Error during compilation with R 4.0.5 and windows 10

Hello, I have try to compile the example “schools.stan” but I always have the following error:

fit ← stan(file = ‘schools.stan’, data = schools_dat)
make cmd is
make -f “C:/PROGRA~1/R/R-40~1.5/etc/x64/Makeconf” -f “C:/PROGRA~1/R/R-40~1.5/share/make/winshlib.mk” -f “C:\Users\Eduardo Sánchez Ayra\Documents/.R/Makevars.win” CXX=’(CXX14) (CXX14STD)’ CXXFLAGS=’(CXX14FLAGS)' CXXPICFLAGS='(CXX14PICFLAGS)’ SHLIB_LDFLAGS=’(SHLIB_CXX14LDFLAGS)' SHLIB_LD='(SHLIB_CXX14LD)’ SHLIB=“file2c24291c414b.dll” WIN=64 TCLBIN=64 OBJECTS=“file2c24291c414b.o”

make would use
make: “C:\Users\Eduardo Sánchez Ayra\Documents/.R/Makevars.win”: No such file or directory
make: *** No rule to make target ‘“C:\Users\Eduardo Sánchez Ayra\Documents/.R/Makevars.win”’. Stop.
Error in compileCode(f, code, language = language, verbose = verbose) :
make: “C:\Users\Eduardo Sánchez Ayra\Documents/.R/Makevars.win”: No such file or directorymake: *** No rule to make target ‘“C:\Users\Eduardo Sánchez Ayra\Documents/.R/Makevars.win”’. Stop.
Además: Warning message:
In system(paste(CXX, ARGS), ignore.stdout = TRUE, ignore.stderr = TRUE) :
‘C:/rtools40/usr/mingw_/bin/g++’ not found
Error in sink(type = “output”) : conexión inválida

Could anybody help me?

Can you post the outputs from:

Sys.getenv("PATH")
Sys.getenv("BINPREF")
Sys.which("make")
readLines("~/.R/Makevars.win")
readLines("~/.Rprofile")
readLines("~/.Renviron")

Sys.getenv(“PATH”)
[1] “C:\rtools40\usr\bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files\GLEAMviz\libs;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\MATLAB\R2021a\runtime\win64;C:\Program Files\MATLAB\R2021a\bin;C:\Users\Eduardo Sánchez Ayra\AppData\Local\Microsoft\WindowsApps;C:\Users\Eduardo Sánchez Ayra\AppData\Local\Programs\MiKTeX\miktex\bin\x64"”
Sys.getenv(“BINPREF”)
[1] “”
Sys.which(“make”)
make
“C:\rtools40\usr\bin\make.exe”
readLines("~/.R/Makevars.win")
[1] “”
[2] " CXX14FLAGS += -mtune=native -O3 -mmmx -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2"
readLines("~/.Rprofile")
Error in file(con, “r”) : no se puede abrir la conexión
Además: Warning message:
In file(con, “r”) :
no fue posible abrir el archivo ‘C:\Users\Eduardo Sánchez Ayra\Documents/.Rprofile’:
No such file or directory
readLines("~/.Renviron")
[1] “PATH=”{RTOOLS40_HOME}\\usr\\bin;{PATH}""

Thanks!!

“no fue posible abrir el archivo” means “it’s was impossilbe to open the file”
Thanks,

At a guess, it looks like there’s an issue with how its parsing your name in the file path.

Based on what you posted, the file path should be:

C:\Users\Eduardo Sánchez Ayra

But the error message in the first post show the path as:

C:\Users\Eduardo Sánchez Ayra\

I’m not entirely sure how to fix this one, to be honest. As a first step, I’ll get you to try installing the preview of the next RStan release to see if it’s already been fixed. To install, restart R (making sure that rstan doesn’t get loaded) and run:

remove.packages(c("StanHeaders", "rstan"))
install.packages("StanHeaders", repos = c("https://mc-stan.org/r-packages/", getOption("repos")))
install.packages("rstan", repos = c("https://mc-stan.org/r-packages/", getOption("repos")))

Let me know if that doesn’t fix it

Hi, very sorry but it doesn’t fix.

fit ← stan(file = ‘schools.stan’, data = schools_dat)
make cmd is
make -f “C:/PROGRA~1/R/R-40~1.5/etc/x64/Makeconf” -f “C:/PROGRA~1/R/R-40~1.5/share/make/winshlib.mk” -f “C:\Users\Eduardo Sánchez Ayra\Documents/.R/Makevars.win” CXX=’(CXX14) (CXX14STD)’ CXXFLAGS=’(CXX14FLAGS)' CXXPICFLAGS='(CXX14PICFLAGS)’ SHLIB_LDFLAGS=’(SHLIB_CXX14LDFLAGS)' SHLIB_LD='(SHLIB_CXX14LD)’ SHLIB=“file233474225237.dll” WIN=64 TCLBIN=64 OBJECTS=“file233474225237.o”

make would use
make: “C:\Users\Eduardo Sánchez Ayra\Documents/.R/Makevars.win”: No such file or directory
make: *** No rule to make target ‘“C:\Users\Eduardo Sánchez Ayra\Documents/.R/Makevars.win”’. Stop.
Error in compileCode(f, code, language = language, verbose = verbose) :
make: “C:\Users\Eduardo Sánchez Ayra\Documents/.R/Makevars.win”: No such file or directorymake: *** No rule to make target ‘“C:\Users\Eduardo Sánchez Ayra\Documents/.R/Makevars.win”’. Stop.
Error in sink(type = “output”) : conexión inválida

Thanks again¡

Hello again,
I have tried to change the user name but I have some problems with other applications. Do you have any solution?
Thanks

@hsbadr This isn’t directly related to the new version, but any chance you know what a fix might be? I’m not very familiar with localisation issues

Actually, can you try your model with the cmdstanR package? It interacts with Stan in a different way and might not run into this issue.

Instructions for getting setup and running models are here: Getting started with CmdStanR • cmdstanr

Hi,
I have create a new user account (Windowws 10) without “á” just for R + rstan and it is working fine. I prefer to do it that way to concentrate in modelling with Stan rather to install cmdstanR.
I think the problem it is the spanish character “á”, so may be you can debugging this issue in next version.
Anyway, thanks for your support, it was very hepfull.

@andrjohns Sorry for the very late reply! Character encoding is a historical problem in R + C/POSIX standards, especially on Windows. We could encode the paths using functions like enc2native() or enc2utf8(). But, this would fix the local path wrapped by those functions and may easily fail in a later step, when passed to an external function that doesn’t support the current locale.