Error in JIT compilation of dolfinx fem forms after updating to MacOS 15.4

Hello community,

I use FEniCSx v0.9.0 with Python 3.12.2, along with scifem and other standard libraries, on a Mac M1.

After updating MacOS to version 15.4 (previously 15.3), I was surprised to encounter the following error when running a simulation that previously worked without issues, which seems to be related to the compiling of the dolfinx.fem.forms:

Traceback (most recent call last):
  File "/Users/XX(hidden)/opt/anaconda3/envs/fenicsx0.9.0/lib/python3.11/site-packages/ffcx/codegeneration/jit.py", line 97, in get_cached_module
    with open(c_filename, "x"):
         ^^^^^^^^^^^^^^^^^^^^^
FileExistsError: [Errno 17] File exists: '/Users/XX(hidden)/.cache/fenics/libffcx_forms_8f64505a2ea5cbfd43f4ec3dc7b39e9438824bf0.c'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Volumes/XX(hidden).py", line 323, in <module>
    print(f"{dolfinx.fem.assemble_scalar(dolfinx.fem.form(1 * dss))}")
                                                                         ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/XX(hidden)/opt/anaconda3/envs/fenicsx0.9.0/lib/python3.11/site-packages/dolfinx/fem/forms.py", line 337, in form
    return _create_form(form)
           ^^^^^^^^^^^^^^^^^^
  File "/Users/XX(hidden)/opt/anaconda3/envs/fenicsx0.9.0/lib/python3.11/site-packages/dolfinx/fem/forms.py", line 331, in _create_form
    return _form(form)
           ^^^^^^^^^^^
  File "/Users/XX(hidden)/opt/anaconda3/envs/fenicsx0.9.0/lib/python3.11/site-packages/dolfinx/fem/forms.py", line 254, in _form
    ufcx_form, module, code = jit.ffcx_jit(
                              ^^^^^^^^^^^^^
  File "/Users/XX(hidden)/opt/anaconda3/envs/fenicsx0.9.0/lib/python3.11/site-packages/dolfinx/jit.py", line 62, in mpi_jit
    return local_jit(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/XX(hidden)/opt/anaconda3/envs/fenicsx0.9.0/lib/python3.11/site-packages/dolfinx/jit.py", line 212, in ffcx_jit
    r = ffcx.codegeneration.jit.compile_forms([ufl_object], options=p_ffcx, **p_jit)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/XX(hidden)/opt/anaconda3/envs/fenicsx0.9.0/lib/python3.11/site-packages/ffcx/codegeneration/jit.py", line 188, in compile_forms
    obj, mod = get_cached_module(module_name, form_names, cache_dir, timeout)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/XX(hidden)/opt/anaconda3/envs/fenicsx0.9.0/lib/python3.11/site-packages/ffcx/codegeneration/jit.py", line 114, in get_cached_module
    compiled_module = importlib.util.module_from_spec(spec)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 573, in module_from_spec
  File "<frozen importlib._bootstrap_external>", line 1233, in create_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
ImportError: dlopen(/Users/XX(hidden)/.cache/fenics/libffcx_forms_8f64505a2ea5cbfd43f4ec3dc7b39e9438824bf0.cpython-311-darwin.so, 0x0002): tried: '/Users/XX(hidden)/.cache/fenics/libffcx_forms_8f64505a2ea5cbfd43f4ec3dc7b39e9438824bf0.cpython-311-darwin.so' (duplicate LC_RPATH '/Users/XX(hidden)/opt/anaconda3/envs/fenicsx0.9.0/lib'), '/System/Volumes/Preboot/Cryptexes/OS/Users/XX(hidden)/.cache/fenics/libffcx_forms_8f64505a2ea5cbfd43f4ec3dc7b39e9438824bf0.cpython-311-darwin.so' (no such file), '/Users/XX(hidden)/.cache/fenics/libffcx_forms_8f64505a2ea5cbfd43f4ec3dc7b39e9438824bf0.cpython-311-darwin.so' (duplicate LC_RPATH '/Users/XX(hidden)/opt/anaconda3/envs/fenicsx0.9.0/lib')

I use Conda, so I tried removing the environment and creating it again with different versions of python (3.13, 3.12.3, 3.11).

Also, I tried removing the cache with: rm -rf ~/.cache/fenics.

However, these two things didn’t solve the issue.

I would appreciate any idea or comment regarding the issue. Thank you in advance!

See: Duplicate LC_RPATH errors on macOS 15.4 Sequoia - #6 by minrk and the previous posts in this thread