uv: `uvx` invocation does not propagate `DYLD_FALLBACK_LIBRARY_PATH` to the invoked script on MacOS

I was not able to pass environment variables to utilities run with uvx.

I noticed this problem trying to run uvx weasyprint on MacOS, which fails because it is not able to locate a homebrew installed library.

% export DYLD_FALLBACK_LIBRARY_PATH=/opt/homebrew/lib
% uvx weasyprint --version

... snip ...

OSError: cannot load library 'gobject-2.0-0': dlopen(gobject-2.0-0, 0x0002): tried: 'gobject-2.0-0' (no such file), '/System/Volumes/Preboot/Cryptexes/OSgobject-2.0-0' (no such file), '/usr/lib/gobject-2.0-0' (no such file, not in dyld cache), 'gobject-2.0-0' (no such file).  Additionally, ctypes.util.find_library() did not manage to locate a library called 'gobject-2.0-0'

But after installing in a venv

% uv venv
Using Python 3.12.5
Creating virtualenv at: .venv
Activate with: source .venv/bin/activate

% uv pip install weasyprint
Resolved 14 packages in 9ms
Installed 14 packages in 19ms
 + brotli==1.1.0
 + cffi==1.17.0
 + cssselect2==0.7.0
 + fonttools==4.53.1
 + html5lib==1.1
 + pillow==10.4.0
 + pycparser==2.22
 + pydyf==0.11.0
 + pyphen==0.16.0
 + six==1.16.0
 + tinycss2==1.3.0
 + weasyprint==62.3
 + webencodings==0.5.1
 + zopfli==0.2.3

the command works as expected (and no export necessary)

% DYLD_FALLBACK_LIBRARY_PATH=/opt/homebrew/lib .venv/bin/weasyprint --version
WeasyPrint version 62.3

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 32 (26 by maintainers)

Most upvoted comments

@miccoli Sorry about all the back and forth! We’ll look for a workaround here, but this is really an annoying macOS behavior.

Thanks for nailing this down really really fast.

No problem on my side, once you know the problem you can live with it quite easily… I opened this issue mainly to avoid others the pain of understanding what was going on.

BTW this is really an edge case, so there is no urgency in solving it.

Wow so tragic. I have SIP turned off — that’s why it works for me.