I’m trying to install CmdStanR on my Mac and am running into trouble. Since I haven’t been able to solve this problem via Googling, I thought I’d try and get some help here because someone may have run into the same issue.
I started out by installing the CmdStanR packages:
> install.packages("cmdstanr", repos = c("https://mc-stan.org/r-packages/", getOption("repos")))
Warning in install.packages :
unable to access index for repository https://mc-stan.org/r-packages/bin/macosx/el-capitan/contrib/3.6:
cannot open URL 'https://mc-stan.org/r-packages/bin/macosx/el-capitan/contrib/3.6/PACKAGES'
installing the source package ‘cmdstanr’
trying URL 'https://mc-stan.org/r-packages/src/contrib/cmdstanr_0.1.3.tar.gz'
Content type 'application/gzip' length 831895 bytes (812 KB)
==================================================
downloaded 812 KB
* installing *source* package ‘cmdstanr’ ...
** using staged installation
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
*** copying figures
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (cmdstanr)
The downloaded source packages are in
‘/private/var/folders/6j/mkww2sy511q8ypd70xhdfcl40000gp/T/Rtmp3brOxI/downloaded_packages’
So far, so good I think. Next I loaded the CmdStanR libary:
> library(cmdstanr)
This is cmdstanr version 0.1.3
- Online documentation and vignettes at mc-stan.org/cmdstanr
- CmdStan path set to: /Users/andrew/.cmdstanr/cmdstan-2.24.1
- Use set_cmdstan_path() to change the path
I next ran install_cmdstan()
as done in this vignette:
> install_cmdstan(cores = 2, overwrite = TRUE)
* Latest CmdStan release is v2.24.1
* Installing CmdStan v2.24.1 in /Users/andrew/.cmdstanr/cmdstan-2.24.1
* Downloading cmdstan-2.24.1.tar.gz from GitHub...
* Removing the existing installation of CmdStan...
* Download complete
* Unpacking archive...
* Building CmdStan binaries...
cp bin/mac-stanc bin/stanc
clang++ -std=c++1y -Wno-unknown-warning-option -Wno-tautological-compare -Wno-sign-compare -D_REENTRANT -Wno-ignored-attributes -I stan/lib/stan_math/lib/tbb_2019_U8/include -O3 -I src -I stan/src -I lib/rapidjson_1.1.0/ -I stan/lib/stan_math/ -I stan/lib/stan_math/lib/eigen_3.3.7 -I stan/lib/stan_math/lib/boost_1.72.0 -I stan/lib/stan_math/lib/sundials_5.2.0/include -DBOOST_DISABLE_ASSERTS -c -fvisibility=hidden -o bin/cmdstan/stansummary.o src/cmdstan/stansummary.cpp
chmod +x bin/stanc
cd stan/lib/stan_math/lib/boost_1.72.0; ./bootstrap.sh
Building Boost.Build engine with toolset clang... In file included from src/cmdstan/stansummary.cpp:1:
In file included from src/cmdstan/stansummary_helper.hpp:4:
In file included from stan/src/stan/mcmc/chains.hpp:4:
In file included from stan/src/stan/io/stan_csv_reader.hpp:4:
In file included from stan/lib/stan_math/lib/boost_1.72.0/boost/algorithm/string.hpp:18:
In file included from stan/lib/stan_math/lib/boost_1.72.0/boost/algorithm/string/std_containers_traits.hpp:18:
In file included from stan/lib/stan_math/lib/boost_1.72.0/boost/config.hpp:57:
In file included from stan/lib/stan_math/lib/boost_1.72.0/boost/config/platform/macos.hpp:28:
stan/lib/stan_math/lib/boost_1.72.0/boost/config/detail/posix_features.hpp:18:15: fatal error: 'unistd.h' file not found
# include <unistd.h>
^~~~~~~~~~
1 error generated.
make: *** [bin/cmdstan/stansummary.o] Error 1
make: *** Waiting for unfinished jobs....
Failed to build Boost.Build build engine
Consult 'bootstrap.log' for more details
make: *** [stan/lib/stan_math/lib/boost_1.72.0/stage/lib/libboost_program_options.a] Error 1
Warning message:
There was a problem during installation. See the error message(s) above.
As you can see, this is where I started running into trouble. I’m not sure what is causing this error - I couldn’t find a similar issue when I was Googling.
I know that CmdStanR isn’t working right because I can’t run simple examples from the vignette:
> file <- file.path(cmdstan_path(), "examples", "bernoulli", "bernoulli.stan")
> mod <- cmdstan_model(file)
Compiling Stan program...
stan/lib/stan_math/lib/sundials_5.2.0/src/nvector/serial/nvector_serial.c:19:10: fatal error: 'stdio.h' file not found
#include <stdio.h>
^~~~~~~~~
1 error generated.
Error: An error occured during compilation! See the message above for more information.
I’d appreciate any help that can be provided. Here’s my session info in case it’s helpful:
> sessionInfo()
R version 3.6.1 (2019-07-05)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Mojave 10.14.6
Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] cmdstanr_0.1.3
loaded via a namespace (and not attached):
[1] processx_3.4.3 compiler_3.6.1 backports_1.1.8 R6_2.4.1 rsconnect_0.8.15 tools_3.6.1 rstudioapi_0.11 crayon_1.3.4 checkmate_2.0.0
[10] jsonlite_1.7.1 ps_1.3.4 ```