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
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:
Running RStudio with administrator privilege
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 actionChecking the folder manually, and I found that the path
C:\Users\my_username\Documents\R\win-library\4.1\
existsUsing
dir.create
and.libPaths()
as suggested byteichert
in a previous threaddir.create(Sys.getenv("R_LIBS_USER"), recursive = TRUE)
.libPaths(Sys.getenv("R_LIBS_USER"))
I also found that some people suggested to configure my R profile using
export R_LIBS_USER=/path/to/your/r-library
or
sudo usermod -a -G staff your_user_name
However, I didn't use any profile while using R or RStudio, so I'm not sure if I have any username or any RStudio profile. I didn't recently update my R or RStudio application as well. I haven't used R or RStudio in a while, and when I opened them again last week the issue pops up.
Any help will be much appreciated. Thank you very much in advance.