foundry.nix
foundry.nix copied to clipboard
Latest nightly reports libusb error on macOS
See error below when trying to build on x86_64-darwin :
> dyld[26252]: Library not loaded: /usr/local/opt/libusb/lib/libusb-1.0.0.dylib
> Referenced from: <736E6247-D161-383D-B251-98CDD9CF58AB> /nix/store/hm7nkcd8pbw26x0bnsna3x1pzlfmap5i-foundry-0.0.0/bin/.forge-wrapped
> Reason: tried: '/usr/local/opt/libusb/lib/libusb-1.0.0.dylib' (errno=1), '/usr/local/lib/libusb-1.0.0.dylib' (errno=1), '/usr/lib/libusb-1.0.0.dylib' (no such file, not in dyld cache)
> /nix/store/skkmsz618ybnwhawjfs33xi76bxwwfvh-stdenv-darwin/setup: line 1605: 26252 Abort trap: 6 $out/bin/forge --version > /dev/null
Hm, I don't have a darwin machine. Is it still happening on today's nightly? Or what about the monthly?
Any idea what the fix might be?
This is a bit of a random guess, but could try adding libusb1 to nativeBuildInputs?
Maybe something like this: https://github.com/shazow/foundry.nix/pull/24
Thanks again, but the problem still happens on latest nightly and the attempted fix doesn't help.
• Updated input 'foundry':
'github:shazow/foundry.nix/3d62e5266eecd6c283769a09a1dbd3a012b0d6ca' (2023-09-11)
→ 'github:shazow/foundry.nix/652d3c51f772ee3103991dac9bdf2d9448057871' (2023-09-11)
...
error: builder for '/nix/store/mpp4b2ijj7dxh1swncba9qgy5h5x2qlz-foundry-0.0.0.drv' failed with exit code 134;
last 10 log lines:
> installing
> post-installation fixup
> checking for references to /private/tmp/nix-build-foundry-0.0.0.drv-0/ in /nix/store/xdzz93slsi9n8hcnziwl0yd4rgbzvnvb-foundry-0.0.0...
> patching script interpreter paths in /nix/store/xdzz93slsi9n8hcnziwl0yd4rgbzvnvb-foundry-0.0.0
> stripping (with command strip and flags -S) in /nix/store/xdzz93slsi9n8hcnziwl0yd4rgbzvnvb-foundry-0.0.0/bin
> running install tests
> dyld[9514]: Library not loaded: /usr/local/opt/libusb/lib/libusb-1.0.0.dylib
> Referenced from: <166F67F2-63B7-38AF-A37A-2B675000D5EB> /nix/store/xdzz93slsi9n8hcnziwl0yd4rgbzvnvb-foundry-0.0.0/bin/.forge-wrapped
> Reason: tried: '/usr/local/opt/libusb/lib/libusb-1.0.0.dylib' (errno=1), '/usr/local/lib/libusb-1.0.0.dylib' (errno=1), '/usr/lib/libusb-1.0.0.dylib' (no such file, not in dyld cache)
> /nix/store/skkmsz618ybnwhawjfs33xi76bxwwfvh-stdenv-darwin/setup: line 1605: 9514 Abort trap: 6 $out/bin/forge --version > /dev/null
For full logs, run 'nix log /nix/store/mpp4b2ijj7dxh1swncba9qgy5h5x2qlz-foundry-0.0.0.drv'.
Found this https://github.com/foundry-rs/foundry/blob/d135838b4e9d0a345e406b5f1805eaafa5f64223/foundryup/install#L52
Not sure why it used to work for me and now not anymore, maybe they added some tests at build- or runtime
@beeb Ah, does it work if you install libusb out of band?
I can't really test as all the latest nightlies available through this overlay give me 404 errors e.g. https://github.com/foundry-rs/foundry/releases/download/nightly-8920fd4cf4082d678fb569e3fb7b0267366f59bb/foundry_nightly_darwin_amd64.tar.gz
Is foundry deleting nightly tags regularly? I've hit this issue several times where the release artifact cannot be downloaded. It's not even an old tag as it was apparently found today by your workflow
does it work if you install libusb out of band
I tried with the monthly release and the answer is no. See output of homebrew:
But I get the same error as initially reported.
We've generally had an arrangement where they keep the last N nightly tags, but otherwise they do get deleted regularly. Monthly is supposed to be permanent.
This is still an issue on macOS, can the issue be at least re-opened?
In https://github.com/shazow/foundry.nix/pull/24 I notice that the AutoPatchelfHook is only used on linux, shouldn't it also be used on macOS to patch the libusb path?
@beeb AutoPatchelfHook is for NixOS, it doesn't support darwin AFAIK. It's mainly to override the dynamically linked FHS paths.
If you manage to patch the foundry binary manually (using patchelf) with the correct libusb paths such that it works, then we can probably figure out a way to automate that in the flake.
Also can you confirm whether just using the foundry binaries from the foundry repo works on your machine? If not, it may be a whole other issue.
Confirmed, everything works as expected when installing through foundryup (as long as libusb is installed through homebrew)
Hi @shazow recently in Ethereum.nix we have switched to buildbot, and interestingly I've encountered the same error, you can see the error logs here.
Scouting on fundry's repository I discovered this little warning.
So, I guess what you can do is include libusb dependency if the build is on darwin.
@aldoborrero I tried this change here: https://github.com/shazow/foundry.nix/pull/24
But it didn't help @beep with their issue. Can you see if it helps you? If so, happy to merge it.
I tried to get foundryup to resolve this issue - foundry-rs/foundry#3907