Unable to update R packages in default library on Windows 7

六月ゝ 毕业季﹏ 提交于 2019-12-27 17:30:50

问题


I'm trying to update packages on RGui (64-bit) using update.packages but I'm getting the following message:

Warning in install.packages(update[instlib == l, "Package"], l, contriburl = contriburl,  :
  'lib = "C:/PROGRA~1/R/R-212~1.1/library"' is not writable
Error in install.packages(update[instlib == l, "Package"], l, contriburl = contriburl,  : 
  unable to install packages

I've looked at the library folder in Explorer and it has read only set, so I removed it. However, it reappears when I check the properties again immediately after doing this. Installing new packages is unaffected since they have a separate folder in my user profile.

Is there a trick to getting this to work?


回答1:


Usually you need administrator rights to change things in program files. Try running RGui as administrator.




回答2:


It happens the same to me, and after coding hours and hours in "R" of Gui Project, i got bored because it is much easier to read a code when the interface uses colours for a certain type of words (commands). Well, i decided to install RStudio, but soon i was faced with package installation problems. It seems that happens in Windows 7. The way that I used to solve this problem with RSutido was:

  1. C:\Program Files\R - and this is the folder that contains "R" and not RStudio folder!
  2. Right click for properties.
  3. Security.
  4. In "Group or user names" select your name
  5. click "Edit"
  6. select "Full control"
  7. Apply and click OK

After this steps you should be ok to install all the packages :-)




回答3:


try

install.packages('package_name', lib='folder')

you can specify a folder for installation of the libraries, for which you have writing permission.

Hope this helps




回答4:


Uninstalling from C:\Program Files and re-installing to C:\R worked for me

[See mdsumner's comment and Windows FAQ found here]

"...Users of Vista/Windows 7/8/Server 2008/2012 installing for a single user using an account with administrator rights1 should consider installing into a non-system area (such as C:\R)"




回答5:


I had this exact problem and just changed it for myself. That is I navigated to C:/PROGRAM/R and then right clicked on the R to bring up properties. Went to the Security tab clicked on the Group/User that you want to add permissions for. That for me was USER then clicked EDIT and then selected the boxes that were unchecked to Allow control over. I had to do this specifically for each user (of course I was running the entire time as administrator). Clicked Apply/OK and all is well. I can now update/install/ new libraries and what have you for this computer without having to run R as the admin.




回答6:


Without more information, my first guess is that you have insufficient permissions to write to the R site library folder. Usually, R would prompt for creation of a user lib folder to install to, but this can be unreliable under Windows Vista/Windows 7.

Try:

dir.create(Sys.getenv("R_LIBS_USER"), recursive = TRUE)

In the R console. Libraries should now install to /Users/"you"/R/win-library/x.y, for which you have the appropriate permissions.




回答7:


I have BitDefender 2018 and had to disable "safe files" and "firewall".




回答8:


Try choosing a cranmirror location closer to you with this command first

chooseCRANmirror()

And then try installing the package. This command worked for me when I was getting warnings on installing "devtools".




回答9:


I also had this kind of problem in Windows 10, Then I disable "Safe Files" in Bitdefender 2018. It works for me




回答10:


I had a similar error recently. Running RStudio as an administrator didn't work. And changing the permissions on C:/Programs/R is a bit clumsy, as you'd have to repeat it for every user.

The solution for me was changing the library path for R as follows

  1. In the R console, type .libPaths(). You'll see something like this,

    "Path/to/user/R/win-library/x.x" "C:/Programs/R/R-x.x.x"

    The two paths exist because you have defined a user-specific lib path during installation. Replace x.x.x with your R version.

  2. Now set the lib path to the Programs directory

    .libPaths = "C:/Programs/R/R-x.x.x"

Now you can install.packages() or update.packages()!



来源:https://stackoverflow.com/questions/5059692/unable-to-update-r-packages-in-default-library-on-windows-7

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!