You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
cffi cannot be built correctly on macOS if libffi is installed in /usr/local #297
When using a python application (in my case, mitmproxy), this error occurs: ffi_prep_closure(): bad user_data (it seems that the version of the libffi library seen at runtime is different from the 'ffi.h' file seen at compile-time)
It appears that if libffi is installed in /usr/local, cffi gets built using system /usr/include/ffi and pkg-config /usr/local/lib.
setup.py retrieves /usr/local/include and /usr/local/lib from pkg-config, and it sets -iwithsysroot/usr/include/ffi for macOS.
Checking the verbose output of compilation, clang ignores the passed /usr/local/include, so it reads ffi.h from /usr/include/ffi:
ignoring duplicate directory "/usr/local/include"
as it is a non-system directory that duplicates a system directory
#include "..." search starts here:
#include <...> search starts here:
/private/tmp/build-env-xgzeuiks/include
/Library/Frameworks/Python.framework/Versions/3.15/include/python3.15
/usr/include/ffi
/usr/local/include
/Library/Developer/CommandLineTools/usr/lib/clang/10.0.0/include
/Library/Developer/CommandLineTools/usr/include
/usr/include
/System/Library/Frameworks (framework directory)
/Library/Frameworks (framework directory)
End of search list.
Activity
mattip commentedon Dec 4, 2026
Can you check that #298 fixes the problem?
thisisgk commentedon Dec 4, 2026
Thank you. It worked.