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

Windows: Backslash (\) as path separator causes error. #1009

Closed
fereshtehRS opened this issue Nov 9, 2015 · 11 comments
Closed

Windows: Backslash (\) as path separator causes error. #1009

fereshtehRS opened this issue Nov 9, 2015 · 11 comments

Comments

@fereshtehRS
Copy link

fereshtehRS commented Nov 9, 2015

Might be by design. But on Windows it is more intuitive to use "" as path separator.

@shrektan
Copy link
Contributor

shrektan commented Nov 9, 2015

I think use \\ would be ok.

@yihui
Copy link
Member

yihui commented Nov 9, 2015

@fereshtehRS What exactly was the error message?

@shrektan It may be okay on Windows as long as you make the assumption that your app will never run on *nix. In general I'd suggest you avoid \ since it is not portable. Is there a reason that you cannot use the forward slash / that works on both Windows and *nix?

@fereshtehRS
Copy link
Author

For this path: read.csv("C:\Users\fereshteh\Downloads\rock.csv")

Error is:

> runApp()

Listening on http://127.0.0.1:5760
Warning in file(file, "rt") :
ock.csv': Invalid argumentrs\fereshteh\Downloads
Error in file(file, "rt") : cannot open the connection

For this path: read.csv("C:\Users\fereshteh\Downloads\rock.csv")
Error is:

> runApp()

Listening on http://127.0.0.1:5760
Error : '\U' used without hex digits in character string starting ""C:\U"

@yihui I agree that it is a good practice to use "/" instead of "". But we should at least detect and give a proper error and hint.

@wch
Copy link
Collaborator

wch commented Nov 9, 2015

@fereshtehRS, don't you need read.csv("C:\\Users\\fereshteh\\Downloads\\rock.csv")? The single backslash followed by U will make it think you're specifying a unicode value, I think.

@yihui
Copy link
Member

yihui commented Nov 9, 2015

Exactly. This is a general R issue: when you need a literal backslash \, use two \\.

@fereshtehRS
Copy link
Author

Right @wch. That is the case for second error.
@yihui Also correct; error is coming from R. I wonder if Shiny could provide a better error.

@yihui
Copy link
Member

yihui commented Nov 9, 2015

That is also the case for the first error. It happens that \r is a legitimate control character (carriage return), and that is why the error message looks mangled (\r means move to the beginning of the current line then print the following characters).

I think this is an FAQ of R itself. Windows may be constantly surprised by the fact that they need double backslashes in file paths. I'm not sure if we really need to address this issue in Shiny.

@fereshtehRS
Copy link
Author

Yeah, the garbled message is caused by the escaping. Unfortunately R error messages are not intuitive at all. I saw this user was totally lost when he got this error for his shiny app. Not sure what we can do about it; if nothing, then we can close this ticket.

@shrektan
Copy link
Contributor

@yihui Ha, didn't notice that \\ is not portable. Luckily, I use / all the time, so never meet problems on Linux env... Thanks any way.

@yihui
Copy link
Member

yihui commented Nov 10, 2015

@fereshtehRS I completely agree this is fairly confusing to those who do not understand the escaping rules in R. It may be possible to detect such problems with a certain linter (https://github.com/rstudio/rsconnect/blob/master/R/linters.R), but I'm not the right person to decide if this is worth it (given it is not an issue specific to shiny) or work on it.

@fereshtehRS
Copy link
Author

@yihui I'll close this; agree that it is not a priority.

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

No branches or pull requests

4 participants