Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't find init.R on Windows for session watcher #176

Closed
andycraig opened this issue Jan 8, 2020 · 0 comments · Fixed by #177
Closed

Can't find init.R on Windows for session watcher #176

andycraig opened this issue Jan 8, 2020 · 0 comments · Fixed by #177

Comments

@andycraig
Copy link
Collaborator

Here I wrote that on Windows Sys.getenv("HOMEPATH") returns C:\Users\[USERNAME], but when I tried it just now it returned \\Users\\[USERNAME] (without the drive letter). So, when trying to use the session watcher on Windows, I get this error:

Error in file(filename, "r", encoding = encoding) :
  cannot open the connection
In addition: Warning message:
In file(filename, "r", encoding = encoding) :
  cannot open file '\Users\[USERNAME]/.vscode-R/init.R': No such file or directory

Sorry about this, I should have verified that it definitely worked.

Based on https://cran.r-project.org/bin/windows/base/rw-FAQ.html#What-are-HOME-and-working-directories_003f it seems that it should be:

source(file.path(if (.Platform$OS.type == "windows") file.path(Sys.getenv("HOMEDRIVE"), Sys.getenv("HOMEPATH")) else Sys.getenv("HOME"), ".vscode-R", "init.R"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant