Skip to content

Show installed path of Rust components: sources, docs & Clippy #3382

Open
@sohang3112

Description

@sohang3112

Problem you are trying to solve

It would be nice if Rustup itself could show the paths of where Rust components (eg. rustc, rust_src, etc.) are installed.

Solution you'd like

Add a command to show path of Rust components (if installed).

$ rustup which rust_src
/path/to/folder/where/installed/rust_src

Notes

No response

Activity

rbtcollins

rbtcollins commented on Aug 13, 2023

@rbtcollins
Contributor

Components aren't installed into isolated directories - they all exist under the toolchain root.

If you want the path to a binary, rustup which rustc already exists.

Possibly documentation could be improved here.

sohang3112

sohang3112 commented on Aug 14, 2023

@sohang3112
Author

@rbtcollins How can I find the path to installed Rust sources?

rbtcollins

rbtcollins commented on Aug 20, 2023

@rbtcollins
Contributor

You can see the files that rust-src includes by cat ~/.rustup/toolchains/<toolchain-name>/lib/rustlib/manifest-rust-src.

sohang3112

sohang3112 commented on Apr 19, 2024

@sohang3112
Author

You can see the files that rust-src includes by cat ~/.rustup/toolchains/<toolchain-name>/lib/rustlib/manifest-rust-src.

@rbtcollins rustup which rust-src should show path to sources of the default toolchain (stable or nightly). Similarly, rustup which clippy and rustup which rust-docs should also work.

changed the title [-]Show installed path of components[/-] [+]Show installed path of Rust sources[/+] on Apr 19, 2024
changed the title [-]Show installed path of Rust sources[/-] [+]Show installed path of Rust components: sources, docs & Clippy[/+] on Apr 19, 2024
rami3l

rami3l commented on Apr 19, 2024

@rami3l
Member

Components aren't installed into isolated directories - they all exist under the toolchain root.

If you want the path to a binary, rustup which rustc already exists.

Possibly documentation could be improved here.

@rbtcollins I believe we have rustup doc --path for this.

sohang3112

sohang3112 commented on Apr 20, 2024

@sohang3112
Author

@rami3l TIL about rustup doc --path - is this mentioned in the documentation? Also are there similar commands to find paths of Rust sources and Clippy?

rami3l

rami3l commented on Apr 20, 2024

@rami3l
Member

@sohang3112 May I ask what you are using these paths for?

TIL about rustup doc --path - is this mentioned in the documentation?

Not yet, but there probably should be. It's already in the --help string though.

Also are there similar commands to find paths of Rust sources and Clippy?

Yes. Please note that clippy-driver is the real name of clippy, this is clearly documented in the Clippy User Guide.

So for the moment being:

$ rustup which clippy-driver                    # Gives the path of clippy
$ rustup which ../lib/rustlib/manifest-rust-src # A HACK, but does give the path of `rust-src`

If you don't like that hack, there's a more stable alternative to it:

$ echo "$(rustup show home)/toolchains/$(rustup show active-toolchain | awk '{print $1;}')"

I agree that the user experience here is awfully inconsistent and could use some improvements, doc-wise or impl-wise.

rami3l

rami3l commented on Apr 20, 2024

@rami3l
Member

@rbtcollins Moving forwards I suggest we either:

  1. Implement rustup which --prefix which gives ~/.rustup/toolchains/<toolchain-name>/bin and let the user handle the rest.
  2. Implement something like rustup component list --verbose which will add a path to lines like rustc-aarch64-apple-darwin (installed), and will print the path next to each component on rustup component list --installed --verbose.
  3. Implement rustup show active-toolchain --verbose which will do something similar to 2) but just for a single toolchain.

In any case, this should be scheduled after #3225 and #3596. The actual subcommand can be debated. We can afford to have true aliases as in #3596.

added this to the 1.28.0 milestone on Apr 20, 2024
rami3l

rami3l commented on Apr 20, 2024

@rami3l
Member

@sohang3112 Thanks a lot for your support!

... but you haven't answered my question yet:

May I ask what you are using these paths for?

Your original motivation is also very important in deciding the way forward.

sohang3112

sohang3112 commented on Apr 20, 2024

@sohang3112
Author

@rami3l I originally started looking for the path to Rust sources when VS Code wasn't able to find Rust sources (I think it had something to do with some things not working for Rust in VS Code: Go to Definition, hovering to show function, etc. - I don't remember the exact details now). VS Code Rust extension gave an error that it couldn't find Rust sources.

sohang3112

sohang3112 commented on Jul 23, 2024

@sohang3112
Author

@rami3l Is there any update on this issue?

6 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @rbtcollins@sohang3112@rami3l

        Issue actions

          Show installed path of Rust components: sources, docs & Clippy · Issue #3382 · rust-lang/rustup