Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7073521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:56:22+00:00 2026-05-28T05:56:22+00:00

I am trying to use the function insertSource (new in R 2.12) to update

  • 0

I am trying to use the function insertSource (new in R 2.12) to update a function that I have made changes on.

However, when I use the function in this way:

insertSource('filename.R', package = 'mypackage')

I get the error:

Error in get(this, envir = envp) : object '.cacheOnAssign' not found

Unfortunately I can not come up with a simple reproducible example – if one would be helpful, please suggest how I can do it – but I have found that the following code does work:

system("echo 'nls <- function(nls) return(nls)' > foo.R")
insertSource('foo.R', package = stats)

One difference between the stats package and mypackage is the library location (mypackage is in ‘~/lib/R/’. (update): error still occurs when .libPaths('~/lib/R') is in .Rprofile, and googleing ‘.cacheOnAssign’ only returns 6 hits, two of them to this question.

Questions:

  1. what does the error mean?
  2. How can I use insertSource?

Debugging

using options(error = recover)

options(error = recover) 
Error in get(this, envir = envp) : object '.cacheOnAssign' not found
Called from: get(this, envir = envp)
Browse[1]> where
where 1: get(this, envir = envp)
where 2: insertSource("filename.R", "mypackage")
Browse[1]> ls()
[1] "q"
Browse[1]> n
>

not sure what to make of these results, and where to go from here

using options(error = browser) gives more information that I have placed in a text file

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T05:56:23+00:00Added an answer on May 28, 2026 at 5:56 am

    This is arguably a bug in insertSource(). When you supply a file instead of an environment, it calls evalSource() on the file which synthesizes the .cacheOnAssign variable (it will be simply FALSE) in the source environment. That chokes the replacement since the variable does not necessarily exist in the package namespace.

    There are several ways around this, probably the easiest is to create the environment yourself and remove .cacheOnAssign like in this fix:

    insertSource <- function(source, package="", ...) {
        if (!is(source, "environment")) {
            source <- evalSource(source, package = package, lock = FALSE)
            rm(.cacheOnAssign, envir = source)
        }
        methods::insertSource(source, package = package, ...)
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use this function in a C program that needs to be
I am trying to use this function from a COM API which enables the
I'm trying to use the replace function in JavaScript and have a question. strNewDdlVolCannRegion
I'm trying to use the .Contains() function on a list of custom objects. This
I am trying to use eval() function to deserialize this JSON text by using
I'm trying to use the function [context].startSubActivity([intent i]) but that won't compile. Apparently startSubActivity()
I'm trying to use the CreateProcessWithTokenW() win32 API function to start a new process
I have a problem where I'm trying to use a function from another module
I'm trying to use a function that has the following signature to sign a
I have a user function that returns a BIT calle dbo.IsPartReady. I am trying

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.