I've been unable to install any packages

I've been having difficulty lately with RStudio being able to load or install any packages. One day, I suddenly started getting error messages saying that I didn't have packages installed that I previously installed and worked with just fine. Initially, I kept getting error messages saying that RTools was not installed and therefore the packages could not be installed. Eventually, I was able to fix the issue with RTools. However, when I try to install any packages, the installation runs but then I can't load what I installed.

I'm trying to figure out why the package installations are all failing and how I can fix this.

Here is the end of the error message I get when I try: install.packages("ggplot2")

In R CMD INSTALL
Warning in install.packages :

  • installation of package ‘scales’ had non-zero exit status*
    '\RTCFILE02\MyDocs$\A\My Documents\cds projects'
    CMD.EXE was started with the above path as the current directory.
    UNC paths are not supported. Defaulting to Windows directory.
    ERROR: dependencies 'scales', 'withr' are not available for package 'ggplot2'
    ** removing '\RTCFILE02/MyDocs$/alazaros/My Documents/R/win-library/3.5/ggplot2'*
    In R CMD INSTALL
    Warning in install.packages :
  • installation of package ‘ggplot2’ had non-zero exit status*

The downloaded source packages are in

  • ‘C:\Users\A\AppData\Local\Temp\Rtmp2p71Ms\downloaded_packages’*

Please let me know if any more information is required.

Thank you in advance!

Welcome to the community!

Can you share the code you used to install the packages? The code above doesn't do that.

Since you don't have dependencies, you can try install.packages('pkg', dependencies = TRUE)

It seems your package library is in a network drive, R has problems with network drives, I would recommend setting your package library in a local folder or using the system level package library.

You can change the default library folder by setting your R_LIBS_SITE environmental variable on a .Reviron or .Rprofile file

# In a .Renviron file you can set it by adding this line
R_LIBS_SITE="C:\\Program Files\\R\\R-4.0.5\\library"

For a more detailed explanation, you can read this blog post

First of all, thank you! But what do you mean? My code is:

install.packages("ggplot2")

Or am I misunderstanding?

I tried install.packages('pkg', dependencies = TRUE) as well, but I again get an error message:

"In R CMD INSTALL
Warning in install.packages :
installation of package ‘Hmisc’ had non-zero exit status
'\RTCFILE02\MyDocs$\A\My Documents\cds projects'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported. Defaulting to Windows directory.
ERROR: dependencies 'usethis', 'desc', 'httr', 'lifecycle', 'pkgbuild', 'pkgload', 'remotes', 'roxygen2', 'rstudioapi', 'testthat', 'withr' are not available for package 'devtools'

  • removing '\RTCFILE02/MyDocs$/A/My Documents/R/win-library/3.5/devtools'
    In R CMD INSTALL
    Warning in install.packages :
    installation of package ‘devtools’ had non-zero exit status
    '\RTCFILE02\MyDocs$\A\My Documents\cds projects'
    CMD.EXE was started with the above path as the current directory.
    UNC paths are not supported. Defaulting to Windows directory.
    Error: ERROR: no permission to install to directory '\RTCFILE02/MyDocs$/A/My Documents/R/win-library/3.5'
    In R CMD INSTALL
    Warning in install.packages :
    installation of package ‘vdiffr’ had non-zero exit status"

Hi Andre,

This may be a dumb question, but I've been having difficulties in figuring out how to set up/create the .Reviron file. I've tried to create it in Windows PowerShell but haven't had any luck... Do you have any tips or guides? Or know of any other methods for creating the Reviron or Rprofile files?

Thanks!

You can create one with any text editor, even with the Windows Notepad, it is as simple as adding a line like this: R_LIBS_SITE="C:\\Program Files\\R\\R-4.0.5\\library" and saving the file as .Renviron in your "home" folder. The next time R starts is going to read the value from the defined varible.

Hi! First, sorry I missed the code. I was looking at your picture and didn't see any. It's better to paste code in code blocks than use pictures.

Now for your file question do this:
In RStudio create a new text file.
Add any env variables. No R code.
Save the file .Reviron
Done.

Hello,

I saved the Renviron file to the following location "C:\Users\alazaros\R.Renviron", with the file containing the line "R_LIBS_SITE="C:\Program Files\R\R-3.5.3\library"

I restarted R several times but am still unable to install packages

The file should be called .Renviron not R.Renviron