# OSError using BridgeStan from within conda env

**URL:** <https://discourse.mc-stan.org/t/oserror-using-bridgestan-from-within-conda-env/38693>\
**Category:** Interfaces\
**Tags:** bridgestan\
**Created:** [February 3, 2025, 7:34pm UTC](https://discourse.mc-stan.org/t/oserror-using-bridgestan-from-within-conda-env/38693 "2025-02-03T19:34:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![eliot](https://avatars.discourse-cdn.com/v4/letter/e/8baadc/32.png) [@eliot](https://discourse.mc-stan.org/u/eliot)\
**Post date:** [February 3, 2025, 7:34pm UTC](https://discourse.mc-stan.org/t/oserror-using-bridgestan-from-within-conda-env/38693/1 "2025-02-03T19:34:40Z")

</div>

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

```no-highlight
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+

---

<div class="post-metadata">

**Author:** ![WardBrian](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/wardbrian/32/12078_2.png) [@WardBrian](https://discourse.mc-stan.org/u/WardBrian)\
**Post date:** [February 3, 2025, 7:50pm UTC](https://discourse.mc-stan.org/t/oserror-using-bridgestan-from-within-conda-env/38693/2 "2025-02-03T19:50:01Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![WardBrian](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/wardbrian/32/12078_2.png) [@WardBrian](https://discourse.mc-stan.org/u/WardBrian)\
**Post date:** [February 3, 2025, 7:56pm UTC](https://discourse.mc-stan.org/t/oserror-using-bridgestan-from-within-conda-env/38693/3 "2025-02-03T19:56:57Z")

</div>

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

> [@eliot](#):
>
> `/Users/eliotcarlson/miniconda3/envs/stan/lib/libtbb.12.14.dylib`

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:

```no-highlight
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)

---

<div class="post-metadata">

**Author:** ![eliot](https://avatars.discourse-cdn.com/v4/letter/e/8baadc/32.png) [@eliot](https://discourse.mc-stan.org/u/eliot)\
**Post date:** [February 3, 2025, 8:05pm UTC](https://discourse.mc-stan.org/t/oserror-using-bridgestan-from-within-conda-env/38693/4 "2025-02-03T20:05:09Z")

</div>

Will try this, thanks!
