# Unable to install packages/Create library

### Error Information:

I have just installed R and Rstudio, but when I try to install package through Rstudio, it says

Warning in install.packages :
'lib = "C:/Program Files/R/R-3.6.1/library"' is not writable
Warning in install.packages :
cannot create dir 'C:\Users\jimmy\OneDrive??', reason 'Invalid argument'
Error in install.packages : unable to create ‘C:/Users/jimmy/OneDrive/??/R/win-library/3.6’
Warning message:
In dir.create(tempPath, recursive = TRUE) :
cannot create dir 'C:\Users\jimmy\OneDrive??', reason 'Invalid argument'

Anyone knows how to fix this?
Thank you

#### System Information:

• RStudio Edition: Desktop
• R Version: 3.6.1

Seems like it doesn't like question marks in the file path. What is the output of calling .libPaths() for you?

.libPaths()


Try creating a directory somewhere locally that you have write permission like C:\Users\jimmy\rlibrary and then setting that as the .libPath in R using

.libPaths("C:\Users\jimmy\rlibrary")


After then, when you're installing packages using the dialog Tools>Install Packages.. make sure that the "Install to Library:" option matches the directory you created.

If that allows you to install packages, you'll have to setup that directory as your default library path. You can do this by creating a .Rprofile file in your home directory and adding the libPaths("path\to\your\lib") command into it so it gets run when Rstudio starts.

Run RStudio as administrator to have write permissions on the system level library path "C:/Program Files/R/R-3.6.1/library" or define a user level library on a non cloud-synced folder.

Thanks, I ran as an administrator, then it worked!

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