Rstan error, [C:/PROGRA~1/R/R-41~1.1/etc/x64/Makeconf:245: file96411659f3.o] Error 127

Hi, I encounter this error when I run

example(stan_model, package = “rstan”, run.dontrun = TRUE).

The error is:

Error in compileCode(f, code, language = language, verbose = verbose) :
sh: line 1: D:/Program: No such file or directorymake: *** [C:/PROGRA~1/R/R-41~1.1/etc/x64/Makeconf:245: file96411659f3.o] Error 127
Error in sink(type = “output”) : invalid connection

I’ve seen ther threads with similar errors, such as this, but the error isnt 100% the same and none of the solutions work . Also devtools wont load for some reason. I get this output.

devtools::session_info(“rstan”)
Error in loadNamespace(x) : there is no package called ‘devtools’

I’ve also tried reinstalling R and Rtools4 to no avail.

Any help would be appericated. Thanks!

Can you post the outputs from:

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

Are you able to install packages from source:

install.packages("jsonlite",type="source")

Hi Andrjohns, this is what i get from the 4 lines. Theres no errors.

readLines(“~/.Renviron”)
[1] “PATH="{RTOOLS40_HOME}\\usr\\bin;{PATH}"”
readLines(“~/.R/Makevars.win”)
[1] “”
[2] " CXX14FLAGS += -mtune=native -O3 -mmmx -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2"
Sys.which(“make”)
make
“C:\rtools40\usr\bin\make.exe”
Sys.getenv(“PATH”)
[1] “C:\rtools40\usr\bin;C:\Program Files\R\R-4.1.1\bin\x64;C:\Windows\System32;C:\Windows;C:\Windows\System32\wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Windows\System32\OpenSSH;C:\Users\ps172\AppData\Local\Microsoft\WindowsApps;C:\Users\ps172\AppData\Local\GitHubDesktop\bin”
Sys.getenv(“BINPREF”)
[1] “”

However, I did counter something while trying to install jsonlite.

  • installing source package ‘jsonlite’ …
    ** package ‘jsonlite’ successfully unpacked and MD5 sums checked
    ERROR: cannot remove earlier installation, is it in use?
  • removing ‘C:/Users/ps172/Documents/R/win-library/4.1/jsonlite’
  • restoring previous ‘C:/Users/ps172/Documents/R/win-library/4.1/jsonlite’
    Warning in file.copy(lp, dirname(pkgdir), recursive = TRUE, copy.date = TRUE) :
    problem copying C:\Users\ps172\Documents\R\win-library\4.1\00LOCK-jsonlite\jsonlite\libs\x64\jsonlite.dll to C:\Users\ps172\Documents\R\win-library\4.1\jsonlite\libs\x64\jsonlite.dll: Permission denied
    Warning in install.packages :
    installation of package ‘jsonlite’ had non-zero exit status

The downloaded source packages are in
‘C:\Users\ps172\AppData\Local\Temp\RtmpAxa5gC\downloaded_packages’

Thanks,

Try this one:

remove.packages("jsonlite")
install.packages("jsonlite",type="source")

Hi Andrjohns,

This is what i get fro the code:

remove.packages(“jsonlite”)
Removing package from ‘C:/Users/ps172/Documents/R/win-library/4.1’
(as ‘lib’ is unspecified)
Error in remove.packages : there is no package called ‘jsonlite’

  • installing source package ‘jsonlite’ …
    ** package ‘jsonlite’ successfully unpacked and MD5 sums checked
    ** using staged installation
    ** libs
    C:/rtools40/usr/mingw_64/bin/gcc -I"C:/PROGRA~1/R/R-41~1.1/include" -DNDEBUG -Iyajl/api -D__USE_MINGW_ANSI_STDIO -O2 -Wall -std=gnu99 -mfpmath=sse -msse2 -mstackrealign -c base64.c -o base64.o
    sh: line 1: C:/rtools40/usr/mingw_64/bin/gcc: No such file or directory
    make: *** [C:/PROGRA~1/R/R-41~1.1/etc/x64/Makeconf:238: base64.o] Error 127
    ERROR: compilation failed for package ‘jsonlite’
  • removing ‘C:/Users/ps172/Documents/R/win-library/4.1/jsonlite’
    Warning in install.packages :
    installation of package ‘jsonlite’ had non-zero exit status

The downloaded source packages are in
‘C:\Users\ps172\AppData\Local\Temp\RtmpeENZb1\downloaded_packages’

Thanks

It looks like the paths to the compilers have been setup for R3.6, which isn’t compatible with the directory structure of RTools4. Was this installation setup by an IT department or similar, or just your personal installation?

Also, what do you get from:

Sys.which("gcc")
Sys.which("g++")

I installed it myself to do a assignment for uni. I just followed the quick guide on github.

Sys.which(“gcc”)
gcc
“”
Sys.which(“g++”)
g++
“”

I don’t get anything from the 2 lines.

Did you have a previous R installation that was overwritten, or was this the first time that you installed R?

It was the first time I intstalled R on this PC (about 1 months ago). I uninstalled and reinstalled a few times yesterday hoping it would fix the problem. Maybe that is the issue?

Have you tried reinstalling RTools?

I did that yesterday and just tried it again. (Rtools40-x86_64) I still get the same output from “install.packages(“jsonlite”,type=“source”)”.

Can you uninstall RTools and try the new version (rtools40v2-x86_64.exe), from here: Using Rtools4 on Windows

Make sure that you close R before these steps as well

Hi,

I unistalled Rtools from control panel > program > program files, and installed Rtools4v2.
I also checked to see if PATH="${RTOOLS40_HOME}\usr\bin;${PATH}was in .Renviron.
I also made sure to quit R when doing this

It didn’t work, I still get the same error from trying to download jsonlite.

Thanks,

Hmm, do you have a .Rprofile file? That might have some configuration settings?

readLines("~/.Rprofile")

Yes, it gives:

readLines(“~/.Rprofile”)
[1] “Sys.setenv(BINPREF = "C:/rtools40/usr/mingw_$(WIN)/bin/")”

Ah. Yes. That’s the issue. Delete that file and you’ll be good to go.

Do you know why you set that? Was this manually created following a guide somewhere?

I dont think I set that. I remember seeing this thread specifically saying to “unlist” .rprofile.

I’ve also tried all sorts of answers from differrnt threads hoping something would stick so maybe that was done by accident.

The example code now works! Thanks so much

example code:
example(stan_model, package = “rstan”, run.dontrun = TRUE)

1 Like