R install.packages 返回“错误:无法锁定目录”

Bre*_*ent 10 r install.packages tidyverse

[与14382209类似的问题,但那里的建议没有解决这个问题]

\n\n

在 Windows 7 工作计算机上新安装 R 4.0.0tidyverse会返回此经典的“无法创建锁定目录”错误

\n\n
 install.packages(\'tidyverse\')\nWARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding:\n\nhttps://cran.rstudio.com/bin/windows/Rtools/\nInstalling package into \xe2\x80\x98\\\\ukbia04sfsrv002.a04.dt21.svcs.hp.com/users/A04/ocarrib/R/win-library/4.0\xe2\x80\x99\n(as \xe2\x80\x98lib\xe2\x80\x99 is unspecified)\nalso installing the dependencies \xe2\x80\x98highr\xe2\x80\x99, \xe2\x80\x98markdown\xe2\x80\x99, \xe2\x80\x98testthat\xe2\x80\x99, \xe2\x80\x98RColorBrewer\xe2\x80\x99, \xe2\x80\x98viridisLite\xe2\x80\x99, \xe2\x80\x98askpass\xe2\x80\x99, \xe2\x80\x98rematch\xe2\x80\x99, \xe2\x80\x98prettyunits\xe2\x80\x99, \xe2\x80\x98processx\xe2\x80\x99, \xe2\x80\x98knitr\xe2\x80\x99, \xe2\x80\x98yaml\xe2\x80\x99, \xe2\x80\x98htmltools\xe2\x80\x99, \xe2\x80\x98evaluate\xe2\x80\x99, \xe2\x80\x98base64enc\xe2\x80\x99, \xe2\x80\x98tinytex\xe2\x80\x99, \xe2\x80\x98xfun\xe2\x80\x99, \xe2\x80\x98backports\xe2\x80\x99, \xe2\x80\x98generics\xe2\x80\x99, \xe2\x80\x98reshape2\xe2\x80\x99, \xe2\x80\x98assertthat\xe2\x80\x99, \xe2\x80\x98glue\xe2\x80\x99, \xe2\x80\x98fansi\xe2\x80\x99, \xe2\x80\x98DBI\xe2\x80\x99, \xe2\x80\x98lifecycle\xe2\x80\x99, \xe2\x80\x98R6\xe2\x80\x99, \xe2\x80\x98tidyselect\xe2\x80\x99, \xe2\x80\x98ellipsis\xe2\x80\x99, \xe2\x80\x98pkgconfig\xe2\x80\x99, \xe2\x80\x98Rcpp\xe2\x80\x99, \xe2\x80\x98BH\xe2\x80\x99, \xe2\x80\x98plogr\xe2\x80\x99, \xe2\x80\x98digest\xe2\x80\x99, \xe2\x80\x98gtable\xe2\x80\x99, \xe2\x80\x98isoband\xe2\x80\x99, \xe2\x80\x98scales\xe2\x80\x99, \xe2\x80\x98withr\xe2\x80\x99, \xe2\x80\x98vctrs\xe2\x80\x99, \xe2\x80\x98curl\xe2\x80\x99, \xe2\x80\x98mime\xe2\x80\x99, \xe2\x80\x98openssl\xe2\x80\x99, \xe2\x80\x98utf8\xe2\x80\x99, \xe2\x80\x98clipr\xe2\x80\x99, \xe2\x80\x98cellranger\xe2\x80\x99, \xe2\x80\x98progress\xe2\x80\x99, \xe2\x80\x98callr\xe2\x80\x99, \xe2\x80\x98fs\xe2\x80\x99, \xe2\x80\x98rmarkdown\xe2\x80\x99, \xe2\x80\x98whisker\xe2\x80\x99, \xe2\x80\x98selectr\xe2\x80\x99, \xe2\x80\x98stringi\xe2\x80\x99, \xe2\x80\x98broom\xe2\x80\x99, \xe2\x80\x98cli\xe2\x80\x99, \xe2\x80\x98crayon\xe2\x80\x99, \xe2\x80\x98dbplyr\xe2\x80\x99, \xe2\x80\x98dplyr\xe2\x80\x99, \xe2\x80\x98forcats\xe2\x80\x99, \xe2\x80\x98ggplot2\xe2\x80\x99, \xe2\x80\x98haven\xe2\x80\x99, \xe2\x80\x98hms\xe2\x80\x99, \xe2\x80\x98httr\xe2\x80\x99, \xe2\x80\x98jsonlite\xe2\x80\x99, \xe2\x80\x98lubridate\xe2\x80\x99, \xe2\x80\x98magrittr\xe2\x80\x99, \xe2\x80\x98modelr\xe2\x80\x99, \xe2\x80\x98pillar\xe2\x80\x99, \xe2\x80\x98purrr\xe2\x80\x99, \xe2\x80\x98readr\xe2\x80\x99, \xe2\x80\x98readxl\xe2\x80\x99, \xe2\x80\x98reprex\xe2\x80\x99, \xe2\x80\x98rlang\xe2\x80\x99, \xe2\x80\x98rstudioapi\xe2\x80\x99, \xe2\x80\x98rvest\xe2\x80\x99, \xe2\x80\x98stringr\xe2\x80\x99, \xe2\x80\x98tibble\xe2\x80\x99, \xe2\x80\x98tidyr\xe2\x80\x99, \xe2\x80\x98xml2\xe2\x80\x99\n\n\n  There are binary versions available but the source versions are later:\n       binary source needs_compilation\nmodelr  0.1.6  0.1.7             FALSE\nxml2    1.3.1  1.3.2              TRUE\n\n  Binaries will be installed\ntrying URL \'https://cran.rstudio.com/bin/windows/contrib/4.0/highr_0.8.zip\'\nContent type \'application/zip\' length 48579 bytes (47 KB)\ndownloaded 47 KB\n\n# .... Output edited for brevity #\n\ntrying URL \'https://cran.rstudio.com/bin/windows/contrib/4.0/tidyverse_1.3.0.zip\'\nContent type \'application/zip\' length 440009 bytes (429 KB)\ndownloaded 429 KB\n\npackage \xe2\x80\x98highr\xe2\x80\x99 successfully unpacked and MD5 sums checked\nError in install.packages : ERROR: failed to lock directory \xe2\x80\x98\\\\ukbia04sfsrv002.a04.dt21.svcs.hp.com\\users\\A04\\ocarrib\\R\\win-library\\4.0\xe2\x80\x99 for modifying\nTry removing \xe2\x80\x98\\\\ukbia04sfsrv002.a04.dt21.svcs.hp.com\\users\\A04\\ocarrib\\R\\win-library\\4.0/00LOCK\xe2\x80\x99\n
Run Code Online (Sandbox Code Playgroud)\n\n

然后试用rtools

\n\n
 install.packages(\'rtools\')\nWARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding:\n\nhttps://cran.rstudio.com/bin/windows/Rtools/\nInstalling package into \xe2\x80\x98\\\\ukbia04sfsrv002.a04.dt21.svcs.hp.com/users/A04/ocarrib/R/win-library/4.0\xe2\x80\x99\n(as \xe2\x80\x98lib\xe2\x80\x99 is unspecified)\nWarning in install.packages :\n  package \xe2\x80\x98rtools\xe2\x80\x99 is not available (for R version 4.0.0)\n
Run Code Online (Sandbox Code Playgroud)\n\n

然后尝试:\n-00lock直接从指定位置删除文件夹 (~A04\\ocarrib\\R\\win-library\\4.0/00LOCK)\n- 重新启动 R\n- 不走运,同样的错误

\n\n

然后尝试选项:

\n\n
> install.packages("tidyverse", dependencies = TRUE, INSTALL_opts = \'--no-lock\')\nWARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding:\n\nhttps://cran.rstudio.com/bin/windows/Rtools/\nInstalling package into \xe2\x80\x98\\\\ukbia04sfsrv002.a04.dt21.svcs.hp.com/users/A04/ocarrib/R/win-library/4.0\xe2\x80\x99\n(as \xe2\x80\x98lib\xe2\x80\x99 is unspecified)\nalso installing the dependencies \xe2\x80\x98RColorBrewer\xe2\x80\x99, \xe2\x80\x98viridisLite\xe2\x80\x99, \xe2\x80\x98askpass\xe2\x80\x99, \xe2\x80\x98rematch\xe2\x80\x99, \xe2\x80\x98prettyunits\xe2\x80\x99, \xe2\x80\x98processx\xe2\x80\x99, \xe2\x80\x98lazyeval\xe2\x80\x99, \xe2\x80\x98backports\xe2\x80\x99, \xe2\x80\x98generics\xe2\x80\x99, \xe2\x80\x98reshape2\xe2\x80\x99, \xe2\x80\x98assertthat\xe2\x80\x99, \xe2\x80\x98fansi\xe2\x80\x99, \xe2\x80\x98DBI\xe2\x80\x99, \xe2\x80\x98lifecycle\xe2\x80\x99, \xe2\x80\x98R6\xe2\x80\x99, \xe2\x80\x98tidyselect\xe2\x80\x99, \xe2\x80\x98ellipsis\xe2\x80\x99, \xe2\x80\x98pkgconfig\xe2\x80\x99, \xe2\x80\x98Rcpp\xe2\x80\x99, \xe2\x80\x98BH\xe2\x80\x99, \xe2\x80\x98plogr\xe2\x80\x99, \xe2\x80\x98digest\xe2\x80\x99, \xe2\x80\x98gtable\xe2\x80\x99, \xe2\x80\x98isoband\xe2\x80\x99, \xe2\x80\x98scales\xe2\x80\x99, \xe2\x80\x98withr\xe2\x80\x99, \xe2\x80\x98vctrs\xe2\x80\x99, \xe2\x80\x98curl\xe2\x80\x99, \xe2\x80\x98mime\xe2\x80\x99, \xe2\x80\x98openssl\xe2\x80\x99, \xe2\x80\x98utf8\xe2\x80\x99, \xe2\x80\x98clipr\xe2\x80\x99, \xe2\x80\x98cellranger\xe2\x80\x99, \xe2\x80\x98progress\xe2\x80\x99, \xe2\x80\x98callr\xe2\x80\x99, \xe2\x80\x98fs\xe2\x80\x99, \xe2\x80\x98whisker\xe2\x80\x99, \xe2\x80\x98selectr\xe2\x80\x99, \xe2\x80\x98stringi\xe2\x80\x99, \xe2\x80\x98rex\xe2\x80\x99, \xe2\x80\x98yaml\xe2\x80\x99, \xe2\x80\x98evaluate\xe2\x80\x99, \xe2\x80\x98highr\xe2\x80\x99, \xe2\x80\x98markdown\xe2\x80\x99, \xe2\x80\x98xfun\xe2\x80\x99, \xe2\x80\x98htmltools\xe2\x80\x99, \xe2\x80\x98base64enc\xe2\x80\x99, \xe2\x80\x98tinytex\xe2\x80\x99, \xe2\x80\x98broom\xe2\x80\x99, \xe2\x80\x98cli\xe2\x80\x99, \xe2\x80\x98crayon\xe2\x80\x99, \xe2\x80\x98dbplyr\xe2\x80\x99, \xe2\x80\x98dplyr\xe2\x80\x99, \xe2\x80\x98forcats\xe2\x80\x99, \xe2\x80\x98ggplot2\xe2\x80\x99, \xe2\x80\x98haven\xe2\x80\x99, \xe2\x80\x98hms\xe2\x80\x99, \xe2\x80\x98httr\xe2\x80\x99, \xe2\x80\x98jsonlite\xe2\x80\x99, \xe2\x80\x98lubridate\xe2\x80\x99, \xe2\x80\x98magrittr\xe2\x80\x99, \xe2\x80\x98modelr\xe2\x80\x99, \xe2\x80\x98pillar\xe2\x80\x99, \xe2\x80\x98purrr\xe2\x80\x99, \xe2\x80\x98readr\xe2\x80\x99, \xe2\x80\x98readxl\xe2\x80\x99, \xe2\x80\x98reprex\xe2\x80\x99, \xe2\x80\x98rlang\xe2\x80\x99, \xe2\x80\x98rstudioapi\xe2\x80\x99, \xe2\x80\x98rvest\xe2\x80\x99, \xe2\x80\x98stringr\xe2\x80\x99, \xe2\x80\x98tibble\xe2\x80\x99, \xe2\x80\x98tidyr\xe2\x80\x99, \xe2\x80\x98xml2\xe2\x80\x99, \xe2\x80\x98covr\xe2\x80\x99, \xe2\x80\x98feather\xe2\x80\x99, \xe2\x80\x98glue\xe2\x80\x99, \xe2\x80\x98knitr\xe2\x80\x99, \xe2\x80\x98rmarkdown\xe2\x80\x99, \xe2\x80\x98testthat\xe2\x80\x99\n\n\n  There are binary versions available but the source versions are later:\n       binary source needs_compilation\nmodelr  0.1.6  0.1.7             FALSE\nxml2    1.3.1  1.3.2              TRUE\n\n  Binaries will be installed\ntrying URL \'https://cran.rstudio.com/bin/windows/contrib/4.0/RColorBrewer_1.1-2.zip\'\nContent type \'application/zip\' length 55583 bytes (54 KB)\ndownloaded 54 KB\n\n# Output edited for brevity\n\npackage \xe2\x80\x98RColorBrewer\xe2\x80\x99 successfully unpacked and MD5 sums checked\npackage \xe2\x80\x98viridisLite\xe2\x80\x99 successfully unpacked and MD5 sums checked\npackage \xe2\x80\x98askpass\xe2\x80\x99 successfully unpacked and MD5 sums checked\nError in install.packages : ERROR: failed to lock directory \xe2\x80\x98\\\\ukbia04sfsrv002.a04.dt21.svcs.hp.com\\users\\A04\\ocarrib\\R\\win-library\\4.0\xe2\x80\x99 for modifying\nTry removing \xe2\x80\x98\\\\ukbia04sfsrv002.a04.dt21.svcs.hp.com\\users\\A04\\ocarrib\\R\\win-library\\4.0/00LOCK\xe2\x80\x99\n
Run Code Online (Sandbox Code Playgroud)\n\n

还有其他想法吗?

\n\n

会议信息:

\n\n
> sessionInfo()\nR version 4.0.0 (2020-04-24)\nPlatform: x86_64-w64-mingw32/x64 (64-bit)\nRunning under: Windows 7 x64 (build 7601) Service Pack 1\n\nMatrix products: default\n\nlocale:\n[1] LC_COLLATE=English_United Kingdom.1252  LC_CTYPE=English_United Kingdom.1252   \n[3] LC_MONETARY=English_United Kingdom.1252 LC_NUMERIC=C                           \n[5] LC_TIME=English_United Kingdom.1252    \n\nattached base packages:\n[1] stats     graphics  grDevices utils     datasets  methods   base     \n\nloaded via a namespace (and not attached):\n[1] compiler_4.0.0 tools_4.0.0 \n
Run Code Online (Sandbox Code Playgroud)\n

小智 15

  1. 打开R文件夹(下载后首先保存 R 的位置)

  2. 00lock通过更改位置来删除文件夹 - 剪切并粘贴到另一个位置。

  3. 尝试下载该库。


小智 8

如果您使用的是 Ubuntu Linux,您可以00LOCK-<package>在位置找到该文件夹/home/<your-computer-name>/R/x86_64-pc-linux-gnu-library/<your-R-version>​​。删除该文件夹后00LOCK-<package>,尝试再次安装该软件包,它现在应该可以工作了!