2022-02-25 R包安装问题2:failed to lock directory

install.packages("glue")
Installing package into ‘/home/xxxx/R/x86_64-pc-linux-gnu-library/3.5’
(as ‘lib’ is unspecified)
trying URL 'https://cloud.r-project.org/src/contrib/glue_1.6.2.tar.gz'
Content type 'application/x-gzip' length 106510 bytes (104 KB)
==================================================
downloaded 104 KB

ERROR: failed to lock directory ‘/home/xxx/R/x86_64-pc-linux-gnu-library/3.5’ for modifying
Try removing ‘/home/xxxx/R/x86_64-pc-linux-gnu-library/3.5/00LOCK-glue’
Warning in install.packages :
installation of package ‘glue’ had non-zero exit status

The downloaded source packages are in
‘/tmp/RtmpYKJA0j/downloaded_packages’

------------ 解决方法 ----------------
原理是发生锁竞争错误了。
了解到R可以通过unlink的方式,来关闭这个链接,释放这个lock文件,重新执行就没问题啦。

unlink("/home/xxxx/R/x86_64-pc-linux-gnu-library/3.5/00LOCK-glue",recursive = TRUE)

然后重新安装包

你可能感兴趣的:(2022-02-25 R包安装问题2:failed to lock directory)