Installation on MacOS with conda

I have installed conda today using the Anaconda3 distribution from Download Anaconda Distribution | Anaconda . Here is the conda info:

     active environment : base
    active env location : /opt/anaconda3
            shell level : 1
       user config file : /Users/[redacted]/.condarc
 populated config files : /opt/anaconda3/.condarc
                          /opt/anaconda3/condarc.d/anaconda-auth.yml
                          /Users/[redacted]/.condarc
          conda version : 26.7.2
    conda-build version : 26.5.0
         python version : 3.14.6.final.0
                 solver : libmamba (default)
       virtual packages : __archspec=1=m3
                          __conda=26.7.2=0
                          __osx=26.6.2=0
                          __unix=0=0
       base environment : /opt/anaconda3  (writable)
      conda av data dir : /opt/anaconda3/etc/conda
  conda av metadata url : None
           channel URLs : https://conda.anaconda.org/conda-forge/osx-arm64
                          https://conda.anaconda.org/conda-forge/noarch
                          https://repo.anaconda.com/pkgs/main/osx-arm64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/r/osx-arm64
                          https://repo.anaconda.com/pkgs/r/noarch
          package cache : /opt/anaconda3/pkgs
                          /Users/[redacted]/.conda/pkgs
          notices cache : /Users/[redacted]/Library/Caches/conda/notices
       envs directories : /opt/anaconda3/envs
                          /Users/[redacted]/.conda/envs
    temporary directory : /var/folders/6f/7rqfnkm544vctrrxvscx5ndh0000gp/T
               platform : osx-arm64
             user-agent : conda/26.7.2 requests/2.34.2 CPython/3.14.6 Darwin/25.6.0 OSX/26.6.2 solver/libmamba conda-libmamba-solver/26.7.0 libmambapy/2.3.2 aau/0.8.1 c/. s/. e/.
                UID:GID : 502:20
             netrc file : None
           offline mode : False

I have Xcode and the Command Line Tools installed:

xcodebuild -version
> Xcode 27.0
> Build version 27A266a
clang -v
> Apple clang version 21.0.0 (clang-2100.3.34.2)
> Target: arm64-apple-darwin25.6.0
> Thread model: posix
> InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

I then installed dolfinx as described on the fenicsproject page:

conda create -n test
conda activate test
conda install -c conda-forge fenics-dolfinx mpich pyvista

This installed fenics-dolfinx version 0.11 and related packages:

pip3 list
[...]
fenics-basix       0.11.0
fenics-dolfinx     0.11.0
fenics-ffcx        0.11.0
fenics-ufl         2026.1.0
[...]

I then tried running the demo_poisson.py script from https://docs.fenicsproject.org/dolfinx/v0.11.0.post0/python/_downloads/b94ac7be61dc3726ca331afd20f195d2/demo_poisson.py, however I got the following error:

ld: warning: duplicate -rpath '/opt/anaconda3/envs/test/lib' ignored                                                                    
ld: warning: ignoring file /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/libm.tbd, malformed file                                                                                                                       
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/libm.tbd:4:20: error: unknown architecture                                                                                                                                
                   arm64e.x1-macos, arm64e.x1-maccatalyst ]                                                                             
                   ^~~~~~~~~~~~~~~                                                                                                      
                                                                                                                                        
ld: warning: ignoring file /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/libSystem.tbd, malformed file                                                                                                                  
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/libSystem.tbd:4:20: error: unknown architecture                                                                                                                           
                   arm64e.x1-macos, arm64e.x1-maccatalyst ]                                                                             
                   ^~~~~~~~~~~~~~~

ld: dynamic executables or dylibs must link with libSystem.dylib for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Traceback (most recent call last):
  File "/opt/anaconda3/envs/test/lib/python3.14/site-packages/setuptools/_distutils/compilers/C/unix.py", line 413, in link
    self.call(linker + ld_args)
    ~~~~~~~~~^^^^^^^^^^^^^^^^^^
  File "/opt/anaconda3/envs/test/lib/python3.14/site-packages/setuptools/_distutils/compilers/C/base.py", line 1177, in call
    subprocess.check_call(cmd, env=macos.inject_ver(env), **kwargs)
    ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/anaconda3/envs/test/lib/python3.14/subprocess.py", line 420, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['clang', '-bundle', '-undefined', 'dynamic_lookup', '-Wl,-rpath,/opt/anaconda3/envs/test/lib', '-L/opt/anaconda3/envs/test/lib', '-Wl,-rpath,/opt/anaconda3/envs/test/lib', '-L/opt/anaconda3/envs/test/lib', './libffcx_forms_812eb41c7947a5841f4fccab85cd4e6b90e48ecf.o', '-lm', '-o', './libffcx_forms_812eb41c7947a5841f4fccab85cd4e6b90e48ecf.cpython-314-darwin.so']' returned non-zero exit status 1.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/anaconda3/envs/test/lib/python3.14/site-packages/cffi/ffiplatform.py", line 48, in _build
    dist.run_command('build_ext')
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/opt/anaconda3/envs/test/lib/python3.14/site-packages/setuptools/dist.py", line 1106, in run_command
    super().run_command(command)
    ~~~~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/opt/anaconda3/envs/test/lib/python3.14/site-packages/setuptools/_distutils/dist.py", line 1047, in run_command
    cmd_obj.run()
    ~~~~~~~~~~~^^
  File "/opt/anaconda3/envs/test/lib/python3.14/site-packages/setuptools/command/build_ext.py", line 95, in run
    _build_ext.run(self)
    ~~~~~~~~~~~~~~^^^^^^
  File "/opt/anaconda3/envs/test/lib/python3.14/site-packages/setuptools/_distutils/command/build_ext.py", line 382, in run
    self.build_extensions()
    ~~~~~~~~~~~~~~~~~~~~~^^
  File "/opt/anaconda3/envs/test/lib/python3.14/site-packages/setuptools/_distutils/command/build_ext.py", line 498, in build_extensions
    self._build_extensions_serial()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/opt/anaconda3/envs/test/lib/python3.14/site-packages/setuptools/_distutils/command/build_ext.py", line 524, in _build_extensions_serial
    self.build_extension(ext)
    ~~~~~~~~~~~~~~~~~~~~^^^^^
  File "/opt/anaconda3/envs/test/lib/python3.14/site-packages/setuptools/command/build_ext.py", line 260, in build_extension
    _build_ext.build_extension(self, ext)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^
  File "/opt/anaconda3/envs/test/lib/python3.14/site-packages/setuptools/_distutils/command/build_ext.py", line 609, in build_extension
    self.compiler.link_shared_object(
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
        objects,
        ^^^^^^^^
    ...<8 lines>...
        target_lang=language,
        ^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/opt/anaconda3/envs/test/lib/python3.14/site-packages/setuptools/_distutils/compilers/C/base.py", line 822, in link_shared_object
    self.link(
    ~~~~~~~~~^
        Compiler.SHARED_OBJECT,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ...<11 lines>...
        target_lang,
        ^^^^^^^^^^^^
    )
    ^
  File "/opt/anaconda3/envs/test/lib/python3.14/site-packages/setuptools/_distutils/compilers/C/unix.py", line 415, in link
    raise LinkError(msg)
distutils.compilers.C.errors.LinkError: Command '['clang', '-bundle', '-undefined', 'dynamic_lookup', '-Wl,-rpath,/opt/anaconda3/envs/test/lib', '-L/opt/anaconda3/envs/test/lib', '-Wl,-rpath,/opt/anaconda3/envs/test/lib', '-L/opt/anaconda3/envs/test/lib', './libffcx_forms_812eb41c7947a5841f4fccab85cd4e6b90e48ecf.o', '-lm', '-o', './libffcx_forms_812eb41c7947a5841f4fccab85cd4e6b90e48ecf.cpython-314-darwin.so']' returned non-zero exit status 1.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/[redacted]/git/shapeopt-3d-navierstokes/numerics/demo_poisson.py", line 159, in <module>
    problem = LinearProblem(
        a,
    ...<3 lines>...
        petsc_options={"ksp_type": "preonly", "pc_type": "lu", "ksp_error_if_not_converged": True},
    )
  File "/opt/anaconda3/envs/test/lib/python3.14/site-packages/dolfinx/fem/petsc.py", line 790, in __init__
    self._a = _create_form(
              ~~~~~~~~~~~~^
        a,
        ^^
    ...<3 lines>...
        entity_maps=entity_maps,
        ^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/opt/anaconda3/envs/test/lib/python3.14/site-packages/dolfinx/fem/forms.py", line 476, in form
    return _create_form(form)
  File "/opt/anaconda3/envs/test/lib/python3.14/site-packages/dolfinx/fem/forms.py", line 468, in _create_form
    return _form(form)
  File "/opt/anaconda3/envs/test/lib/python3.14/site-packages/dolfinx/fem/forms.py", line 384, in _form
    ufcx_form, module, code = jit.ffcx_jit(
                              ~~~~~~~~~~~~^
        comm, form, form_compiler_options=form_compiler_options, jit_options=jit_options
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/opt/anaconda3/envs/test/lib/python3.14/site-packages/dolfinx/jit.py", line 61, in mpi_jit
    return local_jit(*args, **kwargs)
  File "/opt/anaconda3/envs/test/lib/python3.14/site-packages/dolfinx/jit.py", line 221, in ffcx_jit
    r = ffcx.codegeneration.jit.compile_forms([ufl_object], options=p_ffcx, **p_jit)
  File "/opt/anaconda3/envs/test/lib/python3.14/site-packages/ffcx/codegeneration/jit.py", line 244, in compile_forms
    raise e
  File "/opt/anaconda3/envs/test/lib/python3.14/site-packages/ffcx/codegeneration/jit.py", line 224, in compile_forms
    impl = _compile_objects(
        decl,
    ...<9 lines>...
        visualise=visualise,
    )
  File "/opt/anaconda3/envs/test/lib/python3.14/site-packages/ffcx/codegeneration/jit.py", line 400, in _compile_objects
    ffibuilder.compile(tmpdir=cache_dir, verbose=True, debug=cffi_debug)
    ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/anaconda3/envs/test/lib/python3.14/site-packages/cffi/api.py", line 720, in compile
    return recompile(self, module_name, source, tmpdir=tmpdir,
                     target=target, source_extension=source_extension,
                     compiler_verbose=verbose, debug=debug, **kwds)
  File "/opt/anaconda3/envs/test/lib/python3.14/site-packages/cffi/recompiler.py", line 1569, in recompile
    outputfilename = ffiplatform.compile('.', ext,
                                         compiler_verbose, debug)
  File "/opt/anaconda3/envs/test/lib/python3.14/site-packages/cffi/ffiplatform.py", line 20, in compile
    outputfilename = _build(tmpdir, ext, compiler_verbose, debug)
  File "/opt/anaconda3/envs/test/lib/python3.14/site-packages/cffi/ffiplatform.py", line 54, in _build
    raise VerificationError('%s: %s' % (e.__class__.__name__, e))
cffi.VerificationError: LinkError: Command '['clang', '-bundle', '-undefined', 'dynamic_lookup', '-Wl,-rpath,/opt/anaconda3/envs/test/lib', '-L/opt/anaconda3/envs/test/lib', '-Wl,-rpath,/opt/anaconda3/envs/test/lib', '-L/opt/anaconda3/envs/test/lib', './libffcx_forms_812eb41c7947a5841f4fccab85cd4e6b90e48ecf.o', '-lm', '-o', './libffcx_forms_812eb41c7947a5841f4fccab85cd4e6b90e48ecf.cpython-314-darwin.so']' returned non-zero exit status 1.
Exception ignored while calling deallocator <function LinearProblem.__del__ at 0x115b74b40>:
Traceback (most recent call last):
  File "/opt/anaconda3/envs/test/lib/python3.14/site-packages/dolfinx/fem/petsc.py", line 882, in __del__
    lambda obj: obj is not None, (self._solver, self._A, self._b, self._x, self._P_mat)
AttributeError: 'LinearProblem' object has no attribute '_solver'
Abort(808576911): Fatal error in internal_Finalize: Other MPI error, error stack:
internal_Finalize(50)...........: MPI_Finalize failed
MPII_Finalize(421)..............: 
MPID_Finalize(711)..............: 
MPIDI_OFI_mpi_finalize_hook(861): 
flush_send_queue(830)...........: 
MPIDI_NM_progress(108)..........: 
MPIDI_OFI_handle_cq_error(593)..: OFI poll failed (default nic=utun4: Input/output error)

Inside the environment, I observe that a different clang than the system clang is used:

clang -v
> clang version 23.1.1
> Target: arm64-apple-darwin25.6.0
> Thread model: posix
> InstalledDir: /opt/anaconda3/envs/test/bin
> Configuration file: /opt/anaconda3/envs/test/bin/arm64-apple-darwin-clang.cfg

I have tried reinstalling and/or downgrading clang, however nothing seems to work.

Manual compilation of the cffi with the clang in the environment does not work (same error). Compilation using the system clang (see above) by changing directory to ~/.cache/fenics and running

mv libffcx_forms_812eb41c7947a5841f4fccab85cd4e6b90e48ecf.c.failed libffcx_forms_812eb41c7947a5841f4fccab85cd4e6b90e48ecf.c
clang -bundle -undefined dynamic_lookup -Wl,-rpath,/opt/anaconda3/envs/test/lib -L/opt/anaconda3/envs/test/lib -Wl,-rpath,/opt/anaconda3/envs/test/lib -L/opt/anaconda3/envs/test/lib ./libffcx_forms_812eb41c7947a5841f4fccab85cd4e6b90e48ecf.o -lm -o ./libffcx_forms_812eb41c7947a5841f4fccab85cd4e6b90e48ecf.cpython-314-darwin.so

works (no errors and the .so file is generated), but the error persists when rerunning python3 demo_poisson.py.

Help would be greatly appreciated!

Uninstalling Xcode and the Command Line Tools, and then installing only the Command Line Tools Version 26.6 (but not installing Xcode at all) from Sign In - Apple solved the issue!

Great that you figured it out! I had the same issue and got Claude to debug it for me. Here’s Claudes alternate fix that doesn’t require a reinstall, maybe someone else will find it useful.

Hit the same error (ld: dynamic executables or dylibs must link with libSystem.dylib for architecture arm64) building FFCX forms via CFFI. Turned out /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk was symlinked to a beta SDK whose libSystem doesn’t support plain arm64. As an alternative to reinstalling CLT, you can just repoint that symlink at an older SDK if one’s still on disk (check /Library/Developer/CommandLineTools/SDKs/):

​ sudo ln -sfn MacOSX12.1.sdk /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk ​

Worked for me without touching the Xcode/CLT install at all.