简体   繁体   中英

'lib = "C:/Users/xxx/Documents/R/win-library/4.0"' is not writable

I realize that there are many similar topics such a mine, but none of the appear to resolve my issues. From one day to the next I am now unable to install any packages. I always get the following error:

> install.packages("gapminder")
Installing package into ‘C:/Users/mario/Documents/R/win-library/4.0’
(as ‘lib’ is unspecified)
Warning in install.packages :
  'lib = "C:/Users/mario/Documents/R/win-library/4.0"' is not writable

If I then chose the option to 'use a personal library instead' I get:

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.0/gapminder_0.3.0.zip'
Content type 'application/zip' length 2031853 bytes (1.9 MB)
downloaded 1.9 MB

Warning in install.packages :
  cannot create dir 'C:\Users\mario\Documents\R\win-library\4.0\filecb869a32b3e', reason 'No such file or directory'
Error in install.packages : unable to create temporary directory ‘C:\Users\mario\Documents\R\win-library\4.0\filecb869a32b3e’

Googling on SO and other places suggests that this is a permission issue. Howver, I double checked and I am running RStudio under admin permission and I have double-checked that both RStudio and R 4.0 have full read/write privilege for admins:

在此处输入图像描述

and for regular users:

在此处输入图像描述

The library folder exists and is full of all the libraries that I always use:

在此处输入图像描述

And I believe this is independent of RStudio since going straight to R and trying to install from there leads to the same problems:

在此处输入图像描述

I am running Windows 10 Home 10.0.19041

After way too many hours of frustration I found the culprit:

在此处输入图像描述

Turning off real-time protection on Windows Security fixes the issue:

> install.packages("gapminder")
Installing package into ‘C:/Users/mario/Documents/R/win-library/4.0’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.0/gapminder_0.3.0.zip'
Content type 'application/zip' length 2031853 bytes (1.9 MB)
downloaded 1.9 MB

package ‘gapminder’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
    C:\Users\mario\AppData\Local\Temp\RtmpGi9Jo9\downloaded_packages

That explains why the problem appeared from one day to the next (Windows 10 update) and why it doesn't show on my work laptop (IT-managed updates). Now to figure out how to put R/RStudio on the exclusion list rather than shutting this option off completely.

Mario's solution solved the proble. You can turn on real time protection and go to controlled folder access. When you click on the button, scroll down in the menu to allow an app through controlled folder access.

When you click on add an allowed app and then click on the recently blocked app, just whitelist R apps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM