6

I use Rstudio and try to add new packages through command console.

It fails to install it for this reason

install.packages("devtools"); devtools::install_github("hadley/rvest")
Warning in install.packages :
  'lib = "C:/Program Files/R/R-3.2.1/library"' is not writable
Warning in install.packages :
  cannot create dir 'C:\Users\myuser', reason 'Permission denied'
Error in install.packages : unable to create ‘C:/Users/myuser/Documents/R/win-library/3.2’
Error in loadNamespace(name) : there is no package called ‘devtools’

How can I make this file writable?

angs
  • 341
  • 3
  • 5
  • 13
  • You probably need administrator privileges. –  Jun 24 '15 at 05:37
  • Change the library directory to a directory where you have writing privileges. See `?install.packages`. – Roland Jun 24 '15 at 07:34
  • @Roland I tried something like this for a package I have download as zip it is not working install.packages('C:/Users/Desktop/rvest-master.zip', type='source', lib='C:/Users/newpath',repos = NULL). Do you mean to change totally the path for all package? I show the link you provide. It mentions this problem but I didn't find any example how to make it. Any help will be very helpful for me. I am administrator to my pc windows 8 64 – angs Jun 24 '15 at 19:22

4 Answers4

5

Changing the security setting on the R folder to "full control" fixed this for me. See the third posting down at this link for step by step instructions: Unable to update R packages in default library on Windows 7

Community
  • 1
  • 1
George
  • 66
  • 1
4

Just run RStudio as an administrator. Right-Click on it and choose run as Administrator

1

I ran into this problem. The issue for me was using single quotes instead of double quotes. Using install.packages("foo") worked fine, whereas install.packages('foo') caused this issue.

Adam_G
  • 7,337
  • 20
  • 86
  • 148
1

As i have found out that disabling the Ransomware protection on Window Defender allows me to write in the directory.

This solved the problem. Hope it works for you.

  • This worked in my situation. The error was as OP but occurred with full admin permission on the library and when running RStudio as administrator. Ransomware Protection was blocking the unzip and install (download of the package itself was working). – benj Feb 02 '22 at 13:06