I am trying to run a Stan model on python (using cmdstanpy) on a Mac computer. The error I get is the following: CmdStan’s precompiled header (PCH) files may need to be rebuilt.Please run cmdstanpy.rebuild_cmdstan().
When I try to rebuild it, I get the following error: No CmdStan installation found, run command "install_cmdstan"or (re)activate your conda environment!
It seems that cmdstan(py) is not installed. However, it is indeed installed and the examples (e.g., the standard Bernoulli example) work just fine.
The problem lies in the make tool. Whereas on windows it is possible to specify the custom make tool, this is not the case on Mac. As a result, when trying to run the model (before trying to rebuild cmdstan), I get this error message: error: PCH file uses an older PCH format that is no longer supported
1 error generated.
make: *** [/Users/x/Desktop/cmdstan-2.31.0/examples/model1] Error 1
Command [‘make’, ‘/Users/x/Desktop/cmdstan-2.31.0/examples/model1’]
error during processing No such file or directory
How can I solve this issue? Is there a (simple) way to set a custom make tool on a Mac?
Could you try manually rebuilding? This means opening a terminal, going into the directory your cmdstan directory, and then running make clean-all followed by make build.
If either of those commands produce errors please share them
Thank you for the reply. The commands on the terminal work fine (successfully cleaned and rebuilt cmdstan which is proved by the message “CmdStan v2.31.0 built” , but the errors when running the python file still remain the same as before
I had that PCH header errors a few times now. Rebuilding from within Python didn’t seem to work so I solved it a few times by just installing CmdStan fresh (sometimes there’d be a new release, sometimes just the same). I think it always worked, and I didn’t know about the clean-all approach, which I’m not sure worked, so you could try that.
I’m not entirely sure what cases that problem, but I would like to have a less cumbersome solution if it happens again.
I get PCH headers constantly because Apple constantly updates behind the scenes. This just broke a script a half hour in today because the first model was already compiled and it didn’t fail until trying to compile the second model.
Might there be a way to check when loading cmdstanpy that it’s up to date and won’t throw a PCH error? This is really frustrating having these pop up constantly, especially in the middle of a long-running script (I know I could pre-compile at the top of the script, but it’s not very naturally modular that way).
I’m curious what version of cmdstan you’re using, we tried to make these less common.
You can also set PRECOMPILED_HEADERS=false in make/local, if you just want to not deal with them at the cost of extra compile times. I don’t know of any elegant way cmdstanpy could do what you describe