2

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’
Tom
  • 279
  • 1
  • 12

1 Answers1

0

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.

Kevin Ushey
  • 20,530
  • 5
  • 56
  • 88
  • Thanks for the response. I have never tried changing the .Renviron, but I have been doing some reading and it looks like I just add an R script called .Renviron which includes the line you suggested ("RENV_PATHS_LIBRARY = /path/to/library") at the base of the project directory. Is this correct? – Tom Nov 13 '20 at 09:59
  • That's right -- `.Renviron` is a list of environment variables of the form ` = `, and can either be placed at the project root, or in your home directory. This is documented in R's help file accessed via `?Startup`. See https://rstudio.github.io/renv/reference/paths.html for documentation on what paths can be customized with `renv`. – Kevin Ushey Nov 13 '20 at 19:19
  • I tried adding a .Renviron file with the line suggested above pointing to a folder outside of the project in a location that meant the filepath didn't contain any spaces or special characters. I still ran into the same problem so it looks like it hasn't had any effect. I tried both R and txt files for the .Renviron file. Am I missing anything like a function that I should be wrapping around that line? – Tom Nov 14 '20 at 17:15
  • Just to note, I have now tried the usethis package to edit my project .Renviron file, which worked. But it also hasn't had an effect. – Tom Nov 14 '20 at 17:30