Expecting RStan Issues With MacOS Big Sur?

Hi

Very novice Stan user.
Updated to Big Sur. Using R 4.03 and RStudio 1.3.959.
Now get the following error. Any help understanding and managing it would be appreciated.

library(StanHeaders)
library(Rcpp)
library(ggplot2)
library(rstan)
library(withr)
options(mc.cores = parallel::detectCores())

example(stan_model, run.dontrun = TRUE)

stn_mdR> stancode ← ‘data {real y_mean;} parameters {real y;} model {y ~ normal(y_mean,1);}’

stn_mdR> mod ← stan_model(model_code = stancode, verbose = TRUE)

TRANSLATING MODEL ‘16a540c6086086816528e4524def24d9’ FROM Stan CODE TO C++ CODE NOW.
successful in parsing the Stan model ‘16a540c6086086816528e4524def24d9’.
sh: clang++ -mmacosx-version-min=10.13: command not found
error in running commandThe NEXT version of Stan will not be able to pre-process your Stan program.
Please open an issue at
Issues · stan-dev/stanc3 · GitHub
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 ‘/var/folders/vz/g1j5pr8n7tg786zcwmv2dx8c0000gp/T//Rtmp9cB1Vc/file2c866fd6798b.stan’, reason 'No such file or directory’COMPILING THE C++ CODE FOR MODEL ‘16a540c6086086816528e4524def24d9’ NOW.
OS: x86_64, darwin17.0; rstan: 2.21.1; Rcpp: 1.0.5; inline: 0.3.16

setting environment variables:
PKG_LIBS = /Library/Frameworks/R.framework/Versions/4.0/Resources/library/rstan/lib//libStanServices.a -L’/Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/lib/’ -lStanHeaders -L’/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppParallel/lib/’ -ltbb -ltbbmalloc -ltbbmalloc_proxy
PKG_CPPFLAGS = -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include/" -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/" -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/unsupported" -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/BH/include" -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/src/" -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/" -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppParallel/include/" -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/rstan/include" -DEIGEN_NO_DEBUG -DBOOST_DISABLE_ASSERTS -DBOOST_PENDING_INTEGER_LOG2_HPP -DSTAN_THREADS -DBOOST_NO_AUTO_PTR -include ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp’ -D_REENTRANT -DRCPP_PARALLEL_USE_TBB=1
Program source :

So I’m not knowledgable enough to understand that error message. But it might be worth reinstalling all the relevant packages if you haven’t already done so. Worth a try anyhow!

Do you have XCode?

yes, downloaded the most recent version 12.2 ,2 days ago after getting Big Sur

And did you reinstall from scratch things using build from source?

I am running macOS 11 and do not (yet?) have any issues.

This may be the source of the problem. The missing libraries are as follows

'R> install.packages(c(“ggraph”, “RcppArmadillo”, “rstan”))

There are binary versions available but the source versions are later:
binary source needs_compilation
ggraph 2.0.3 2.0.4 TRUE
RcppArmadillo 0.10.1.0.0 0.10.1.2.0 TRUE
rstan 2.21.1 2.21.2 TRUE

Do you want to install from sources the packages which need compilation? (Yes/no/cancel) ’

I answered yes but get several pages of errors and can’t find the log file.At the end of the file is
"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
ERROR: compilation failed for package ‘rstan’

  • removing ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/rstan’
  • restoring previous ‘/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/vz/g1j5pr8n7tg786zcwmv2dx8c0000gp/T/RtmpMt8rQ2/downloaded_packages’"

I would have chosen No. Also, check whether you have something in ~/.Renviron that set the PATH environmental variable that should now be deleted.

I changed my reply to no.
I have nothing in my .Renviron file
.Rprofile shows

"options(prompt="R> ", digits=4, show.signif.stars=FALSE)
## local creates a new, empty environment
## This avoids polluting the global environment with
## the object r
local({
    r = getOption("repos")             
    r["CRAN"] = "https://cran.rstudio.com/"
    options(repos = r)
})
## WORKAROUND: https://github.com/rstudio/rstudio/issues/6692 for rstan
## Revert to 'sequential' setup of PSOCK cluster in RStudio Console on macOS and R 4.0.0
if (Sys.getenv("RSTUDIO") == "1" && !nzchar(Sys.getenv("RSTUDIO_TERM")) && 
    Sys.info()["sysname"] == "Darwin") {
  parallel:::setDefaultClusterOptions(setup_strategy = "sequential")
}"

So, did it install rstan 2.21.1 correctly?

I think rayan 2.21.1 is installed properly but I still get the following error

Blockquote
R> example(stan_model, run.dontrun = TRUE)

stn_mdR> stancode ← ‘data {real y_mean;} parameters {real y;} model {y ~ normal(y_mean,1);}’

stn_mdR> mod ← stan_model(model_code = stancode, verbose = TRUE)

TRANSLATING MODEL ‘16a540c6086086816528e4524def24d9’ FROM Stan CODE TO C++ CODE NOW.
successful in parsing the Stan model ‘16a540c6086086816528e4524def24d9’.
sh: clang++ -mmacosx-version-min=10.13: command not found
error in running commandThe NEXT version of Stan will not be able to pre-process your Stan program.
Please open an issue at
Issues · stan-dev/stanc3 · GitHub
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 ‘/var/folders/vz/g1j5pr8n7tg786zcwmv2dx8c0000gp/T//RtmpbtAKen/file6ee833dd4339.stan’, reason 'No such file or directory’COMPILING THE C++ CODE FOR MODEL ‘16a540c6086086816528e4524def24d9’ NOW.
OS: x86_64, darwin17.0; rstan: 2.21.1; Rcpp: 1.0.5; inline: 0.3.16

setting environment variables:
PKG_LIBS = /Library/Frameworks/R.framework/Versions/4.0/Resources/library/rstan/lib//libStanServices.a -L’/Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/lib/’ -lStanHeaders -L’/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppParallel/lib/’ -ltbb -ltbbmalloc -ltbbmalloc_proxy
PKG_CPPFLAGS = -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include/" -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/" -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/unsupported" -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/BH/include" -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/src/" -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/" -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppParallel/include/" -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/rstan/include" -DEIGEN_NO_DEBUG -DBOOST_DISABLE_ASSERTS -DBOOST_PENDING_INTEGER_LOG2_HPP -DSTAN_THREADS -DBOOST_NO_AUTO_PTR -include ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp’ -D_REENTRANT -DRCPP_PARALLEL_USE_TBB=1

Blockquote

OK. What is the R output of

Sys.getenv("PATH")

?

R> Sys.getenv(“PATH”)
[1] “/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Library/TeX/texbin:/opt/X11/bin:/Library/Apple/usr/bin:/usr/local/git/bin:/opt/local/bin:/Applications/RStudio.app/Contents/MacOS/postback”
R>

And

Sys.which("clang++")

?

Blockquote

R> Sys.which(“clang++”)
clang++
“/usr/bin/clang++”

That looks like it should be fine. When you run

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

do you get a mod object out at the end?

I seem to get an error as well as the mod object!

R> example(“stan_model”, package = “rstan”, run.dontrun = TRUE)

stn_mdR> stancode ← ‘data {real y_mean;} parameters {real y;} model {y ~ normal(y_mean,1);}’

stn_mdR> mod ← stan_model(model_code = stancode, verbose = TRUE)

TRANSLATING MODEL ‘16a540c6086086816528e4524def24d9’ FROM Stan CODE TO C++ CODE NOW.
successful in parsing the Stan model ‘16a540c6086086816528e4524def24d9’.
sh: clang++ -mmacosx-version-min=10.13: command not found
The NEXT version of Stan will not be able to pre-process your Stan program.
Please open an issue at
Issues · stan-dev/stanc3 · GitHub
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().

stn_mdR> fit ← sampling(mod, data = list(y_mean = 0))

stn_mdR> fit2 ← sampling(mod, data = list(y_mean = 5))
Warning messages:
1: In system2(CXX, args = ARGS) : error in running command
2: In file.remove(c(unprocessed, processed)) :
cannot remove file ‘/var/folders/vz/g1j5pr8n7tg786zcwmv2dx8c0000gp/T//RtmpbtAKen/file6ee86bcb1a9d.stan’, reason ‘No such file or directory’
R> str(mod)
Formal class ‘stanmodel’ [package “rstan”] with 5 slots
…@ model_name : chr “16a540c6086086816528e4524def24d9”
…@ model_code : chr “data {real y_mean;} parameters {real y;} model {y ~ normal(y_mean,1);}”
… …- attr(*, “model_name2”)= chr “16a540c6086086816528e4524def24d9”
…@ model_cpp :List of 2
… … model_cppname: chr "model6ee84954e160_16a540c6086086816528e4524def24d9" .. .. model_cppcode: chr “// Code generated by Stan version 2.21.0\n\n#include <stan/model/model_header.hpp>\n\nnamespace model6ee84954e1”| truncated
…@ mk_cppmodule:function (object)
…@ dso :Formal class ‘cxxdso’ [package “rstan”] with 7 slots
… … …@ sig :List of 1
… … … … file6ee83686dc9: chr(0) .. .. ..@ dso_saved : logi TRUE .. .. ..@ dso_filename: chr "file6ee83686dc9" .. .. ..@ modulename : chr "stan_fit4model6ee84954e160_16a540c6086086816528e4524def24d9_mod" .. .. ..@ system : chr "x86_64, darwin17.0" .. .. ..@ cxxflags : chr "CXXFLAGS = -Wall -g -O2 (LTO)"
… … …@ .CXXDSOMISC :<environment: 0x7f9a2c0e11d0>
R>

I am here to report that I have seen no issues with Big Sur (I still have the fixes that I did when upgrading to Catalina).

2 Likes

I don’t think you have any errors, just warnings that are fixed on GitHub.

Ok good to know.
Thank you for your help.

I just posted some benchmarks here

in summary it does seem to be fast.

1 Like