Home > Net >  R cannot install packages - library is not writable and `No such file or directory`
R cannot install packages - library is not writable and `No such file or directory`

Time:08-05

I know that this question is similar to previously asked questions. However, this question differs in some ways.

I have not been able to install any packages into R for some time now. Here's the code:

install.packages("GGally")
Installing package into ‘C:/Users/my_usernames/Documents/R/win-library/4.1’
(as ‘lib’ is unspecified)
Warning in install.packages :
  'lib = "C:/Users/my_username/Documents/R/win-library/4.1"' is not writable

After this, the system keeps prompting me to use a personal library, to which I clicked Yes enter image description here

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.1/GGally_2.1.2.zip'
Content type 'application/zip' length 1637552 bytes (1.6 MB)
downloaded 1.6 MB

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

Some things that I did but didn't work out:

  1. Running RStudio with administrator privilege

  2. Using Tools > Install Packages --> after this, a prompt to create a personal library appears, and if I click Yes, the prompt keeps reappearing without any action

  3. Checking the folder manually, and I found that the path C:\Users\my_username\Documents\R\win-library\4.1\ exists

  4. Using dir.create and .libPaths() as suggested by teichert in enter image description here

    CodePudding user response:

    install.packages("GGally")
    Installing package into ‘C:/Users/my_usernames/Documents/R/win-library/4.1’
    (as ‘lib’ is unspecified)
    Warning in install.packages :
      'lib = "C:/Users/my_username/Documents/R/win-library/4.1"' is not writable
    

    Maybe you should change "my_usernames" part. you write your your own name

    CodePudding user response:

    maybe you need to run Rstudio as "administrator" to be able to install on this folder. so you can fix that problem

    CodePudding user response:

    After this, the system keeps prompting me to use a personal library, to which I clicked Yes "try to click no"

  • Related