OSError using BridgeStan from within conda env

I’m having trouble compiling a model with BridgeStan in a conda environment. Is this caused by a mismatch between standard libraries / compilers?

model = bs.StanModel("./normal.stan",data=data)
  File "/Users/eliotcarlson/miniconda3/envs/stan/lib/python3.13/site-packages/bridgestan/model.py", line 145, in __init__
    self.stanlib = ctypes.CDLL(self.lib_path)
                   ~~~~~~~~~~~^^^^^^^^^^^^^^^
  File "/Users/eliotcarlson/miniconda3/envs/stan/lib/python3.13/ctypes/__init__.py", line 390, in __init__
    self._handle = _dlopen(self._name, mode)
                   ~~~~~~~^^^^^^^^^^^^^^^^^^
OSError: dlopen(/path/to/normal_model.so, 0x0006): Symbol not found: __ZNSt11range_errorD1Ev
  Referenced from: <35764D09-94F8-3831-B205-3ED092834814> /path/to/normal_model.so
  Expected in:     <8D1674D6-4EAC-396D-BD2E-B9870818DB5E> /Users/eliotcarlson/miniconda3/envs/stan/lib/libtbb.12.14.dylib

Operating System: MacOS sequoia 15.1.1
Interface Version: BridgeStan 2.6.1
Compiler/Toolkit: clang 17+

Hi Eliot, can you share the output of conda list, and the contents of bridgestan/make/local (if it exists)?

Actually, before even looking at conda info, I think I know what the bit I was looking for will tell me.

tells me that something else in your environment is installing tbb, and in particular, a newer version than the one Stan itself ships with. The easiest way to get this all to work is usually to define some extra information in the bridgestan/make/local file to ask bridgestan to kindly use the TBB provided by conda. Try this:

TBB_CXX_TYPE=clang
TBB_INTERFACE_NEW=true
TBB_INC=/Users/eliotcarlson/miniconda3/envs/stan/include/
TBB_LIB=/Users/eliotcarlson/miniconda3/envs/stan/lib/

(note that the above is not bridgestan-specific, but also would apply to e.g. cmdstan. If you install cmdstan from conda-forge, it pre-populates the make/local file with something like this)

Will try this, thanks!