6

I'm trying to install the dev version of tidyr. When I try devtools::install_github("tidyverse/tidyr") or remotes::install_github("tidyverse/tidyr"), I get the following error:

> devtools::install_github("tidyverse/tidyr")
Downloading GitHub repo tidyverse/tidyr@master
Downloading GitHub repo r-lib/vctrs@master
These packages have more recent versions available.
Which would you like to update?

1:   All
2:   CRAN packages only
3:   None
4:   rlang    (0.3.4 -> 18856f22a...) [GitHub]
5:   ellipsis (0.1.0 -> 9908b24a2...) [GitHub]

Enter one or more numbers separated by spaces, or an empty line to cancel
1: 1
rlang    (0.3.4 -> 18856f22a...) [GitHub]
ellipsis (0.1.0 -> 9908b24a2...) [GitHub]
Downloading GitHub repo r-lib/rlang@master
√  checking for file 'C:\Users\owner\AppData\Local\Temp\RtmpYDrYNh\remotes96bc1c295445\r-lib-rlang-18856f2/DESCRIPTION' ...
-  preparing 'rlang': (2s)
√  checking DESCRIPTION meta-information ... 
-  cleaning src
-  installing the package to process help pages (1.3s)
-  cleaning src (27.6s)
-  checking for LF line-endings in source and make files and shell scripts (445ms)
-  checking for empty or unneeded directories (878ms)
-  building 'rlang_0.3.4.9002.tar.gz'

Installing package into ‘C:/Users/owner/Documents/R/win-library/3.5’
(as ‘lib’ is unspecified)
ERROR: failed to lock directory 'C:/Users/owner/Documents/R/win-library/3.5' for modifying
Try removing 'C:/Users/owner/Documents/R/win-library/3.5/00LOCK-rlang'
In R CMD INSTALL
Error in i.p(...) : 
  (converted from warning) installation of package ‘C:/Users/owner/AppData/Local/Temp/RtmpYDrYNh/file96bc24b12ee3/rlang_0.3.4.9002.tar.gz’ had non-zero exit status

I remove 00LOCK-rlang as suggested by the warning and try again. As before, I get asked which packages I want to update and I select All. This time I get the following error when it attempts to update rlang:

installing to C:/Users/owner/Documents/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:\Users\owner\Documents\R\win-library\3.5\rlang\libs\x64\rlang.dll: Permission denied
* removing 'C:/Users/owner/Documents/R/win-library/3.5/rlang'
* restoring previous 'C:/Users/owner/Documents/R/win-library/3.5/rlang'
Error in file.copy(lp, dirname(pkgdir), recursive = TRUE, copy.date = TRUE) : 
  (converted from warning) problem copying C:\Users\owner\Documents\R\win-library\3.5\00LOCK-rlang\rlang\libs\x64\rlang.dll to C:\Users\owner\Documents\R\win-library\3.5\rlang\libs\x64\rlang.dll: Permission denied
Execution halted
In R CMD INSTALL
Error in i.p(...) : 
  (converted from warning) installation of package ‘C:/Users/owner/AppData/Local/Temp/RtmpYDrYNh/file96bc74433a2d/rlang_0.3.4.9002.tar.gz’ had non-zero exit status

Session info after second attempt:

> sessionInfo()
R version 3.5.2 (2018-12-20)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.1        rstudioapi_0.10   magrittr_1.5      usethis_1.5.0     devtools_2.0.2    pkgload_1.0.2     R6_2.4.0          rlang_0.3.4       tools_3.5.2       pkgbuild_1.0.3   
[11] sessioninfo_1.1.1 cli_1.1.0         withr_2.1.2       remotes_2.0.4     yaml_2.2.0        assertthat_0.2.1  digest_0.6.18     rprojroot_1.3-2   crayon_1.3.4      processx_3.3.0   
[21] callr_3.2.0       fs_1.2.7          ps_1.3.0          curl_3.3          rpart_4.1-15      testthat_2.0.1    glue_1.3.1        memoise_1.1.0     compiler_3.5.2    desc_1.2.0       
[31] backports_1.1.4   prettyunits_1.0.2

Using source("https://install-github.me/r-lib/rlang") solved the problem but why did devtools:: and remotes::install_github() fail?

zx8754
  • 52,746
  • 12
  • 114
  • 209
user51462
  • 1,658
  • 2
  • 13
  • 41

2 Answers2

8

I found a slightly different solution.

  1. Open Rgui.exe as Administrator. I don't think you actually need to open Rgui.exe as Administrator but I did so I'll leave it.
  2. Move C:\...\R\win-library\3.5\rlang to another folder (leaving no rlang folder in that directory)
  3. install.packages("rlang")
  4. Close Rgui
  5. Start a new (normal) session and enjoy!
Josh Rumbut
  • 2,640
  • 2
  • 32
  • 43
  • 1
    This worked for me on a computer which I don't have administrative privileges. Also, I did not move the rlang folder. I just did [step 1] + [step 3] and it worked. – Frank Nov 01 '22 at 14:28
7

I experienced this issue as well. Note the [...]\rlang\libs\x64\rlang.dll: Permission denied. The current R-session is not permitted to access these files. To circumvent this, open Rgui.exe by either searching for Rgui in Windows Search via Win+Q, or by the C:\Program Files\R\R-3.5.3\bin\x64\Rgui.exe. Right-click and press Run as administrator, and then do the same thing, as you did before.

You could also run RStudio in Administrative mode.

Mossa
  • 1,656
  • 12
  • 16
  • 4
    I had the same problem. Running R as administrator did not work for me. Running RStudio as administrator did not work either. Running Rgui as administrator solve the problem. I don't understand the reason, but it worked. – Corrado Apr 23 '19 at 13:50
  • Thanks @Mossa, it wouldn't have occurred to me to use the gui - why would there be a difference between installing it there vs RStudio? I had tried running RStudio as admin but that didn't work for me either. – user51462 Apr 24 '19 at 10:52