Cmdstanpy doesn't build model: error during processing

I am struggling to build a basic model which worked for me in the past. I am on a 2019 MacBook Pro, running on MacOS Monterey (12.4). The Processor is a 2.4 GHz Quad-Core Intel Core i5. I have been following this GitHub thread, but unlike in the thread, rebuilding the model did not solve the issue for me. I am doing all this after installing cmdstanpy 1.0.8 in a conda environment.

The code I am running

from cmdstanpy.model import CmdStanModel
sm = CmdStanModel(stan_file = file_path)

I tried rebuilding cmdstan (using rebuild_cmdstan) as is recommended in the error message below. The rebuild was successful, yet I continue get an error message that the model file wasn’t found, although it clearly sees it. The error message reads:

Exception has occurred: ValueError
Failed to compile Stan model '/Users/galraz1/Developer/looking_time_models/PPL_attempts/stan/multi_feature.stan'. Console:

--- Translating Stan model to C++ code ---
bin/stanc  --o=/Users/galraz1/Developer/looking_time_models/PPL_attempts/stan/multi_feature.hpp /Users/galraz1/Developer/looking_time_models/PPL_attempts/stan/multi_feature.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 -fmessage-length=0 -isystem /Users/galraz1/opt/miniconda3/include -std=c++1y -Wno-unknown-warning-option -Wno-tautological-compare -Wno-sign-compare -D_REENTRANT -Wno-ignored-attributes      -I /Users/galraz1/opt/miniconda3/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.78.0 -I stan/lib/stan_math/lib/sundials_6.1.1/include -I stan/lib/stan_math/lib/sundials_6.1.1/src/sundials -D_FORTIFY_SOURCE=2 -isystem /Users/galraz1/opt/miniconda3/include    -DBOOST_DISABLE_ASSERTS   -DTBB_INTERFACE_NEW  -DTBB_INTERFACE_NEW     -c  -x c++ -o /Users/galraz1/Developer/looking_time_models/PPL_attempts/stan/multi_feature.o /Users/galraz1/Developer/looking_time_models/PPL_attempts/stan/multi_feature.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 -fmessage-length=0 -isystem /Users/galraz1/opt/miniconda3/include -std=c++1y -Wno-unknown-warning-option -Wno-tautological-compare -Wno-sign-compare -D_REENTRANT -Wno-ignored-attributes      -I /Users/galraz1/opt/miniconda3/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.78.0 -I stan/lib/stan_math/lib/sundials_6.1.1/include -I stan/lib/stan_math/lib/sundials_6.1.1/src/sundials -D_FORTIFY_SOURCE=2 -isystem /Users/galraz1/opt/miniconda3/include    -DBOOST_DISABLE_ASSERTS   -DTBB_INTERFACE_NEW  -DTBB_INTERFACE_NEW    -Wl,-pie -Wl,-headerpad_max_install_names -Wl,-dead_strip_dylibs -Wl,-rpath,/Users/galraz1/opt/miniconda3/lib -L/Users/galraz1/opt/miniconda3/lib        -Wl,-L,"/Users/galraz1/opt/miniconda3/lib/" -Wl,-rpath,"/Users/galraz1/opt/miniconda3/lib/" -ltbb    /Users/galraz1/Developer/looking_time_models/PPL_attempts/stan/multi_feature.o src/cmdstan/main.o        -Wl,-L,"/Users/galraz1/opt/miniconda3/lib/" -Wl,-rpath,"/Users/galraz1/opt/miniconda3/lib/" -ltbb stan/lib/stan_math/lib/sundials_6.1.1/lib/libsundials_nvecserial.a stan/lib/stan_math/lib/sundials_6.1.1/lib/libsundials_cvodes.a stan/lib/stan_math/lib/sundials_6.1.1/lib/libsundials_idas.a stan/lib/stan_math/lib/sundials_6.1.1/lib/libsundials_kinsol.a   -o /Users/galraz1/Developer/looking_time_models/PPL_attempts/stan/multi_feature
ld: unsupported tapi file type '!tapi-tbd' in YAML file '/Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk/usr/lib/libSystem.tbd' for architecture x86_64
clang-14: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [/Users/galraz1/Developer/looking_time_models/PPL_attempts/stan/multi_feature] Error 1

Command ['make', '/Users/galraz1/Developer/looking_time_models/PPL_attempts/stan/multi_feature']
	error during processing No such file or directory
  File "/Users/galraz1/Developer/looking_time_models/PPL_attempts/stan/action_loop.py", line 145, in <module>
    sm = CmdStanModel(stan_file = 'multi_feature.stan')

This seems like a generic Xcode error. There are a few proposed solutions on stackoverflow, the simplest of which seems to be re-installing the Xcode command line tools

1 Like
--- 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 -fmessage-length=0 -isystem /Users/galraz1/opt/miniconda3/include -std=c++1y -Wno-unknown-warning-option -Wno-tautological-compare -Wno-sign-compare -D_REENTRANT -Wno-ignored-attributes      -I /Users/galraz1/opt/miniconda3/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.78.0 -I stan/lib/stan_math/lib/sundials_6.1.1/include -I stan/lib/stan_math/lib/sundials_6.1.1/src/sundials -D_FORTIFY_SOURCE=2 -isystem /Users/galraz1/opt/miniconda3/include    -DBOOST_DISABLE_ASSERTS   -DTBB_INTERFACE_NEW  -DTBB_INTERFACE_NEW     -c  -x c++ -o /Users/galraz1/Developer/looking_time_models/PPL_attempts/stan/multi_feature.o /Users/galraz1/Developer/looking_time_models/PPL_attempts/stan/multi_feature.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 -fmessage-length=0 -isystem /Users/galraz1/opt/miniconda3/include -std=c++1y -Wno-unknown-warning-option -Wno-tautological-compare -Wno-sign-compare -D_REENTRANT -Wno-ignored-attributes      -I /Users/galraz1/opt/miniconda3/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.78.0 -I stan/lib/stan_math/lib/sundials_6.1.1/include -I stan/lib/stan_math/lib/sundials_6.1.1/src/sundials -D_FORTIFY_SOURCE=2 -isystem /Users/galraz1/opt/miniconda3/include    -DBOOST_DISABLE_ASSERTS   -DTBB_INTERFACE_NEW  -DTBB_INTERFACE_NEW    -Wl,-pie -Wl,-headerpad_max_install_names -Wl,-dead_strip_dylibs -Wl,-rpath,/Users/galraz1/opt/miniconda3/lib -L/Users/galraz1/opt/miniconda3/lib        -Wl,-L,"/Users/galraz1/opt/miniconda3/lib/" -Wl,-rpath,"/Users/galraz1/opt/miniconda3/lib/" -ltbb    /Users/galraz1/Developer/looking_time_models/PPL_attempts/stan/multi_feature.o src/cmdstan/main.o        -Wl,-L,"/Users/galraz1/opt/miniconda3/lib/" -Wl,-rpath,"/Users/galraz1/opt/miniconda3/lib/" -ltbb stan/lib/stan_math/lib/sundials_6.1.1/lib/libsundials_nvecserial.a stan/lib/stan_math/lib/sundials_6.1.1/lib/libsundials_cvodes.a stan/lib/stan_math/lib/sundials_6.1.1/lib/libsundials_idas.a stan/lib/stan_math/lib/sundials_6.1.1/lib/libsundials_kinsol.a   -o /Users/galraz1/Developer/looking_time_models/PPL_attempts/stan/multi_feature
ld: unsupported tapi file type '!tapi-tbd' in YAML file '/Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk/usr/lib/libSystem.tbd' for architecture x86_64
clang-14: error: linker command failed with exit code 1

this looks like a problem with xcode - have you tried running

xcode-select --install
1 Like