Stan not running after updating to r version 4.0.2 and stan updated from 2.19.3 to 2.21

I am working on a windows 10 sever and updated r from version 4.0 to 4.0.2. I reinstalled rstan from Cran then installed rstan which installed version 2.21 and I was using version 2.19.3. Now I cant rtun stan at all and get the following message which has never happened to me before.

running the command below always worked fine

fit <- stan(file = “SingleComponentBinding.stan”, data = Dat, pars=c(‘Fmaxe1’,‘EC501’,‘sigma’,‘C_pred’,‘theta1’,‘theta2’), + iter = 4000, warmup=2000, chains = 5, thin=2, seed=82058, cores=5, + control=list(adapt_delta=0.9, max_treedepth=10))

but now I get the following error and have spent hour deleting and reinstalling to no avail.

Version:1.0 StartHTML:0000000107 EndHTML:0000002029 StartFragment:0000000127 EndFragment:0000002011

The NEXT version of Stan will not be able to pre-process your stan program please open issue at

https://github.com/stan-dev/stanc3/issues if you can share or at least describe your Stan program. This will help ensure that Stan continues to work on your Stan programs in the future. Thank you! This message can be avoided by wrapping your function call inside suppressMessages(). cannot remove file ‘C:\Users\johnson.rd.1\AppData\Local\Temp\3\Rtmpikkggv\file20ec4e345171.stan’, reason 'No such file or directory’running command ‘C:/PROGRA~1/R/R-4.0.2/bin/x64/R CMD SHLIB file20ec48d11d2a.cpp 2> file20ec48d11d2a.cpp.err.txt’ had status 1cannot open file ‘file20ec48d11d2a.cpp.err.txt’: No such file or directoryError in file(con, “r”) : cannot open the connection Error in sink(type = “output”) : invalid connection

You probably just temporarily need

I just did that still have an issue

Error in file(con, “r”) : cannot open the connection

In addition: Warning messages:

1: In file.remove(c(unprocessed, processed)) :

cannot remove file ‘C:\Users\johnson.rd.1\AppData\Local\Temp\3\RtmpUhJrt0\filefd445fd4320.stan’, reason ‘No such file or directory’

2: In file(con, “r”) :

cannot open file ‘filefd410334aae.cpp.err.txt’: No such file or directory

OK. Does

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

work now?

No

image001.png

No I get

Compilation argument:

C:/PROGRA~1/R/R-4.0.2/bin/x64/R CMD SHLIB file235c380e233a.cpp 2> file235c380e233a.cpp.err.txt

“C:/rtools40/mingw64/bin/“g++ -std=gnu++14 -I"C:/PROGRA~1/R/R-4.0.2/include” -DNDEBUG -I"C:/Program Files/R/R-4.0.2/library/Rcpp/include/” -I"C:/Program Files/R/R-4.0.2/library/RcppEigen/include/" -I"C:/Program Files/R/R-4.0.2/library/RcppEigen/include/unsupported" -I"C:/Program Files/R/R-4.0.2/library/BH/include" -I"C:/Program Files/R/R-4.0.2/library/StanHeaders/include/src/" -I"C:/Program Files/R/R-4.0.2/library/StanHeaders/include/" -I"C:/Program Files/R/R-4.0.2/library/RcppParallel/include/" -I"C:/Program Files/R/R-4.0.2/library/rstan/include" -DEIGEN_NO_DEBUG -DBOOST_DISABLE_ASSERTS -DBOOST_PENDING_INTEGER_LOG2_HPP -DSTAN_THREADS -DBOOST_NO_AUTO_PTR -include “C:/Program Files/R/R-4.0.2/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp” -std=c++1y -march=core2 -include C:/Program Files/R/R-4.0.2/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp -I “C:/Program Files/R/R-4.0.2/library/StanHeaders/include” -I “C:/Program Files/R/R-4.0.2/library/RcppEigen/include” -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -mtune=native -march=native -Wno-ignored-attributes -Wno-deprecated-declarations -c file235c380e233a.cpp -o file235c380e233a.o

g++.exe: error: Files/R/R-4.0.2/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp: No such file or directory

make: *** [C:/PROGRA~1/R/R-4.0.2/etc/x64/Makeconf:229: file235c380e233a.o] Error 1

Error in file(con, “r”) : cannot open the connection

In addition: Warning messages:

1: In file.remove(c(unprocessed, processed)) :

cannot remove file ‘C:\Users\johnson.rd.1\AppData\Local\Temp\3\RtmpC63zGJ\file235c22577c8.stan’, reason ‘No such file or directory’

2: In file(con, “r”) :

cannot open file ‘file235c380e233a.cpp.err.txt’: No such file or directory

image001.png

And packageVersion("rstan") says 2.21.1?

library(rstan)

Loading required package: StanHeaders

Loading required package: ggplot2

rstan (Version 2.21.2, GitRev: 2e1f913d3ca3)

For execution on a local, multicore CPU with excess RAM we recommend calling

options(mc.cores = parallel::detectCores()).

To avoid recompilation of unchanged Stan programs, we recommend calling

rstan_options(auto_write = TRUE)

For improved execution time, we recommend calling

Sys.setenv(LOCAL_CPPFLAGS = ‘-march=native -mtune=native’)

image001.png

OK. I think I need to upload a new StanHeaders to CRAN. Let me see if it passes the reverse dependency checks.

Sorry it is version 2.21.2. My bad

image001.png

Or I can get I from source if you are ok sending me the link.

image001.png

It is not so easy to install from GitHub, but you can basically take

https://cran.r-project.org/src/contrib/StanHeaders_2.21.0-5.tar.gz

unzip it, delete the R/zzz.R file, and then R CMD build StanHeaders/ .

This what is on my system

packageVersion(“StanHeaders”)

[1] ‘2.21.0.5’

image001.png

Yeah, you need the same StanHeaders except without the R/zzz.R file.

What directory is that in?

image001.png

I replaced the StanHeaders file after deleting the zzz file same error

The NEXT version of Stan will not be able to pre-process your Stan program.
Please open an issue at
https://github.com/stan-dev/stanc3/issues
if you can share or at least describe your Stan program. This will help ensure that Stan
continues to work on your Stan programs in the future. Thank you!
This message can be avoided by wrapping your function call inside suppressMessages().
Error in file(con, "r") : cannot open the connection
In addition: Warning messages:
1: In file.remove(c(unprocessed, processed)) :
cannot remove file 'C:\Users\johnson.rd.1\AppData\Local\Temp\3\RtmpuyaCA2\file46478dac2a.stan', reason 'No such file or directory'
2: In system(cmd, intern = !verbose) :
running command 'C:/PROGRA~1/R/R-4.0.2/bin/x64/R CMD SHLIB file464692e2461.cpp 2> file464692e2461.cpp.err.txt' had status 1
3: In file(con, "r") :
cannot open file 'file464692e2461.cpp.err.txt': No such file or directory
Error in sink(type = "output") : invalid connection

image001.png

The directory and the file in question is there on my system

C:\Program Files\R\R-4.0.2\library\StanHeaders\include\stan\math\prim\mat\fun

image001.png

This error makes no sense

error: Files/R/R-4.0.2/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp: No such file or directory

make: *** [C:/PROGRA~1/R/R-4.0.2/etc/x64/Makeconf:229: file1bf09682b05.o] Error 1

Error in file(con, “r”) : cannot open the connection

image001.png

It is because of the space between Program and Files. That is readily fixable, but I’m not sure about the other errors people are getting on Windows.

For people with R 4.x, you can

install.packages(
"https://win-builder.r-project.org/521p7D65m24s/StanHeaders_2.21.0-6.zip",
repos = NULL, type = "win.binary")

to avoid the error due to the space between Program and Files.

1 Like

It appears I still have the same issue. I’m running:

  • Windows 10 with a network drive
  • R version 4.0.2
  • R Studio version 1.3.959
  • Rtools version 4.0
  • packageVersion(“rstan”) = 2.21.1
  • packageVersion(“StanHeaders”) = 2.21.0.6

I completed the steps described here, to try and make sure everything is installed on my internal drive. When running:
.libPaths()

The following is returned:
“C:/R/library” “C:/Program Files/R/R-4.0.2/library”

In a clean R session without any stanfit objects, when running:
example(stan_model, package = “rstan”, run.dontrun = TRUE)

The following is returned:
Error in compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created! C:/rtools40/mingw64/bin/…/lib/gcc/x86_64-w64-mingw32/8.3.0/…/…/…/…/x86_64-w64-mingw32/bin/ld.exe: file3f8e0744e7.o:file3f8e0744e7.cpp:(.text+0x124c): undefined reference to rstan::stan_fit::stan_fit(SEXPREC*, int)' C:/rtools40/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: file3f8e0744e7.o:file3f8e0744e7.cpp:(.text$_ZN3tbb8internal26task_scheduler_observer_v3D1Ev[_ZN3tbb8internal26task_scheduler_observer_v3D1Ev]+0x14): undefined reference to tbb::internal::task_scheduler_observer_v3::observe(bool)’
C:/rtools40/mingw64/bin/…/lib/gcc/x86_64-w64-mingw32/8.3.0/…/…/…/…/x86_64-w64-mingw32/bin/ld.exe: file3f8e0744e7.o:file3f8e0744e7.cpp:(.text$_ZN3tbb8internal26task_scheduler_observer_v3D0Ev[_ZN3tbb8internal26task_scheduler_observer_v3D0Ev]+0x1c): undefined reference to `tbb::internal::task_scheduler_observer_v3::observe(bool)’
C:/rtools40/mingw64/bin/…/lib/gcc/x86_64-w64-m
In addition: Warning messages:
1: package ‘StanHeaders’ was built under R version 4.1.0
2: In file.remove(c(unprocessed, processed)) :
cannot remove file ‘C:\Users\wolf5246\AppData\Local\Temp\RtmpoDt9QP\file3f873d214ed.stan’, reason ‘No such file or directory’

StanHeaders is saved in “C:\R\library\StanHeaders” - so no issue with spaces in the address.