.libPaths() raising error because Documents folder could not be found by R


I just installed R (4.1.2) and R studio as a complete beginner in Windows 10, and I am trying to install a package called "vcfR".
I wanted to create a specific environment to separate core packages from the ones added by me, creating a folder on this location "C:\Users\Iñigo\R_lib".
However, RStudio raises this error whenever I call .libPaths() to check the default library path. I did not add any locations with c() yet:

> .libPaths()
[1] "C:/Program Files/R/R-4.1.2/library"
Warning message:
In normalizePath(path.expand(path), winslash, mustWork) :
  path[1]="C:/Users/Iñigo/Documents": El sistema no puede encontrar la ruta especificada

Where "El sistema no puede encontrar la ruta especificada" translates to a typical powershell error saying "The system could not find the specified path".
In addition, when I try to install the package to the default location the process seems to start fine but ends
telling me that the package is stored in the Temp folder of my system.

I suspect that the "ñ" character in my user might be a problem. Still, I cannot find any solution to these issues anywhere.

I would greatly appreciate it if someone helped me troubleshoot this.
Thank you,


1 Like

Yes, R has problems with non-ASCII characters in the package library path on Windows, I think this is going to change on the next release with utf8 support on Windows but currently you would need to remove any non-ASCII character from the path.

This doesn't mean that the installation has failed, it is only an informative message about the temporary location of the compiled binaries which are going to be automatically deleted later. Unless you get an actual error message, then most likely the installation process has been successful.

Hi Andrés,

Thank you for your quick reply, I appreciate it. As you said, the packages I needed were successfully installed. (I checked this with the require() function)

I still have a question regarding the error telling that the Documents folder cannot be found. Should I worry about it? Why does R need to access that folder? There is a .Rhistory file containing the command history from the console, which I think RStudio wants to access to display the commands that were prompted in the last session of the IDE. Anyways, I think this should not interfere with the normal functioning of the program.

By default R sets the user-level package library at your HOME directory (which usually is your user name), also, the default working directory is set to your HOME directory.

This is likely to bring you unexpected issues, I would recommend modifying both default locations to a path not containing non-ASCII characters.

Can you explain your motivation for this? I ask because its not typically done. If the motivation is to have different folders per project, this would be better managed by using a system like renv rather than your own libpath management...

I tried changing the default working directory to "C:\Rhomedir" which is a folder I just made for this purpose, but it did not work, the error keeps appearing. I am sure I am missing some concepts here... Could you explain how to do this? Or maybe there is another issue with this?

I am coming from Python, with a mindset of having different environments for (significantly) different projects. Honestly, I did not document myself enough to see this is not the typical way of doing it. Guess I will not need to create a separate environment.

This is the default when you are not in a project, maybe you are in a project and the project is located under your user folder?

For casual use it is not usually necessary but for serious work (which eventually would end up running on a production environment) using renv is a good solution for reproducibility (similar to using virtual environments in Python) and not as complicated as using containers.

I checked this but I am not in any project folder. The console says I am in the "Rhomedir" I made before (double checked with getwd(), but still complains about the Documents path. Maybe Windows has some issue with environment variables?

Also, I will explore this, thank you.

I think this comes from somewhere else. What are your .libPaths()? are you restoring your previous environment on startup? Have you modified your startup files in any way?

Output of .libpaths(): [1] "C:/Program Files/R/R-4.1.2/library".
As far as I know, I am not restoring any previous environment on startup and no startup files were modified manually.

Actually, the screenshot of your global options you showed previously, shows you have that option enabled.

I'm not sure this is the cause though, I'm just trying to discard options.

Also, what is the output of Sys.getenv("R_LIBS_USER") can you try explicitly setting your default package library location on a startup file?

The output I get is the following:

> Sys.getenv("R_LIBS_USER")
[1] "C:/Users/I�igo/Documents/R/win-library/4.1"
Warning message:
In normalizePath(path.expand(path), winslash, mustWork) :
  path[1]="C:/Users/Iñigo/Documents": El sistema no puede encontrar la ruta especificada

So I guess I have to change that location because RStudio is taking it as the default library location for my user?

Yes, but this doesn't have to do with RStudio, this is an R thing.

I think you can avoid that error message by explicitly setting your package library location on a startup file. I would simply add .libPaths(c("C:/Program Files/R/R-4.1. 2/library")) to my Rprofile.site file.

Thank you again, Andrés. I think this did not work since I am still getting the error message. I edited the file adding the row you typed:

However, if this is an R problem, expecting the error to also appear in the pure R GUI, I opened it but the error did not come up. Is reinstalling an option?

Also, the line above the highlighted one seems to also be interesting for solving the problem. However, the "site-library" directory does not exist. I tried uncommenting the ".Library.site ..." line but also not working...

Edit: Okay reinstalling did not work at all :c

That is weird, startup files can be found on other locations (with different scopes), maybe the R-version level Rprofile.site file is being overwrite by another startup file, a .Rprofile at your HOME folder maybe?

I have never experienced this error before but the only explanation I can think of is that your user level package library is being set to your HOME directory at startup so I would check all possible startup configuration files including Renviron.site and .Renviron files.

However, besides being annoying, it is not going to bring you major issues.

Is it weird that there is no .Renviron file in my "Documents" folder? Should I manually create it? I read it should be there. Contrarily, .Rhistory is indeed located there.
I cannot find any .Renviron nor Renviron.site files in my .../users/Iñigo/Documents folder.

No, they are not present by default

Not necessarily, only if you need to define environment variable that are specific to your user.

I can't reproduce the error message you get and since there no similar reports flooding the forum I would assume this is an issue specific to your system, which makes it hard to solve.

If I ever fix the issue, I'll report it in a similar topic.

Thank you for all your help, I appreciate it!

I have exactly the same problem, with libPaths, Document folder, getting In normalizePath(path.expand(path), winslash, mustWork) :
path[1]="C:/Users/Iñigo/Documents": El sistema no puede encontrar la ruta especificada (except getting it in French)

To date I did not find any proper solution, I am sorry to tell you :frowning:
I just switched to Linux and no problems so far...