Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is this a bug in R 3.5?

Tags:

windows

r

When I call Rscript.exe for Version 3.5 of R, it is unable to open the file if the file name or path has a space in it. I saved 2 files with the code:

cat("What do you get when you multiply 6 * 9?")

as C:\foo bar.R and as C:\foo_bar.R

When I in a DOS command window try to run these using version 3.4.3 and 3.5:

C:\>"C:\Program Files\R\R-3.4.3\bin\x64\Rscript.exe" "C:\foo bar.R"
What do you get when you multiply 6 * 9?
C:\>"C:\Program Files\R\R-3.4.3\bin\x64\Rscript.exe" "C:\foo_bar.R"
What do you get when you multiply 6 * 9?
C:\>"C:\Program Files\R\R-3.5.0\bin\x64\Rscript.exe" "C:\foo bar.R"
Fatal error: cannot open file 'C:\foo': No such file or directory


C:\>"C:\Program Files\R\R-3.5.0\bin\x64\Rscript.exe" "C:\foo_bar.R"
What do you get when you multiply 6 * 9?
C:\>

When I try to run the file with a space in the name in version 3.5.0 of R, there is a fatal error saying there is no such file.

like image 506
Kerry Jackson Avatar asked Apr 25 '18 17:04

Kerry Jackson


1 Answers

Thanks Edward Carney, I emailed the address you listed, and got a response from Tomas confirming it is a bug, and providing a workaround until it is fixed:

A quick workaround before this gets fixed is to add an extra first argument that has no space in it, e.g.

Rscript --vanilla "foo bar.R"

The problem exists on all systems, not just Windows.

This has now been corrected in the Development version, and there is a binary build for Windows at: https://cran.r-project.org/bin/windows/base/rdevel.html

It has also been corrected in the patched version, and there is a binary build for Windows at: https://cran.r-project.org/bin/windows/base/rpatched.html

like image 185
Kerry Jackson Avatar answered Nov 19 '22 10:11

Kerry Jackson