Cannot install any package in RStudio (ver 1.4.1717) with R for Windows 4.1.1

I installed R for Windows 4.1.1 and RStudio version 1.4.1717 successfully.
However, when I pressed 'Install Packages..." at the tab "Tools", the following window popped up. The message in the window is "Would you like to create a personal library 'C:/Users/Wong's PC/OneDrive/??/R/win-library/4.1' to install packages into?", and there "Yes" and "No" button. After I clicked the "Yes" button, the same window popped up again. If I clicked the "No" button, another window popped up with message "Unable to install packages (default library 'C:/Program Files/R/R 4.1.1/library' is not writeable)"
error1
I'm using Chinese Windows 10, and I chose English version while installing R.
It seems that the default value of "Install to library" in "Install Packages" changed, can I change back the value in "Install to library" to default? What can I do to install package?

Thanks!

Best regards,
CCWong

You have write permissions issues, this is not related to R or RStudio but to your Windows configuration, but also, even if you solve the write permissions issue, you are going to find even more issues down the road if you set your package library in a cloud synced folder (OneDrive), so I recommend you to yo set your package library somewhere else (the system level package library is my preferred choice for personal use on Windows).

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

Hi Andresrcs,

Thanks for your reply. However, I cannot find the file with extension .Rprofile or .Renviron. Does R and RStudio in Windows version also have .Rprofile or .Renviron file?

Thanks a lot!

Best regards,
CCWong

Dear Andresrcs,

I found the file "Rprofile".
Do I need to change the sentence
Sys.setenv(R_LIBS_SITE =
.expand_R_libs_env_var(Sys.getenv("R_LIBS_SITE")))
to
Sys.setenv(R_LIBS_SITE = "C:\Program Files\R\R-4.1.1\library"?
How about the sentence
.Library.site <- Sys.getenv("R_LIBS_SITE")? Do I need to delete the sentence?

Thanks!

Bes regards,
CCWong

If you run R studio as administrator, the problem is solved.

Dear Andresrcs,

I can install package in RStudio now,

Thanks a lot!

Best regards,
CC Wong

This topic was automatically closed 21 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.