How can I install a package to a directory that includes an apostrophe using makeLazyLoading?

Viewed 198

In RStudio, I have set up a new project using renv. I am trying to install the RMarkdown package and its dependencies. However, the pathname for my project includes an apostrophe and spaces which is preventing me from installing certain packages. I can't change this pathname (it is synced from OneDrive business account). Is it still possible to install these packages?

Here is the error message (I have changed the pathname a bit but it follows the same format with apostrophe and spaces in the same place)...

Error: unexpected symbol in "tools:::makeLazyLoading("rmarkdown", "/Users/name/business account's name/team/project/renv/staging/1/00LOCK-rmarkdown/00new", keep.source = FALSE, keep.parse.data = FALSE, set.install.dir = '/"
Execution halted
ERROR: lazy loading failed for package ‘rmarkdown’
* removing ‘/Users/name/business account's name/team/project/renv/staging/1/rmarkdown’
1 Answers

Likely, the most straightforward fix in your case would be to change that project's library path to point somewhere without any special characters. For example, you could place this in your project's .Renviron:

RENV_PATHS_LIBRARY = /path/to/library

where /path/to/library is some writable filepath without any apostrophes or other special characters.

The other approach you could try is to disable R's staged installation -- e.g. something like:

Sys.setenv(R_INSTALL_STAGED = "false")
install.packages("rmarkdown", type = "source", INSTALL_opts = "--no-test-load")

Or, if using renv:

Sys.setenv(R_INSTALL_STAGED = "false")
options(install.opts = "--no-test-load")
renv::install("rmarkdown")

Those options could be set in your .Rprofile / .Renviron files as appropriate -- see ?Startup for more details.

Related