Catalina/rstan

I’ve used the online tutorial to install RStan. I’m currently using Catalina and studio, which is posing a problem that I suspect others have encountered. I’ve installed Rcpp, Xcode, but when I install Stan this route (install.packages(“rstan”, type = “source”))

clang: error: no such file or directory: ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/rstan/lib//libStanServices.a’
make: *** [rstan.so] Error 1
make: *** Waiting for unfinished jobs…
26 warnings generated.
ERROR: compilation failed for package ‘rstan’

  • removing ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/rstan’
    Warning in install.packages :
    installation of package ‘rstan’ had non-zero exit status

The downloaded source packages are in
‘/private/var/folders/t5/z6n7fqts5sldmfy1m6f9myqr0000gs/T/RtmpWaj6Od/downloaded_packages’

require(rstan)
Loading required package: rstan
Warning message:
In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE, :
there is no package called ‘rstan’

When I install from GitHub (install.packages(“Rcpp”, repos = “Rcpp Drat”) I get similar errors:

In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/Sparse:33:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/IterativeLinearSolvers:46:
/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/src/Core/util/ReenableStupidWarnings.h:10:30: warning: pragma diagnostic pop could not pop, no matching push [-Wunknown-pragmas]
#pragma clang diagnostic pop
^
13 warnings and 14 errors generated.
make: *** [barrier.o] Error 1
make: *** Waiting for unfinished jobs…
13 warnings and 14 errors generated.
13 warnings and 14 errors generated.
make: *** [api.o] Error 1
make: *** [attributes.o] Error 1
13 warnings and 14 errors generated.
make: *** [date.o] Error 1
ERROR: compilation failed for package ‘Rcpp’

  • removing ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp’
  • restoring previous ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp’
    Warning in install.packages :
    installation of package ‘Rcpp’ had non-zero exit status

The downloaded source packages are in
‘/private/var/folders/t5/z6n7fqts5sldmfy1m6f9myqr0000gs/T/RtmpWaj6Od/downloaded_packages’

Operating System: Mac OS Catalina 10.15.5

Many thanks in advance.

Sorry you’re getting an error. A few questions/comments:

  • Do I understand correctly that not even Rcpp will install for you (with or without Stan)? If that’s the case then something not necessarily related to Stan is messed up.

  • If you just installed Xcode for the first time, maybe you need to open it and except some terms and conditions or something? (That used to be a thing, but not sure anymore.)

  • Does installing the Rcpp binary from CRAN not work? (I see you were installing from rcppcore.github.io/drat instead of CRAN)

Other than that I’m not sure. @bgoodri any ideas?

I was able to install Rcpp. I also installed xcode and accepted the terms. It now installs and I can run the 8-schools model, which is good. However, I get a warning message. Here’s an example using brms:

one.pl <- bf(y ~ 1 + (1 | Case) + (1 | Justice))

one.pl.prior <-

prior(“normal(0, 3)”, class = “sd”, group = “Justice”) +

prior(“normal(0, 3)”, class = “sd”, group = “Case”)

fit<- brm(

formula=one.pl,

data=stan.dat2,

family=brmsfamily(“bernoulli”, “logit”),

prior=one.pl.prior

)

There’s still an issue with the makevars file, I think. This is the warning:

Compiling Stan program…

sh: g++ -O2 -march=native -mtune=native: command not found

Start sampling

Warning messages:

1: In system2(CXX, args = ARGS) : error in running command

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

cannot remove file ‘/var/folders/t5/z6n7fqts5sldmfy1m6f9myqr0000gs/T//Rtmp1vBD17/file1b31285d6794.stan’, reason ‘No such file or directory’

It produces results, but I want to be sure everything is configured correctly.

Installing stan using CRAN works, though I couldn’t install from github. The stan instructions also point to the toolchain installer for Catalina. However, the instructions call for the gfortran binaries. The site doesn’t appear to have Catalina (https://github.com/fxcoudert/gfortran-for-macOS/releases), only older operating systems, so not sure what to do here and if this is part of the problem.

Thanks again.

Chris

I’m glad it’s running, but yeah that’s a weird warning.

Hmm, what are the contents of your Makevars file? You can open it by running

file.edit(file.path(Sys.getenv("HOME"), ".R", "Makevars"))