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

rustup component add rust-analyzer-preview does not add rust-analyzer executable to ~/.cargo/bin #2411

Closed
zoechi opened this issue Jul 10, 2020 · 18 comments

Comments

@zoechi
Copy link

zoechi commented Jul 10, 2020

Problem

I can install rust-analyzer using rustup component add rust-analyzer-preview but it is not added to ~/.cargo/bin like all other components (clippy, rustfmt, ...) and therefore not in the path and not executable.

Steps

Possible Solution(s)

Notes

Output of rustup --version: rustup 1.22.1 (b01adbbc3 2020-07-08)
Output of rustup show:

Default host: x86_64-unknown-linux-gnu
rustup home:  /home/user/.rustup

installed toolchains
--------------------

stable-x86_64-unknown-linux-gnu
beta-x86_64-unknown-linux-gnu
nightly-2020-03-19-x86_64-unknown-linux-gnu
nightly-x86_64-unknown-linux-gnu (default)
1.37.0-x86_64-unknown-linux-gnu

installed targets for active toolchain
--------------------------------------

wasm32-unknown-unknown
x86_64-unknown-linux-gnu

active toolchain
----------------

nightly-x86_64-unknown-linux-gnu (default)
rustc 1.46.0-nightly (5db778aff 2020-07-09)
@zoechi zoechi added the bug label Jul 10, 2020
@kinnison
Copy link
Contributor

This is the expected behaviour at this point. #2408 added the proxy but I'm considering if it ought to be in TOOLS or DUP_TOOLS because people have installed it via other means before now. For now, as per people who have talked about it, you can run rust-analyzer via rustup run nightly rust-analyzer which you can always set up as a shell alias if you want, or a small shell script if you so desire.

@kinnison
Copy link
Contributor

The next release of rustup will contain the proxy either way.

@kinnison kinnison removed the bug label Jul 10, 2020
@zoechi
Copy link
Author

zoechi commented Jul 10, 2020

I see.
Feel free to close.

@teor2345
Copy link

teor2345 commented Jun 3, 2021

Note that this change was backed out in 1.23 because rust-analyzer isn't stable yet:
#2408 (comment)

@jangid
Copy link

jangid commented Jul 2, 2022

Now that the rust-analyzer is officially announced as default LS, will the binary be installed to default location in next release?

@Jasha10
Copy link

Jasha10 commented Oct 16, 2022

According to the rust-lang blog post from Sept 22, 2022, rust-analyzer is now available via rustup.

The following works for me:

$ rustup component add rust-analyzer
info: downloading component 'rust-analyzer'
info: installing component 'rust-analyzer'
$ rustup run stable rust-analyzer --version
rust-analyzer 1.64.0 (a55dd71 2022-09-19)

According to the blog post, "The next release of rustup will provide a built-in proxy so that running the executable rust-analyzer will launch the appropriate version."

@janos-r
Copy link

janos-r commented Nov 6, 2022

I love this, I also got it running on helix with a custom rustup run stable rust-analyzer command, but I am confused about the version.
Why does the --version show the version of rustc and not the version of the real rust-analyzer?

@lesleyrs
Copy link

@janos-r I actually didn't get rustup run stable rust-analyzer working in languages.toml, even though it works in terminal. Had to add it to PATH to make it work, what did you do?

@zackw
Copy link

zackw commented Nov 22, 2022

@lesleyrs This wrapper script may help, put it in $HOME/.local/bin or some other directory on your PATH and chmod +x it:

#! /bin/sh
# as of 2022-11-22 rustup-installed rust-analyzer isn't available
# directly in $PATH
exec rustup run $(rustup show active-toolchain | cut -d' ' -f1) rust-analyzer

@pothos
Copy link

pothos commented Dec 6, 2022

@zackw Nice tip! Only "$@" is missing at the end to work with --version or similar arguments.

My complete version of ~/.cargo/bin/rust-analyzer:

#!/bin/bash
set -euo pipefail
exec rustup run "$(rustup show active-toolchain | cut -d' ' -f1)" rust-analyzer "$@"

@janos-r
Copy link

janos-r commented Dec 7, 2022

@janos-r I actually didn't get rustup run stable rust-analyzer working in languages.toml, even though it works in terminal. Had to add it to PATH to make it work, what did you do?

[[language]]
name = "rust"
language-server = { command = "rustup", args = ["run", "stable", "rust-analyzer"] }

Works like a charm. Sry I didnt see your message sooner. In the next release it should be part of the path automatically already tho. This above is just temporarily necessary before that.

@lesleyrs
Copy link

lesleyrs commented Dec 7, 2022

@janos-r Ok I found out why it wasn't working without path, I used that same line but in helix directory languages.toml not the user directory one. I guess you have to recompile to change the former? Thanks :D

@cbiffle
Copy link

cbiffle commented Dec 8, 2022

So, one of the things that's valuable about the proxies in a well-defined (and PATH-exposed) location is that they take advantage of rustup honoring the rust-toolchain.toml file. By hardcoding rustup run stable rust-analyzer into editor configs, aren't we just running "whatever the current stable on this machine is", rather than the version pinned by the project?

Is there a good workaround for this other than the shell script someone posted above?

@zackw
Copy link

zackw commented Dec 8, 2022

Maybe we could get rustup run default ... added? I was surprised to find that that doesn't already work.

@cbiffle
Copy link

cbiffle commented Dec 8, 2022

FWIW this became relevant to me rather suddenly when rls was replaced by an imposter, but `rust-analyzer isn't ready yet (in the sense of having a rustup proxy that respects pinned toolchain versions)

@jjant
Copy link

jjant commented Jan 11, 2023

Will we eventually get this working out of the box?

@lunasophia
Copy link

I don't think it's appropriate for this bug to be closed when the feature it requests is accepted but not yet delivered.

@rbtcollins
Copy link
Contributor

@lunasophia what do you mean? Rustup-init installs a rust-analyzer proxy in current versions.

If you've installed the rust-analyzer component, it should just work. So the feature is delivered.

If you've got specific failures or errors, please file a new bug. I'm locking this now, since we're getting noise, and the appropriate thing to do is to file a new bug, not resurrect a closed, fixed, bug.

@rust-lang rust-lang locked as resolved and limited conversation to collaborators Mar 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests