Cmdstan on Mac

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?

  • Operating System: Mac IOS
  • CmdStan Version: 2.31.0
  • Compiler/Toolkit: Python (Pycharm)

Can you share some information about your compiler/XCode version?

I am using Xcode version 14.2

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.