Skip to content

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

Open

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

  1. 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.

  2. sohang3112 commented on Aug 14, 2023

    @sohang3112
    Author

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

  3. 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.

  4. 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.

  5. changed the title [-]Show installed path of components[/-] [+]Show installed path of Rust sources[/+] on Apr 19, 2024
  6. changed the title [-]Show installed path of Rust sources[/-] [+]Show installed path of Rust components: sources, docs & Clippy[/+] on Apr 19, 2024
  7. 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.

  8. 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?

  9. 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.

  10. 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.

  11. added this to the 1.28.0 milestone on Apr 20, 2024
  12. 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.

  13. 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.

  14. sohang3112 commented on Jul 23, 2024

    @sohang3112
    Author

    @rami3l Is there any update on this issue?

  15. rami3l commented on Jul 24, 2024

    @rami3l
    Member

    @rami3l Is there any update on this issue?

    @sohang3112 The plan is to finish this in the v1.28.0 release cycle, but as my life plans have suddenly changed and I'm now prioritizing my personal issues, I cannot give any guarantees on that. Please remember the Rustup project is fully run by volunteers and so far all team members are doing this as a hobby. If you'd like to work on this issue, please go ahead :)

  16. sohang3112 commented on Jul 24, 2024

    @sohang3112
    Author

    If you'd like to work on this issue, please go ahead :)

    Ok, I'll do that in a while. I'm new to Rust so I'll ask you if I have any questions.

  17. modified the milestones: 1.28.0, 1.28.1 on Aug 9, 2024
  18. modified the milestones: 1.28.2, 1.28.3 on Apr 15, 2025
  19. modified the milestones: 1.29.0, 1.30.0 on Apr 16, 2026
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

      Issue actions