coral-xyz / anchor

⚓ Solana Sealevel Framework
https://anchor-lang.com
Apache License 2.0
3.5k stars 1.3k forks source link

Encountered an issue (librustc_driver-c9ef59bea954d042.dylib) while using `anchor build` in a Solana project. #2777

Open JeanChristopheMoon opened 7 months ago

JeanChristopheMoon commented 7 months ago

There's a problem when trying to use the Rust compiler for the "anchor" project in the Solana environment. It seems like a specific library, "librustc_driver-c9ef59bea954d042.dylib," is causing issues and cannot be loaded.

Error Message:

dyld: Library not loaded: @rpath/librustc_driver-c9ef59bea954d042.dylib Referenced from: /Users/zoro/.cache/solana/v1.37/platform-tools/rust/bin/rustc Reason: no suitable image found. Did find: /Users/zoro/.cache/solana/v1.37/platform-tools/rust/bin/../lib/librustc_driver-c9ef59bea954d042.dylib: cannot load 'librustc_driver-c9ef59bea954d042.dylib' (load command 0x80000034 is unknown) /Users/zoro/.cache/solana/v1.37/platform-tools/rust/bin/../lib/librustc_driver-c9ef59bea954d042.dylib: stat() failed with errno=1

**Environment:**
acheroncrypto commented 7 months ago

The error is from Solana's platform-tools which Anchor uses to build programs so I don't think we can solve it from our side. It might also be an issue with your installation, I'd try removing ~/.cache/solana and re-install.

Interestingly, Rust 1.75.0 blog post mentions librusc_driver.so library even though platform-tools 1.37 uses rustc 1.68.0.

I've run into https://github.com/rust-lang/rust/issues/24677#issuecomment-95012477 and https://github.com/rust-lang/rust/issues/26860#issuecomment-119548800 while looking at this issue, they're pretty old but maybe they help?