Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for "rustup run active" #1279

Closed
wants to merge 1 commit into from
Closed

Add support for "rustup run active" #1279

wants to merge 1 commit into from

Conversation

lnicola
Copy link
Member

@lnicola lnicola commented Oct 29, 2017

Implements #1278

@nrc
Copy link
Member

nrc commented Oct 29, 2017

Would it be possible for rustup run foo to do this rather than rustup run active foo? I feel a bad about adding yet another keyword to rustup (alternatively, maybe we should use default rather than active since that is the term usually used for this).

@lnicola
Copy link
Member Author

lnicola commented Oct 29, 2017

That would make parsing the command line a bit fuzzy ("is rustc a toolchain or a command?", "did it fail to find a toolchain because it was actually a command, or because it's not installed?"), so I'm a bit torn about that.

About active vs. default, I think active is what it should be called. defaultis the "static default", while active might have been overridden (e.g. per-project via rustup override). But I don't like the name either 😄.

@nrc
Copy link
Member

nrc commented Oct 30, 2017

cc @alexcrichton and @withoutboats thoughts?

@lnicola
Copy link
Member Author

lnicola commented Oct 30, 2017

Note that I quite like the idea of making the toolchain optional, but I'll wait for someone else to chip in on whether this feature might be wanted.

@alexcrichton
Copy link
Member

I'm not sure I quite understand the intended use case here, @lnicola mind elaborating on how you intend this getting used?

@lnicola
Copy link
Member Author

lnicola commented Oct 30, 2017

The VS Code extension runs rls via rustup, like rustup run nightly rls, where the toolchain is configured in the editor settings. But this can be problematic, especially when considering toolchain overrides and Windows, where nightly doesn't always mean the same thing.

The simple way out is to run rls directly, but it doesn't work if the cargo directory isn't in PATH, which the editor doesn't (and shouldn't control). So this PR allows VS Code to work even in that situation.

Besides that, it fills a hole in the functionality of rustup: it knows the active toolchain, and it can run commands, but it can't run commands in the active toolchain, which seems awkward (like a ls that only works with absolute paths, if you want).

@lnicola
Copy link
Member Author

lnicola commented Oct 30, 2017

As a summary from a discussion on IRC:

  • The VS Code extension (rls-vscode) should probably just run rls and hope for the best. The toolchain setting should then be removed, maybe after a transitional period in which both methods are supported with a warning for the old one.
  • Running rls directly might fail when rustup run active rls would work when PATH is misconfigured, (maybe because the user has switched to another shell, or is not running a login shell). rls-vscode can detect that rls is not available and ask the user to do.. something.
  • @alexcrichton feels that adding this feature to rustup is unnecessary since there's no expected consumer for it after the rls-vscode changes mentioned above
  • @lnicola pointed out that other projects had to work around the lack of this feature, or have the same issue originally reported in rls-vscode: https://github.com/editor-rs/vscode-rust/blob/8e6422d3f22f35cac8c1fc4de340a2bcfe6456be/src/CargoInvocationManager.ts#L25, https://github.com/aergonaut/languageserver-rust/blob/master/lib/languageserver-rust.js#L21.
  • @lnicola feels it's weird that rustup can tell the active toolchain and run commands under a specific one, but can't run a command under the one that's active (like the rustup stubs do)

In any case, I'm fine with closing this, as it's not strictly needed, but I have a hunch that people might ask again about it in the future.

@lnicola
Copy link
Member Author

lnicola commented Nov 1, 2017

Closing since there wasn't any additional feedback.

@valpackett
Copy link

valpackett commented Dec 27, 2022

Just ran into this. I have rustup installed via a system package on an archlinux box and there's no /usr/bin/rust-analyzer -> /usr/bin/rustup symlink to "just" run it without rustup run. If I make one, it actually complains!

error: unknown proxy name: 'rust-analyzer'; valid proxy names are 'rustc', 'rustdoc', 'cargo', 'rust-lldb', 'rust-gdb', 'rust-gdbgui', 'rls', 'cargo-clippy', 'clippy-driver', 'cargo-miri', 'rustfmt', 'cargo-fmt'

so there's no way to get to rust-analyzer without explicitly referring to stable / nightly etc. at least in this version (rustup 1.25.1) upd: i see this is discussed in #2411

@lnicola
Copy link
Member Author

lnicola commented Dec 28, 2022

@valpackett you can do rustup which rust-analyzer to find the path to the binary. I think the next version of rustup will also include a proxy for it.

PS: this was my first PR to the rust-lang org 😅.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants