r-windows / docs

Documentation for rtools40 and R for Windows
31 stars 10 forks source link

Cannot find path to C++ compiler #17

Closed pfifas closed 4 years ago

pfifas commented 4 years ago

All,

I encounter a problem after installing R 4.0.0 and Rtools40 on my Windows machine. Due to corporate IT, I cannot install into C:\ but have to move R and RTools into C:\Users\<user_id>\AppData\. I set that path manually during installation.

Installation completed successfully. Next, I followed the instructions to create an .Renviron file and wrote

PATH="${RTOOLS40_HOME}\usr\bin;${PATH}"

into it, using writeLines('PATH="${RTOOLS40_HOME}\\usr\\bin;${PATH}"', con = "~/.Renviron") as suggested.

After that, running Sys.which("make") correctly returns:

"C:\\Users\\<user_id>\\AppData\\rtools40\\usr\\bin\\make.exe"

Looking at the PATH also seems to include the right folders, because writeLines(strsplit(Sys.getenv("PATH"), ";")[[1]]) gives (just see the third entry, is this a leftover from an earlier Rtools probably, that's causing trouble here?)

C:\Users\<user_id>\AppData\rtools40\usr\bin; C:\Users\<user_id>\AppData\R-4.0.0\bin\x64; C:\Users\<user_id>\AppData\Rtools\bin

The more detailed check suggested in the FAQs then reveals a problem, because

R <- file.path(R.home('bin'), 'R') system2(R, c("CMD", "config", "CXX11"))

returns:

The system cannot find the path specified. C:/Rtools/mingw_64/bin/g++

That is, R does not seem to find the right path and then fall back to some default path.

When I try to install jsonlite from source, I do get the following error:

install.packages("jsonlite", type = "source") The system cannot find the path specified. * installing *source* package 'jsonlite' ... ** Package 'jsonlite' successfully unpacked and MD5 sums checked ** using staged installation ** libs *** arch - i386 C:/Rtools/mingw_32/bin/gcc -I"C:/Users/<user_id>/AppData/R-40~1.0/include" -DNDEBUG -Iyajl/api -D__USE_MINGW_ANSI_STDIO -O2 -Wall -std=gnu99 -mfpmath=sse -msse2 -mstackrealign -c base64.c -o base64.o sh: C:/Rtools/mingw_32/bin/gcc: No such file or directory make: *** [C:/Users/>user_id>/AppData/R-40~1.0/etc/i386/Makeconf:222: base64.o] Error 127 ERROR: compilation failed for package 'jsonlite'

which seems to be related to the fact that R isn't looking for make in the right place, since the error message states that it is looking at C:/Rtools/mingw_32/bin/gcc.

Any further information (Session info etc.) needed to get to the bottom of this?

Any help much appreciated!

BR Pfifas

jeroen commented 4 years ago

Are you somewhere overriding the BINPREF environment variable? Try in R:

Sys.getenv("BINPREF")

This should be empty. If not you should unset this variable in R 4.0 / rtools40. It looks like you are currently overriding the path to the toolchains.

pfifas commented 4 years ago

Jeroen,

Thanks for the swift response. Indeed, I did have an .Rprofile file in my home directory to set the BINPREF as you noticed.

After removing that, I can now compile, e.g., the jsonlite package from source. So I'm happy (what I was really after is using rstan, but that works too).

That said,

R <- file.path(R.home('bin'), 'R') system2(R, c("CMD", "config", "CXX11"))

Still gives: The system cannot find the path specified. C:/Users/<user_id>/AppData/rtools40/mingw64/bin/g++

So it falls back to the correct location, but does not seem to find it right away.

I get a related warning when using Stan through package brms, where it states:

1: In system(cmd, intern = !verbose) : Execution of command 'C:/Users/<user_id>/AppData/R-40~1.0/bin/x64/R CMD SHLIB file330858734106.cpp 2> file330858734106.cpp.err.txt' returned Status 1 2: In system2(file.path(Sys.getenv("R_HOME"), "bin", "R"), args = "CMD SHLIB --dry-run", : Execution of command '"C:/Users/<user_id>/AppData/R-40~1.0/bin/R" CMD SHLIB --dry-run' returned Status 1

Just reporting that back for your information.

Many thanks again for your help - amazing support.

BR Pfifas

jeroen commented 4 years ago

Strange I am not sure where The system cannot find the path specified. warning comes from.

Does this also give the warning?

 tools::Rcmd(c("config", "CXX11"))
pfifas commented 4 years ago

Yes, gives the same warning.

mdmanurung commented 4 years ago

I am also having this problem. Is there any solution yet?

jeroen commented 4 years ago

What problem? Please include all the details about what you are doing and the error message.

mdmanurung commented 4 years ago

I installed R 4.0.2 and Rtools40 in Windows 10. I followed the guide to install the Rtools.

Sys.which("make") correctly returns the path to make. Sys.getenv("BINPREF") is empty as suggested. However, installing from source leads to error The system cannot find the path specified.

tools::Rcmd(c("config", "CXX11")) also reported The system cannot find the path specified.

But then I saw someone having a similar problem here . Apparently, such error can be caused by a rogue entry in the registry HKCU\Software\Microsoft\Command Processor\AutoRun. In my case, it was due to the insertion of conda into the PATH.

After deleting the registry, everything works fine!

jeroen commented 4 years ago

Thanks for the details! What exactly did conda put on the path that would cause this error?

mdmanurung commented 4 years ago

I think it was a path to Clink.