0

I am facing a problem while trying to install packages in Rstudio.

For example, I face this error when I try to install devtools:

> install.packages("devtools")

  'lib = "C:/Program Files/R/R-4.0.3/library"' is not writable
Error in install.packages : unable to install packages 

Any suggestions about what should I do?

Phil
  • 7,287
  • 3
  • 36
  • 66
  • 2
    Usually it would prompt you to create a personal (user-specific) library. Did you get no such message? That's not where you usually install package unless you were running as administrator or something. What version of R are you running and on what OS version? What does `.libPaths()` return? – MrFlick Jan 28 '21 at 19:12
  • Whether it prompted you or not, I recommend you create a directory for this use. On windows, it should default to looking for (and using, if found) `HOME/R/win-library/x.y` (where HOME is often either `c:/Users/yourname/Documents/` or just `c:/Users/yourname/`; and `x.y` are the major/minor versions of R). For instance, on mine, it's `C:/Users/r2/R/win-library/4.0` (I have R-4.0.3). If that directory does not exist, then created it, restart RStudio and/or R, and then re-attempt to install the package(s) you need. – r2evans Jan 28 '21 at 19:32
  • @MrFlick thank you for your reply...I am getting a message about creating a personal library but when I confirm I face the following problem/error `Warning in install.packages : cannot create dir 'C:\Users\giorg\OneDrive\???????', reason 'Invalid argument' Error in install.packages : unable to create ‘C:/Users/giorg/OneDrive/???????/R/win-library/4.0’ `................... `.libPaths()` returns: `"C:/Program Files/R/R-4.0.3/library"` – Giorgos Xantziplakis Jan 28 '21 at 19:56
  • 1
    It seems you are using OneDrive which is likely causing the problem. Maybe this guide can help: https://medium.com/@ValidScience/how-to-fix-rstudios-package-installation-on-windows-10-c1e602bf3a1f or this possible duplicate: https://stackoverflow.com/a/42643674/2372064 – MrFlick Jan 28 '21 at 19:59
  • @MrFlick Thank you very much for your help, problem solved! – Giorgos Xantziplakis Jan 28 '21 at 20:23
  • 1
    @r2evans Thank you for your reply and your time! – Giorgos Xantziplakis Jan 28 '21 at 20:24

0 Answers0