Unable to get CmdStan working in Julia on Mac OS


I am on MacOS v10.15.7 and CmdStan v2.24.1, I have come back after a break and for some reason can no longer get models to build, I have tried a

make clean-all
make build

and then tried to execute a model but always get the following output, any pointers?

fatal error: file '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/Availability.h' has been modified since the precompiled header 'stan/src/stan/model/model_header.hpp.gch' was built
note: please rebuild precompiled header 'stan/src/stan/model/model_header.hpp.gch'
1 error generated.
make: *** [/var/folders/rc/_df5n5md3vg8qs3wl_5lk0f80000gn/T/jl_AkEehF/weighted_1] Error 1



I think you need to recompile rstan and StanHeaders since Xcode has had recent updates. Make also sure to run xcode-select --install in the terminal.


I don’t know that I have rstan installed, how would I go about recompiling these two, as for xcode, I get the following when I try to run that line so presumably this is fine:

xcode-select: error: command line tools are already installed, use "Software Update" to install updates

You can just run

rm stan/src/stan/model/model_header.hpp.gch
make build

and that should do it.


I have tried this, but it doesn’t work unfortunately

Harry, is it still not working? Why don’t you delete the cmdstan subdirectory and reinstall:

git clone https://github.com/stan-dev/cmdstan.git --recursive
cd cmdstan
# Copy ./make/local from previous install (optional)
make -j9 build
make examples/bernoulli/bernoulli
./examples/bernoulli/bernoulli sample data file=examples/bernoulli/bernoulli.data.R

(or ./examples/bernoulli/bernoulli sample data file=examples/bernoulli/bernoulli.data.json)

ls -l output.csv
bin/stansummary output.csv



Harry, to be complete and test above advise, I just removed the cmdstan subdirectory (the subdir pointed to by JULIA_CMDSTAN_HOME = /Users/rob/Projects/StanSupport/cmdstan) and did above steps with Xcode 12.0.1, MacOS 10.15.7 and .../cmdstan/make/local:

CXX = clang++
STANCFLAGS = --warn-pedantic --O

Not sure xcode-select is needed anymore, but on my system gives:

 ~ xcode-select -p
➜  ~ xcode-select -v
xcode-select version 2373.
➜  ~ xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" to install updates



Yep this has done it, I can’t help but think it might be some weird artefacting from syncing my cmdstan installation between my local machine and a server, but the fresh install worked for whatever reason, I will not lose much more sanity questioning that haha.