Error install .packages :cannot open file

I keep receiving this error messages .I've already installed Rtools and I don't know what to do.Please help.

Error in install.packages : cannot open file 'C:/Users/user/OneDrive/Documents/R/win-library/4.1/file2ca018f6568/pacman/pacman_logo/r_pacman.png': Permission denied

Installing package into ‘C:/Users/user/OneDrive/Documents/R/win-library/4.1’
(as ‘lib’ is unspecified)
Warning: unable to access index for repository
cannot open URL ''

R has problems with cloud synced folders (OneDrive in your case) I would recommend setting your default package library in a non synced folder

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

# In a .Renviron file you can set it by adding a line like this one with the desired location 
R_LIBS_SITE="C:\\Program Files\\R\\R-4.1.1\\library"

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

Also, this seems like a connectivity issue, R is not being able to connect to the CRAN repository you have selected, these are some things to try.

  • Choose a different CRAN repository, RStudios repository is a good choice ( or you could choose one that is geographically closer to you.
  • Disable secure download setting.
  • Check if your internet connection has traffic restrictions of some kind, like a firewall, proxy server, etc. This is usually the case when you are at work or school.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.