'Error in normalizePath(path.expand(path), winslash, mustWork) : path[1]="NA": The system cannot find the file specified
Each time after I open RStudio, the first line of code I enter will result in this warning:
Warning message: Error in normalizePath(path.expand(path), winslash, mustWork) : path[1]="NA": The system cannot find the file specified
This only happens once. As long as I don't close the document, for example, this warning will not show up anymore. However, if I close RStudio and open it again, the first time I run any code will reproduce the same warning.
This only happens for RStudio. If I use R instead, everything works normally.
I tried to supress this warning with supressWarnings()
, suppressWarnings(suppressMessages())
or even invisible(capture.output(suppressWarnings(suppressMessages())))
to no avail.
I normally wouldn't care about warning messages, but since I'm working with RMarkdown, the warnings show up in the final document, so it's really annoying.
Thanks a lot for any help.
Solution 1:[1]
OK, I solved this by reinstalling both R and RStudio with their latest releases. The warnings have stopped.
Solution 2:[2]
Some days ago, when I installed the latest versions of R and RStudio, I had the same warning message at each time after I open RStudio. The reason of the warning message was my account name in Windows which contains accented vowels. (I created an account name without accented vowels, then I installed R and RStudio again, and the warning message disappeared.)
However, I was able to avoid the problem with my old account name with accented vowels as follows:
Install the R and RStudio in a folder to which you have admin rights. (I created a folder called R on my disk C, therefore its path is C:\R.)
In RStudio, list the environment variables:
Sys.getenv()
The path of the environment variables that contain the account name with incorrect symbols shall be changed by creating a file called .Renviron.
The .Renviron file shall be placed where you installed R. In my case it is C:\R. I chose this folder as the new path. Therefore, my .Renviron file contains the following three lines:
HOMEPATH="C:\R"<br>
HOME="C:\R"<br>
R_USER="C:\R"
(The .Renviron file was created in Notepad. When I saved the file I selected .Renviron as file name and All types was chosen as file type.)
The default working directory can also be permanently changed as follows: In RStudio go to the menu: Tools / Global options / General. In the field "Default working directory (when not in a project)" choose a folder whose path does not have accented vowels. (I chose C:\R.)
Finally, restart RStudio and the warning message disappears.
As a side note, I created empty .RData and .RHistory files in RStudio which are stored in the folder C:\R. By using these files, objects created in R and commands can be saved at the end of the working session.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | rnahumaf |
Solution 2 | benson23 |