Compilation error when running the main stan function. I receive an error that several files used by StanHeaders cannot be found (even when they exist).
Description:
I am a new Stan user and had no problem with installation of all dependencies. However, when I try to run a simple “Hello, world” type example (found here), I receive a compilation error that I put under the current output section.
I have messed with changing the Makevars.win file and tried several others alternatives I found within the issues requests, but to no avail. From the output, I believe the issue to be related somehow to the file name having a space, but Program Files should be the standard in all of Windows file naming, how would this be an issue?
Reproducible Steps:
remove(list = ls())
library(rstan)
hello.stan <- 'data {
int<lower=0> N;
vector[N] y;
}
parameters {
real mu;
real<lower=0> sigma;
}
model {
y ~ normal(mu, sigma);
}
'
N <- 100
y <- rnorm(N, mean = 5, sd = 10)
stanfit <- stan(model_name = hello.stan, data = list(N, y))
Current Output:
Error in compileCode(f, code, language = language, verbose = verbose) : Compilation ERROR, function(s)/method(s) not created! g++.exe: error: Files/R/R-3.6.2/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp: No such file or directory g++.exe: error: Files/R/R-3.6.2/library/StanHeaders/include: No such file or directory g++.exe: error: Files/R/R-3.6.2/library/RcppEigen/include: No such file or directory make: *** [C:/PROGRA~1/R/R-3.6.2/etc/x64/Makeconf:215: file4f647a08385b.o] Error 1
This was an issue with the StanHeaders version getting ahead of the RStan version on CRAN, since some of the file paths changed between the two versions. It’s since been reverted but CRAN is still providing the 2.21 binaries. To fix this you need to reinstall the packages from source:
I am having the same issue on a Windows 7 OS (bootcamp on Mac), with R 3.6.2. I have tried your suggestions, and it doesn’t seem to help. I am getting the exact same errors as smonto2.
Yes I do. Here is the actual output. It is possible I missed something, but I think it is the same error as above.
`Error in compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created! g++.exe: error: Files/R/R-3.6.2/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp: No such file or directory
g++.exe: error: Files/R/R-3.6.2/library/StanHeaders/include: No such file or directory
g++.exe: error: Files/R/R-3.6.2/library/RcppEigen/include: No such file or directory
make: *** [C:/PROGRA~1/R/R-36~1.2/etc/x64/Makeconf:215: fileff83e8625cb.o] Error 1
In addition: Warning message:
In system(cmd, intern = !verbose) :
running command ‘C:/PROGRA~1/R/R-36~1.2/bin/x64/R CMD SHLIB fileff83e8625cb.cpp 2> fileff83e8625cb.cpp.err.txt’ had status 1
Error in sink(type = “output”) : invalid connection
package ‘StanHeaders’ successfully unpacked and MD5 sums checked
package ‘rstan’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\User\AppData\Local\Temp\Rtmp44eSx2\downloaded_packages
library(rstan)
Loading required package: StanHeaders
Loading required package: ggplot2
rstan (Version 2.19.3, 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=corei7 -mtune=corei7’)
although this causes Stan to throw an error on a few processors.
However, I got it to run after I did some troubleshooting with the rlang package. It wanted to update to v0.4.8 from source, but when I did that it errored out. when I reverted to the binary version, it was successful.
Not sure why that mattered, but I got the idea when trying to install brms and it was erroring out on the rlang package.
Thanks,
devtools::session_info(“rstan”)
Session info ---------------------------------------------------------------------------------------
setting value
version R version 4.0.2 (2020-06-22)
os Windows 7 x64 SP 1
system x86_64, mingw32
ui RStudio
language (EN)
collate English_United States.1252
ctype English_United States.1252
tz America/Chicago
date 2020-10-13