rust-lang / rust-lang/rust

@rpath store a wrong path of .rustup libstd-*.dylib

Open
#152,209 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-dynamic-library needs-triage O-apple
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

If compile rust in dynamic link mode and set rpath=true, @rpath store a wrong path to libstd-*.dylib.
For example, my app run error when double click in macos got error like below:

dyld[38302]: Library not loaded: @rpath/libstd-b461f656c03d1a0a.dylib
  Referenced from: <no uuid> /Users/larry/Desktop/Img/target/debug/img
  Reason: tried: '/Users/larry/Desktop/Img/target/debug/../../../../../../.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libstd-b461f656c03d1a0a.dylib' (no such file), '/Users/larry/Desktop/Img/target/debug/../../../../../../.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libstd-b461f656c03d1a0a.dylib' (no such file)
zsh: abort      /Users/larry/Desktop/Img/target/debug/img

the right folder should be /opt/Rust/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libstd-b461f656c03d1a0a.dylib'

.rustup/ -> opt/Rust/.rustup

but cargo run works normally.

env: rustc 1.95.0-nightly (f889772d6 2026-02-05)
OS: macOS

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the dynamic-link build with rpath=true on macOS, comparing the executable launched by double-click with cargo run. Trace how the @rpath entry for libstd-*.dylib is formed and compare it with the expected /opt/Rust/.rustup/... location; done means the standalone app resolves the library successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.