You may have leftover files, but it should only be using the new ones. What is the output of
example(stan_model, package = "rstan", run.dontrun = TRUE)
now?
You may have leftover files, but it should only be using the new ones. What is the output of
example(stan_model, package = "rstan", run.dontrun = TRUE)
now?
This is the output… output.txt (53.6 KB)
That ran fine (although saving it in Word makes it harder to read). What is the output when you encounter the error but specify verbose = TRUE
when calling stan
or sampling
?
Here is the output:
TRANSLATING MODEL ‘lm_2wayanova’ FROM Stan CODE TO C++ CODE NOW.
successful in parsing the Stan model ‘lm_2wayanova’.
CHECKING DATA AND PREPROCESSING FOR MODEL ‘lm_2wayanova’ NOW.
COMPILING MODEL ‘lm_2wayanova’ NOW.
STARTING SAMPLER FOR MODEL ‘lm_2wayanova’ NOW.
SAMPLING FOR MODEL ‘lm_2wayanova’ NOW (CHAIN 1).
Chain 1: empty_nested() must be true before calling recover_memory()
[1] “Error in sampler$call_sampler(args_list[[i]]) : "
[2] " empty_nested() must be true before calling recover_memory()”
error occurred during calling the sampler; sampling not done
Hi, I wanted to mention an error I get that may be related to the whole Catalina thing - please let me know if you prefer I open a separate thread for this.
When I run a Stan model that is syntactically incorrect, I get
Error in stanc(file = file, model_code = model_code, model_name = model_name, : c++ exception (unknown reason)
I don’t get any error when running a correct Stan model. I thought it might be related because of the c++ exception (unknown reason)
.
Also, when I click the “check” button for Stan syntax in RStudio, it doesn’t return anything if the model is incorrect.
This is a simple problem to bypass - whenever check syntax doesn’t return anything I’ll just assume I made an error in coding my Stan model. I just wanted to make sure you’re aware of this. Do other people experience this too?
I assume that problem goes away if you compile rstan from source via
install.packages("rstan", type = "source")
?
Yes it does! Thanks for the quick reply.
Hello everyone,
I am still not able to have rstan working properly.
I now freshly installed R, Rstudio and installed the macos-rtools [v3.2.2] without having XCode installed on the mac, but I am still having the same issue as before.
Do you have any new suggestion?
Thanks
I also just tried to freshly install everything having XCode already installed…
And I modified Makevars as you suggested, but I’m still getting
[1] “Error in sampler$call_sampler(args_list[[i]]) : " " c++ exception (unknown reason)”
error occurred during calling the sampler; sampling not done
Hi @Save,
macos-rtools
. Follow these instructions..R/Makevars
:CFLAGS=-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
CCFLAGS=-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
CXXFLAGS=-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
CPPFLAGS=-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include
SHLIB_CXXLDFLAGS+=-Wl,-rpath,/Library/Frameworks/R.framework/Resources/lib /Library/Frameworks/R.framework/Resources/lib/libc++abi.1.dylib
SHLIB_CXX11LDFLAGS+=-Wl,-rpath,/Library/Frameworks/R.framework/Resources/lib /Library/Frameworks/R.framework/Resources/lib/libc++abi.1.dylib
SHLIB_CXX14LDFLAGS+=-Wl,-rpath,/Library/Frameworks/R.framework/Resources/lib /Library/Frameworks/R.framework/Resources/lib/libc++abi.1.dylib
rstan
from source:install.packages("rstan", type = "source")
The above worked for me :)
Thanks for the reply @torkar
I now used a mac just restored to factory settings and updated to Catalina.
Installed R 3.6.2
Installed R studio 1.2.5033
Installed Xcode 11.3, licence accepted
Installed macos.-rtools 3.2.2
Modified .R/Makevars using the terminal as you just suggested me…
Installed rstan from source…
But I still get the same error:
[1] “Error in sampler$call_sampler(args_list[[i]]) : " " c++ exception (unknown reason)”
error occurred during calling the sampler; sampling not done
What am I doing differently?
Did you install Xcode command line tools?
yes I did. the macos-rtools does it…
I tried anyway to install them from the terminal afterwards and it says it’s installed already…
I have the exact same software that you have and it works for me. Could you post a minimum working example here so I can try it out?
I removed everything again and then reinstalled manually the Command Line Tools, clang7 and gfortran6.1(without using the macos-rtools)… and now models are sampling fine!
Thanks again for all the support you gave me!
Managed to stumble across R’s build settings for CRAN official binaries here:
https://svn.r-project.org/R-dev-web/trunk/QA/Simon/R-build
Relevant file is:
https://svn.r-project.org/R-dev-web/trunk/QA/Simon/R-build/fixpathR
The bug is related to clang4
complier being hard coded inside the fixpathR script.
Instances:
find . -name \*.dylib -or -name \*.so| xargs -n 1 install_name_tool -change /usr/local/clang4/lib/$gcclib $R/lib/$gcclib
and
install_name_tool -change /usr/local/clang4/lib/$gcclib $R/lib/$gcclib $rbin
I’ve flagged it for Simon and should hear back soon ™.
Hi I’m on Catalina and recently I installed the rstan on my rstudio but it doesn’t work with the following error though I also installed the Xcode according to its recommendation to run the package.
Error in sink(type = “output”) :
: Warning message:
In system(cmd, intern = !verbose) :
‘/Library/Frameworks/R.framework/Resources/bin/R CMD SHLIB file248670b432b1.cpp 2> file248670b432b1.cpp.err.txt’
Error in map2stan(alist(y ~ dnorm(mu, sigma), mu ~ dnorm(0, 14.14), sigma ~ :
Something went wrong, when calling Stan. Check any debug messages for clues, detective.
#####################
the code I run is the following:
require(rstan)
require(rethinking)
y<-rnorm(1e2,mean=0,sd=1)
m8.5b<-map2stan(
alist(
y~dnorm(mu,sigma),
mu~dnorm(0,14.14),
sigma~dcauchy(0,1)
),
data=list(y=y),
start=list(mu=0,sigma=1),
chains=2,iter=4e3,
warmup=1e3
)
Can anyone help me to figure it out?
FYI - I have found this issues can be solved (at least on the systems I have access to - YMMV) WITHOUT modifying the Makevars file or installing mac-rtools by re-installing the dependencies in order (i.e. one at a time, not all at once):
As a general rule, editing the Makevars should be a last resort - it can potentially affect every compiled R package on the system. You can end up with some difficult to diagnose bugs in other packages.
Not to add to the fun, but having a different but related problem. Upgraded to Catalina, followed all @coatless steps (thanks for those!). Rcpp::sourceCpp(“helloworld.cpp”) example works fine. rstan and rstanarm both work fine (sampling etc). The test program works fine. But, once I run library(rstan)
, while I can compile and run stan models, I can no longer compile any other c++ files. e.g this fails, with a bunch of messages about " #pragma clang diagnostic pop"
library(rstan)
Rcpp::sourceCpp(code =
'
#include <RcppArmadillo.h>
// [[Rcpp::depends(RcppArmadillo)]]
// [[Rcpp::export]]
void hello_world() {
Rcpp::Rcout << "Hello World!" << std::endl;
}
/*** R
hello_world()
*/
'
)
hello_world()
But, if I restart R, and comment out #library(rstan)
everything works fine. Same problem for cpp files that don’t use RcppArmadillo, or for compiling models with Template Model Builder… Not sure if this counts as a stan problem, but since the behavior only starts after loading stan figured I’d start here. The above example does work if I load ggplot2
first, in reference to the issues noted in the results of test program; it’s only loading rstan
that seems to cause the issues. Same problem on a colleagues Mac that I didn’t set up, so doesn’t seem likely to be a result of esoteric setup on my end?
Those are only warning messages. We need the actual error message, which should be on a line that includes error:
(with the colon).