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
Append ~/.rustup/toolchains/bin to PATH when running a proxy #3389
I am writing a new rustc_driver tool (say it's called foo). I want to be able to have multiple versions, so I've put it in the toolchain directory instead of the per-user ~/.cargo/bin (which only allows a single version). Additionally, I want to be able to run it as cargo +nightly foo, so I have a cargo-foo binary which works like cargo-clippy, setting RUSTC_WORKSPACE_WRAPPER.
90% percent of this already works. cargo +nightly foo runs the rustup proxy, which sets RUSTUP_TOOLCHAIN and runs the correct version of cargo, which calls cargo-foo. Here's the problem: cargo-foo is not actually in PATH. It's in /Users/jyn/.local/lib/rustup/toolchains/stage1/bin/cargo-foo, not ~/.cargo/bin. To make this work, I have to write a third cargo-foo binary to go in ~/.cargo/bin and dispatch based on RUSTUP_TOOLCHAIN.
Solution you'd like
It would be really nice if rustup would add /Users/jyn/.local/lib/rustup/toolchains/stage1/bin to PATH so that I don't need to write this third binary. That would make it fully scoped to the toolchain directory so there's no global setup needed and I don't have to worry about differences between the proxy in different versions.
Notes
Unfortunately, this has caused issues in the past; #3178 has a very good writeup. I think as long as we always append the directory to the path, so that it's only used if there's no proxy in ~/.cargo/bin, this should work ok, but it's a complicated space.
Oh, another alternative which is much less likely to break is to have a custom x setup foo step where bootstrap is the one in charge of installing the proxy - that wouldn't need rustup changes and only comes at the cost of a single extra manual step.
So adding to the path means that when users do complicated things; e.g. consider two levels of recursion through proxies, outer layer toolchain X, inner layer toolchain Y, PATH then has $ORIG_PATH:X/bin:Y/bin, anything resolving by PATH will get binaries from X, not Y.
Activity
jyn514 commentedon Jun 21, 2023
Oh, another alternative which is much less likely to break is to have a custom
x setup foostep where bootstrap is the one in charge of installing the proxy - that wouldn't need rustup changes and only comes at the cost of a single extra manual step.rbtcollins commentedon Jun 21, 2023
So adding to the path means that when users do complicated things; e.g. consider two levels of recursion through proxies, outer layer toolchain X, inner layer toolchain Y, PATH then has
$ORIG_PATH:X/bin:Y/bin, anything resolving by PATH will get binaries from X, not Y.