.Rprofile in project directory not loaded when calling Build --- Document

RStudio version: Version 1.2.1335, Build 1351 (f1ac3452)
R version: 3.6.0

I have the following code in my .Rprofile in my project directory

.libPaths(
  c(
    projLibPath,
    .libPaths()
  )
)

which is read in the R session. But when I call Build --- Document, the `.Rprofile is not read, which causes errors, as the dependency package(s) are not found (installed in the local project library).

How can I make sure, that the .Rprofile is always loaded?

Thanks,

Rainer

I believe you are talking about package development by using BUILD- DOCUMENT ?

When you click on the button in the IDE, I think it will run the code in another fresh R Session. Usually when build a package, you don't want your user configuration to impact hence the fact that this sessions may not be loading the .Rprofile. (it could be running R with the --no-init-file flag)

However, this button execute devtools::document() on the current folder. You can run this line of code in your current session where .Rprofile has already been loaded and I guess this would work. Can you try ?

Also, can I ask why, as I understand, you are managing package dependencies for your development with your .Rprofile ?

Sorry - thought I already replied.

When you click on the button in the IDE, I think it will run the code in another fresh R Session. Usually when build a package, you don't want your user configuration to impact hence the fact that this sessions may not be loading the .Rprofile. (it could be running R with the --no-init-file flag)

Yes - makes sense and explains the problem.

However, this button execute devtools::document() on the current folder. You can run this line of code in your current session where .Rprofile has already been loaded and I guess this would work. Can you try ?

Yes - that works.

Also, can I ask why, as I understand, you are managing package dependencies for your development with your .Rprofile ?

I wanted to keep packages specific for the development of a certain package separate from my main library, and never got packrat to work as expected, and I assume it would have the same problems.

But I reverted now back to one huge user library.

Thanks.

There is devtools::dev_mode() that can be of help to have a library dedicated to development. By default it uses this option as path: getOption("devtools.path")
Useful to do what you seek.

Also, there is a newer version of packrat called renv and I would go with that now I think

Sounds interesting - I will look into that.

Thanks

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.