Error in R studio - normalizePath(path.expand(path) winslash mustwork)

I have the Warning message below that appears every time that I open RStudio. I have managed to ignore it, but now it is not letting me install any packages from GitHub.
In normalizePath(path.expand(path), winslash, mustWork) : path[1]="C:/Users/Username/OneDrive/company name/Documents"

The company name has Non-ASCII characters, which I assume is the problem. However, when I look at my system environment variables, there are only two variables related to the Onedrive with the non-ASCII character: OneDrive & OneDriveCommercial.
If I run path.expand("~") or normalizePath("~") the path is to the OneDrive folder.

I have tried to fix it by adding in the .Rprofile the following 2 lines:

R_LIBS_SITE="C:\\Program Files\\R\\R-4.2.1" 
R_LIBS_USER="C:\\Program Files\\R\\R-4.2.1"

But the problem continues.

Any ideas of how to solve it? or Is there any way to change the path.expand("~")?

Thank you so much

I just had my company computer updated to w11 this week and after reinstallation of R Studio I also have this issue where my "~" path is "C:/Users/Username/OneDrive - company name/Documents/" and the company name has a unicode character in it. I have tried on Rgui for r4.2.1 and those methods work fine so it's an R Studio issue. Specifically with the path.expand("~") command as other expansions or normalizations of paths with the same character work as intended.

I have also noticed that I'm missing the a few environment variables when comparing Sys.getenv() of R studio to that of Rgui, notably HOME and R_USER which both have the problem character included. Possibly because it never gets stored due to this error on startup? I wonder if there's a way to manually set this during startup in the file.

I did notice the IT guy install R and R studio at the same time and R finished afterwards. I might try reinstallation to see if that somehow magically fixes my "~" and environment variables.

@shiame I have found a solution that works for me that you might have luck with as well.

The "~" shortcut appears to be bound the first time that path.expand("~") is called and by default is set to your R_USER environment variable. I found that I did not have a R_USER so for some reason it was pulling a raw string of my document directory. I forced one to be loaded by creating a file in the C:\Users\%USERNAME%\AppData\Local\Programs\R\R-4.2.1\etc directory that consist of the following line, of course replacing "Company name" with yours, non-ASCII characters and all:

R_USER=C:\\Users\\%USERNAME%\\"Company name"\\Documents

R studio appears to load this path and is able to start up without the normalizePath() error as well as show me my list of packages.

1 Like

Thank you so much, that works and fixes the problem!

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.