I don’t have any strong feelings about OSs. They are just tools. I had been a Mac user for 10+ years since I was 10, and now I’m using Windows for no reason. All OSs have their pros and cons. For example, I like Mac, but, in the late 90s, I was very disappointed at Mac because it didn’t have fonts to display Shift_JIS art nicely.
Anyway, I’m using Windows and I need to survive. Here’s an error I often see when I try to install rlang package from GitHub by
installing to C:/path/to/R/win-library/3.5/rlang/libs/x64 Error in file.copy(files, dest, overwrite = TRUE) : (converted from warning) problem copying .\rlang.dll to C:\path\to\R\win-library\3.5\rlang\libs\x64\rlang.dll: Permission denied
This is because
rlang.dll is used by the current R session (or other session?), so Windows won’t let me overwrite it. What should I do? Here’s some advice.
Restart the R session
This is always necessary. Since rlang is very fundamental package, it might be loaded as a dependency of some attached or loaded package (if you are curious about the differences between load and attach, R Packages helps). You need a fresh session with no packages (except for base packages) loaded. On RStudio,
Ctrl+Shift+F10, or “Restart R” in “Session” menu.
For usual packages, this is enough. But, rlang is not the case…
remotes::install_github() instead of devtools
devtools::install_github() is just re-exported from remotes package. So, are the same one. But, if I use
devtools::, devtools’s dependencies are loaded, and, at the moment, rlang is included here. So, the same error will occur.
On the other hand,
remotes:: doesn’t need rlang directly or indirectly. So, run
(You might also need
remotes::install_github() for other dependency packages like glue.)
Note that, pkg package seems aware of this kind of problems, so we’ll be free from this kind of problems when pkg is mature!
Usually, restarting the session + using
But, in the past, I needed some extra steps. I don’t know why, but it seemed RStudio loads rlang in background (c.f. https://github.com/r-lib/remotes/issues/131). So, for future references, I note some. Hope this will never be needed again…
Removing package might help, since removed package cannot be loaded.
R CMD build and
R CMD INSTALL
If you really need to be away from RStudio, or even from any R sessions.
In those cases, you can use
R CMD build and
R CMD INSTALL on console.
git clone https://github.com/r-lib/rlang R.exe CMD build --no-manual --no-build-vignettes rlang/ R.exe CMD INSTALL [--some-options-i-dont-remember] rlang_*.tar.gz