Newbie installation problem


#1

I’ve been following the Rstan installation page at


and I’ve got down to the very end but when I do the final thing

Verify that your toolchain works by executing the code below in R and checking that it returns the value 10:

fx <- inline::cxxfunction( signature(x = “integer”, y = “numeric” ) , ‘
return ScalarReal( INTEGER(x)[0] * REAL(y)[0] ) ;
’ )
fx( 2L, 5 ) # should be 10

I get this error message

> fx <- inline::cxxfunction( signature(x = "integer", y = "numeric" ) , '
+ return ScalarReal( INTEGER(x)[0] * REAL(y)[0] ) ;
+ ' )
Error in system(cmd, intern = !verbose) : 'D:/Program' not found
> fx( 2L, 5 ) # should be 10
Error in fx(2L, 5) : could not find function "fx"

I am using R 3.4.1 installed in D:\Program Files\R\R-3.4.1
Windows 8 (I think) 32 bit
Rtools is in D:\Rtools.

I don’t have enough room to put R on my C drive. So how can I get it to work with my D drive.


#2

In the file whose path is given by the output of

file.path(Sys.getenv("HOME"), ".R", "Makevars")

you need to put quotation marks around whatever is assigned to the environmental variable CXX. It should possibly look like

CXX="D:\Program Files\Rtools\mingw-64\bin\g++"

Path problem installing RStan in RStudio in 64-bit Windows 10
#3

Having had that same problem a few days ago, I suggest you have a close look at the part of the procedure that says:

Regardless of whether you utilize the C++11 standard, if you use Rtools33 (or higher) then you need to execute the following once.

cat('Sys.setenv(BINPREF = "C:/Rtools/mingw_$(WIN)/bin/")',
file = file.path(Sys.getenv("HOME"), ".Rprofile"), 
sep = "\n", append = TRUE)

Now substitute the C:/RTools part in the command above with your actual path D:/Program files
The command to run should now look like this:

cat('Sys.setenv(BINPREF = "D:/Program files/mingw_$(WIN)/bin/")',
file = file.path(Sys.getenv("HOME"), ".Rprofile"), 
sep = "\n", append = TRUE)

Running that and with a restart, you should be good to go… Good luck!


#4

I had correctly changed the file path to “D:/Rtools/mingw_32/bin/” and I’ve just double-checked that it points to the right place by pasting it into windows explorer and fixing the "/"s … so that’s not the problem.

I added CXX=“D:\Program Files\Rtools\mingw-32\bin\g++” to the Makevars file but I still get the same error message as in my first post…

From my rather meagre knowledge it looks like “it” is treating "“D:/Program” as a separate thing rather than recognising that “D:/Program files/somewhere” is one entire thing.

I have Rtools in D:/Rtools.and R in D:\Program Files\R\R-3.4.1 so it’s trying to do something in RStan rather than Rtools.


#5

Disclaimer - my knowledge may be even more meagre than yours, so forgive me if if I am suggesting things you may have already considered.

When you mean "…fixing the "/"s… " Did you end up using forward slashes or backslashes?
You wrote:

I added CXX=“D:\Program Files\Rtools\mingw-32\bin\g++” (backslashes)
and
“it” is treating "“D:/Program” as a separate thing (forward slash)

I remember trying doubling backslashes (\\) and also using forward slashes in the expression. Unfortunately I cannot remember which worked in the end.

My case was also simpler because I avoid spaces in directory/file names from a habit I took under Linux. I do not understand quite enough to explain clearly but your problem really smells like a “space escape problem”. Hypothesis: when “it” encounters the space character, “it” thinks this is the end of that token and then cannot find the specified D:\Program. I would explore that path (sorry for the bad pun) as you search for a solution.

Again, sorry if I propose things you already duly considered. Good luck.


#6

In the end I re-installed R at D:\R\R-3.4.1 rather than D:\Program Files\R\R-3.4.1 and, after working out what things I’d fiddled with and undoing them, it all seems to be working now.

Thanks for the feedback.