I try to use the conda defaults channel when possible. However, cmdstan
is only provided on conda-forge. This is OK, but compilation of Stan programs seems to only work if all the dependencies come from conda-forge.
I've made a MWE (for my system) that shows that only when I use all conda-forge dependencies can I compile Stan's "bernoulli" example. I'm running MacOS Monterey, more details at the bottom. Why is this and what can I do about it?
Create a conda env for cmdstan from conda-forge and compile the "bernoulli" example
conda create -n try_stan_forge -c conda-forge cmdstan
This is the package plan for installation:
The following NEW packages will be INSTALLED:
ca-certificates conda-forge/osx-64::ca-certificates-2022.9.24-h033912b_0 None
cctools_osx-64 conda-forge/osx-64::cctools_osx-64-973.0.1-h2b95895_10 None
clang conda-forge/osx-64::clang-14.0.4-h694c41f_0 None
clang-14 conda-forge/osx-64::clang-14-14.0.4-default_h55ffa42_0 None
clang_osx-64 conda-forge/osx-64::clang_osx-64-14.0.4-h3a95cd4_2 None
clangxx conda-forge/osx-64::clangxx-14.0.4-default_h55ffa42_0 None
clangxx_osx-64 conda-forge/osx-64::clangxx_osx-64-14.0.4-he1dbc44_2 None
cmdstan conda-forge/osx-64::cmdstan-2.30.1-h21365d3_0 None
compiler-rt conda-forge/osx-64::compiler-rt-14.0.4-h7fcd477_0 None
compiler-rt_osx-64 conda-forge/noarch::compiler-rt_osx-64-14.0.4-h6df654d_0 None
ld64_osx-64 conda-forge/osx-64::ld64_osx-64-609-h1e06c2b_10 None
libclang-cpp14 conda-forge/osx-64::libclang-cpp14-14.0.4-default_h55ffa42_0 None
libcxx conda-forge/osx-64::libcxx-14.0.6-hccf4f1f_0 None
libllvm14 conda-forge/osx-64::libllvm14-14.0.4-h41df66c_0 None
libzlib conda-forge/osx-64::libzlib-1.2.13-hfd90126_4 None
llvm-tools conda-forge/osx-64::llvm-tools-14.0.4-h41df66c_0 None
make conda-forge/osx-64::make-4.3-h22f3db7_1 None
openssl conda-forge/osx-64::openssl-3.0.5-hfd90126_2 None
sigtool conda-forge/osx-64::sigtool-0.1.3-h88f4db0_0 None
tapi conda-forge/osx-64::tapi-1100.0.11-h9ce4665_0 None
tbb conda-forge/osx-64::tbb-2021.6.0-hb8565cd_0 None
tbb-devel conda-forge/osx-64::tbb-devel-2021.6.0-hb8565cd_0 None
Now activate the env and compile the bernoulli example:
conda activate try_stan_forge
cd $CONDA_PREFIX/bin/cmdstan
make examples/bernoulli/bernoulli
Compilation completes with no errors.
Create another conda env for cmdstan but prefer defaults channel for other dependencies:
conda create -n try_stan_defaults -c defaults -c conda-forge cmdstan
Package plan now uses defaults channel for everything but cmdstan
itself, which is only available on conda-forge:
The following NEW packages will be INSTALLED:
cctools_osx-64 pkgs/main/osx-64::cctools_osx-64-949.0.1-hc7db93f_25 None
clang pkgs/main/osx-64::clang-12.0.0-hecd8cb5_2 None
clang-12 pkgs/main/osx-64::clang-12-12.0.0-default_hfcad0e5_2 None
clang_osx-64 pkgs/main/osx-64::clang_osx-64-12.0.0-h7ad7729_2 None
clangxx pkgs/main/osx-64::clangxx-12.0.0-default_hfcad0e5_2 None
clangxx_osx-64 pkgs/main/osx-64::clangxx_osx-64-12.0.0-he0c6f94_2 None
cmdstan conda-forge/osx-64::cmdstan-2.29.2-h775853c_0 None
compiler-rt pkgs/main/osx-64::compiler-rt-12.0.0-hd87ff74_2 None
compiler-rt_osx-64 pkgs/main/noarch::compiler-rt_osx-64-12.0.0-hfb26b64_2 None
ld64_osx-64 pkgs/main/osx-64::ld64_osx-64-530-h70f3046_23 None
ldid pkgs/main/osx-64::ldid-2.1.2-h2d21305_2 None
libclang-cpp12 pkgs/main/osx-64::libclang-cpp12-12.0.0-default_hfcad0e5_2 None
libcxx pkgs/main/osx-64::libcxx-14.0.6-h9765a3e_0 None
libffi pkgs/main/osx-64::libffi-3.3-hb1e8313_2 None
libllvm12 pkgs/main/osx-64::libllvm12-12.0.0-h9b2ccf5_3 None
libllvm14 pkgs/main/osx-64::libllvm14-14.0.6-he552d86_0 None
llvm-tools pkgs/main/osx-64::llvm-tools-12.0.0-h9b2ccf5_3 None
make pkgs/main/osx-64::make-4.2.1-h3efe00b_1 None
tapi pkgs/main/osx-64::tapi-1000.10.8-ha1b3eb9_0 None
tbb pkgs/main/osx-64::tbb-2021.6.0-haf03e11_0 None
tbb-devel pkgs/main/osx-64::tbb-devel-2021.6.0-haf03e11_0 None
zlib pkgs/main/osx-64::zlib-1.2.12-h4dc903c_3 None
Again, activate the env and compile the example:
conda activate try_stan_defaults
cd $CONDA_PREFIX/bin/cmdstan
make examples/bernoulli/bernoulli
Now we get compilation error:
❯ make examples/bernoulli/bernoulli
x86_64-apple-darwin13.4.0-clang++ -march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -stdlib=libc++ -fvisibility-inlines-hidden -std=c++14 -fmessage-length=0 -isystem /opt/miniconda3/envs/try_stan_defaults/include -std=c++1y -Wno-unknown-warning-option -Wno-tautological-compare -Wno-sign-compare -D_REENTRANT -Wno-ignored-attributes -I /opt/miniconda3/envs/try_stan_defaults/include/ -O3 -I src -I stan/src -I lib/rapidjson_1.1.0/ -I lib/CLI11-1.9.1/ -I stan/lib/stan_math/ -I stan/lib/stan_math/lib/eigen_3.3.9 -I stan/lib/stan_math/lib/boost_1.75.0 -I stan/lib/stan_math/lib/sundials_6.0.0/include -I stan/lib/stan_math/lib/sundials_6.0.0/src/sundials -D_FORTIFY_SOURCE=2 -isystem /opt/miniconda3/envs/try_stan_defaults/include -DBOOST_DISABLE_ASSERTS -DTBB_INTERFACE_NEW -DTBB_INTERFACE_NEW -c -MT stan/src/stan/model/model_header.hpp.gch -MT stan/src/stan/model/model_header.d -MM -E -MG -MP -MF stan/src/stan/model/model_header.d stan/src/stan/model/model_header.hpp
x86_64-apple-darwin13.4.0-clang++ -march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -stdlib=libc++ -fvisibility-inlines-hidden -std=c++14 -fmessage-length=0 -isystem /opt/miniconda3/envs/try_stan_defaults/include -std=c++1y -Wno-unknown-warning-option -Wno-tautological-compare -Wno-sign-compare -D_REENTRANT -Wno-ignored-attributes -I /opt/miniconda3/envs/try_stan_defaults/include/ -O3 -I src -I stan/src -I lib/rapidjson_1.1.0/ -I lib/CLI11-1.9.1/ -I stan/lib/stan_math/ -I stan/lib/stan_math/lib/eigen_3.3.9 -I stan/lib/stan_math/lib/boost_1.75.0 -I stan/lib/stan_math/lib/sundials_6.0.0/include -I stan/lib/stan_math/lib/sundials_6.0.0/src/sundials -D_FORTIFY_SOURCE=2 -isystem /opt/miniconda3/envs/try_stan_defaults/include -DBOOST_DISABLE_ASSERTS -DTBB_INTERFACE_NEW -DTBB_INTERFACE_NEW -c -MT src/cmdstan/main.o -MM -E -MG -MP -MF src/cmdstan/main.d src/cmdstan/main.cpp
--- Compiling pre-compiled header. This might take a few seconds. ---
x86_64-apple-darwin13.4.0-clang++ -march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -stdlib=libc++ -fvisibility-inlines-hidden -std=c++14 -fmessage-length=0 -isystem /opt/miniconda3/envs/try_stan_defaults/include -std=c++1y -Wno-unknown-warning-option -Wno-tautological-compare -Wno-sign-compare -D_REENTRANT -Wno-ignored-attributes -I /opt/miniconda3/envs/try_stan_defaults/include/ -O3 -I src -I stan/src -I lib/rapidjson_1.1.0/ -I lib/CLI11-1.9.1/ -I stan/lib/stan_math/ -I stan/lib/stan_math/lib/eigen_3.3.9 -I stan/lib/stan_math/lib/boost_1.75.0 -I stan/lib/stan_math/lib/sundials_6.0.0/include -I stan/lib/stan_math/lib/sundials_6.0.0/src/sundials -D_FORTIFY_SOURCE=2 -isystem /opt/miniconda3/envs/try_stan_defaults/include -DBOOST_DISABLE_ASSERTS -DTBB_INTERFACE_NEW -DTBB_INTERFACE_NEW -c stan/src/stan/model/model_header.hpp -o stan/src/stan/model/model_header.hpp.gch
--- Translating Stan model to C++ code ---
bin/stanc --o=examples/bernoulli/bernoulli.hpp examples/bernoulli/bernoulli.stan
--- Compiling, linking C++ code ---
x86_64-apple-darwin13.4.0-clang++ -march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -stdlib=libc++ -fvisibility-inlines-hidden -std=c++14 -fmessage-length=0 -isystem /opt/miniconda3/envs/try_stan_defaults/include -std=c++1y -Wno-unknown-warning-option -Wno-tautological-compare -Wno-sign-compare -D_REENTRANT -Wno-ignored-attributes -I /opt/miniconda3/envs/try_stan_defaults/include/ -O3 -I src -I stan/src -I lib/rapidjson_1.1.0/ -I lib/CLI11-1.9.1/ -I stan/lib/stan_math/ -I stan/lib/stan_math/lib/eigen_3.3.9 -I stan/lib/stan_math/lib/boost_1.75.0 -I stan/lib/stan_math/lib/sundials_6.0.0/include -I stan/lib/stan_math/lib/sundials_6.0.0/src/sundials -D_FORTIFY_SOURCE=2 -isystem /opt/miniconda3/envs/try_stan_defaults/include -DBOOST_DISABLE_ASSERTS -DTBB_INTERFACE_NEW -DTBB_INTERFACE_NEW -c -include-pch stan/src/stan/model/model_header.hpp.gch -x c++ -o examples/bernoulli/bernoulli.o examples/bernoulli/bernoulli.hpp
x86_64-apple-darwin13.4.0-clang++ -march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -stdlib=libc++ -fvisibility-inlines-hidden -std=c++14 -fmessage-length=0 -isystem /opt/miniconda3/envs/try_stan_defaults/include -std=c++1y -Wno-unknown-warning-option -Wno-tautological-compare -Wno-sign-compare -D_REENTRANT -Wno-ignored-attributes -I /opt/miniconda3/envs/try_stan_defaults/include/ -O3 -I src -I stan/src -I lib/rapidjson_1.1.0/ -I lib/CLI11-1.9.1/ -I stan/lib/stan_math/ -I stan/lib/stan_math/lib/eigen_3.3.9 -I stan/lib/stan_math/lib/boost_1.75.0 -I stan/lib/stan_math/lib/sundials_6.0.0/include -I stan/lib/stan_math/lib/sundials_6.0.0/src/sundials -D_FORTIFY_SOURCE=2 -isystem /opt/miniconda3/envs/try_stan_defaults/include -DBOOST_DISABLE_ASSERTS -DTBB_INTERFACE_NEW -DTBB_INTERFACE_NEW -Wl,-pie -Wl,-headerpad_max_install_names -Wl,-dead_strip_dylibs -Wl,-rpath,/opt/miniconda3/envs/try_stan_defaults/lib -L/opt/miniconda3/envs/try_stan_defaults/lib -Wl,-L,"/opt/miniconda3/envs/try_stan_defaults/lib/" -Wl,-rpath,"/opt/miniconda3/envs/try_stan_defaults/lib/" -ltbb examples/bernoulli/bernoulli.o src/cmdstan/main.o -Wl,-L,"/opt/miniconda3/envs/try_stan_defaults/lib/" -Wl,-rpath,"/opt/miniconda3/envs/try_stan_defaults/lib/" -ltbb stan/lib/stan_math/lib/sundials_6.0.0/lib/libsundials_nvecserial.a stan/lib/stan_math/lib/sundials_6.0.0/lib/libsundials_cvodes.a stan/lib/stan_math/lib/sundials_6.0.0/lib/libsundials_idas.a stan/lib/stan_math/lib/sundials_6.0.0/lib/libsundials_kinsol.a -o examples/bernoulli/bernoulli
ld: unsupported tapi file type '!tapi-tbd' in YAML file '/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib/libSystem.tbd' for architecture x86_64
clang-12: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [make/program:59: examples/bernoulli/bernoulli] Error 1
Notes on my system:
MacOS 12.6 (Monterey) with Command Line Tools but not Xcode. Here is the CL Tools version:
❯ xcode-select --version
xcode-select version 2395.
❯ pkgutil --pkg-info=com.apple.pkg.CLTools_Executables
package-id: com.apple.pkg.CLTools_Executables
version: 14.0.0.0.1.1661618636
volume: /
location: /
install-time: 1665440751
groups: com.apple.FindSystemFiles.pkg-group