rustup: Binary named `rust-analyzer` added to cargo bin path even when component is not added
Verification
- I searched for recent similar issues at https://github.com/rust-lang/rustup/issues?q=is%3Aissue+is%3Aopen%2Cclosed and found no duplicates.
- I am on the latest version of Rustup according to https://github.com/rust-lang/rustup/tags and am still able to reproduce my issue.
Problem
Rustup keeps adding a binary named rust-analyzer to the .cargo/bin folder. But I didn’t add it because I want homebrew to manage rust-analyzer version, because I want the latest version. But since there is a rust-analyer in my path at ~/.cargo/bin/rust-analyzer my editor tries to use it.
Opening it i get a message
error: Unknown binary 'rust-analyzer' in official toolchain 'stable-aarch64-apple-darwin'.
To install, run `rustup component add rust-analyzer`
This is very annoying because I keep having to delete this dummy binary everytime i run rustup so my editor can find the actual binary. Is there any reason to create these dummy binaries? Can I disable this?
Steps
- Install rustup with with minimal
Possible Solution(s)
No response
Notes
No response
Rustup version
rustup 1.27.1 (54dd3d00f 2024-04-24)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.78.0 (9b00956e5 2024-04-29)`
Installed toolchains
Default host: aarch64-apple-darwin
rustup home: /Users/praveen/.rustup
stable-aarch64-apple-darwin (default)
rustc 1.78.0 (9b00956e5 2024-04-29)
OS version
MacOS Version 14.5 (23F79)
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 5
- Comments: 16 (11 by maintainers)
I’d like to prefer using my own
rust-analyzer’s version of choice, but it seems likerustupknows better 🤷 It’s weird and confusing, because the binary in~/.cargo/bin/is created even if I don’t have the component installed. This issue makes keeping multiple machines with different OSes up-to-date just slightly more annoying every 4 weeksI’m not sure if the bug reported here is ‘i get an error’, or, ‘the wrong version runs’: consider that we might teach this one proxy to fall back to path, but then the bug changes to be ‘wrong version because I had the component installed’.
I suggest finding out the plans of rust analyser.
If the situation is transitory , I recommend doing nothing… Users can put their own bin before the cargo bin anyway.
If we add special case complexity, it affects our users as it becomes one more thing they have to learn about when the system behaves in a surprising manner.
Sounds reasonable to me… Security-wise it seems okay to me because we’re merely relying on the
PATHthat the user has set anyway (and so implicitly trusts).@praveenperera Thanks for filing this issue!
Yes, since
rustupwould want to add a shim forrust-analyzer.AFAIK you can’t, unfortunately. However this point has been pointed out in the original PR by @ehuss:
If you are a VSCode user, it would be okay if you just use the plugin-bundled version of
rust-analyzer, as it’s guaranteed to be up-to-date. If you are not, well, to be frank I think this is a point to be improved, since I also use a non-Rustup distribution ofrust-analyzer(from Neovim’smasonto be precise).@rbtcollins Do you think it’ll be fine if we only add shims for installed components (or
DUP_TOOLS, to be more specific)? Will that disrupt our current stability guarantees/business logic too much?I can make this less annoying by putting homebrew path before the cargo path, but I don’t understand why its installing these dummy binaries into the PATH in the first place