Dealing with Catalina

Memory is faded on this, so what I say would be off, but I seem to recall we just removed the .Renviron and .R/Makevars files so that cmdstanr compiled using the basic apple clang. Before we did this, my .Renviron still had the clang7 path in it.

I’m a little confused in reviewing the above thread what pertains to rstan issues within the Catalina environment, and what pertains to cmdstanr … perhaps we should separate these issues?

Please separate out the issues. Provide a minimal reproducible example on the cmdstanr.

I’m wondering if an flag is needed to quiet the deprecation warnings associated with BH and RcppEigen.

The fix for Catalina involved setting SHLIB_CXXFLAGS in ~/.R/Makevars, which should be irrelevant to CmdStan because it does not create a shared library.

Thanks all. @coatless and @ssp3nc3r, I can’t seem to figure out how get discourse to let me split these two issues. I can just open a brand new one, but am afraid to lose the bits of this thread.

An update on the RStan issue for @bgoodri, I was able to get RStan to install and run the 8 schools model without issue. However, when attempting to run my model I get the same c++ exception (unknown reason) as before. Apparently I have not actually solved any of my problems

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?

Hi, do you have any other error messages? Please reformat your post so the code is shown as code and not regular text using ``` and ``` around your code.

The model looks a bit strange with no linear model to estimate?


Hi, that is the code I run and the related error message

Hard for me to see what you’re trying to do. You’re not estimating \mu as far as I can tell? I would’ve expected a linear regression in the line that starts with mu?

I use the R R 3.6.2 GUI 1.70 El Capitan build (7735)
Rstudio Version 1.2.5033
the systerm is Catalina
when I run the code, the notification told me to install the Xcode, so I installed it, the version is Version 11.3.1 (11C504)
I also inferred to the website to install the C++ toolchain


But there are still errors

it kind of establishing MCMC with parameters mu and sigma, each defined by the specific distribution

You did run xcode-select --install in the terminal?

1 Like

not really, let me try

Thank you very much @torkar, it does work!!!

Mitzi’s instructions worked for me:

I am running Catalina and using R version 3.6.2. I installed rstan from source, as suggested in the thread. Things seem to mostly be working but I occasionally see the following when compiling models. Does anyone know what might be the issue or if I can safely ignore these three errors? Apologies if this has already come up and I missed the solution.

## Running /Library/Frameworks/R.framework/Resources/bin/R CMD SHLIB foo.c
## clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I"/Library/Frameworks/R.framework/Versions/3.6/Resources/library/Rcpp/include/"  -I"/Library/Frameworks/R.framework/Versions/3.6/Resources/library/RcppEigen/include/"  -I"/Library/Frameworks/R.framework/Versions/3.6/Resources/library/RcppEigen/include/unsupported"  -I"/Library/Frameworks/R.framework/Versions/3.6/Resources/library/BH/include" -I"/Library/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders/include/src/"  -I"/Library/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders/include/"  -I"/Library/Frameworks/R.framework/Versions/3.6/Resources/library/RcppParallel/include/"  -I"/Library/Frameworks/R.framework/Versions/3.6/Resources/library/rstan/include" -DEIGEN_NO_DEBUG  -DBOOST_DISABLE_ASSERTS  -DBOOST_PENDING_INTEGER_LOG2_HPP  -DSTAN_THREADS  -include stan/math/prim/mat/fun/Eigen.hpp  -D_REENTRANT  -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include  -fPIC  -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -c foo.c -o foo.o
## In file included from <built-in>:1:
## In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:13:
## In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/RcppEigen/include/Eigen/Dense:1:
## In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/RcppEigen/include/Eigen/Core:88:
## /Library/Frameworks/R.framework/Versions/3.6/Resources/library/RcppEigen/include/Eigen/src/Core/util/Macros.h:613:1: error: unknown type name 'namespace'
## namespace Eigen {
## ^
## /Library/Frameworks/R.framework/Versions/3.6/Resources/library/RcppEigen/include/Eigen/src/Core/util/Macros.h:613:16: error: expected ';' after top level declarator
## namespace Eigen {
##                ^
##                ;
## In file included from <built-in>:1:
## In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:13:
## In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/RcppEigen/include/Eigen/Dense:1:
## /Library/Frameworks/R.framework/Versions/3.6/Resources/library/RcppEigen/include/Eigen/Core:96:10: fatal error: 'complex' file not found
## #include <complex>
##          ^~~~~~~~~
## 3 errors generated.
## make: *** [foo.o] Error 1

Probably doing

xcode-select --install

in the Terminal app or Terminal window of RStudio will do the trick in this case. However, see also

I had xcode installed but noticed their was a minor update to Catalina. I installed that, restarted then followed the steps posted here, which is basically the same steps as rstan developers suggest with the addition of removing and installing Rcpp and RcppEigen from source https://github.com/facebook/prophet/issues/1222#issuecomment-566209099

This seems to have addressed the issue for now.

1 Like

Thanks for reporting back. I just ran into this issue myself.

I am actually still encountering the issue. It only seems to occur within R markdown files. I am hoping it is safe to ignore.

1 Like

Unfortunately I cannot get Rcpp to install. I am on MacOS 10.15.4, and I did a fresh reinstall of R 3.6.3. Following the manual instructions on https://thecoatlessprofessor.com/programming/cpp/r-compiler-tools-for-rcpp-on-macos/, the command

install.packages(c('Rcpp', 'RcppArmadillo'))

in section ‘Quick check’ gives an error that starts with:

* installing *source* package ‘Rcpp’ ...
** using staged installation
** libs
clang++ -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I../inst/include/  -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include  -fPIC  -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -c api.cpp -o api.o
In file included from api.cpp:24:
In file included from ../inst/include/Rcpp.h:27:
In file included from ../inst/include/RcppCommon.h:29:
In file included from ../inst/include/Rcpp/r/headers.h:67:
In file included from ../inst/include/Rcpp/platform/compiler.h:100:
/usr/local/clang7/include/c++/v1/cmath:313:9: error: no member named 'signbit' in the global namespace
using ::signbit;
      ~~^

Using

install.packages("Rcpp", repos="https://rcppcore.github.io/drat")

gives the same error.

gcc --version gives

Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 11.0.3 (clang-1103.0.32.59)
Target: x86_64-apple-darwin19.4.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

Any tips?