Skip to content

Expose a function to obtain cargo's installation root #13288

Open
@yds12

Description

@yds12

Problem

I have an application that needs to know where binaries installed via cargo install are located in the system. I can roughly assume it will be in $HOME/.cargo/bin, but according to this, when we do cargo install the location will be determined by, in order of priority:

  • --root option
  • CARGO_INSTALL_ROOT environment variable
  • install.root Cargo config value
  • CARGO_HOME environment variable
  • $HOME/.cargo

My idea was to use cargo as a library crate (although I need to see the impact in terms of dependencies) to obtain this location. I assume cargo already has some internal function that does that, as far as I checked it uses a resolve_root function, but that function is not public.

In summary: it would be nice to have a function in cargo (as a library) that given a current working directory, could give me the installation root.

Proposed Solution

If I understand correctly, making resolve_root public would suffice.

Notes

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-cargo-apiArea: cargo-the-library API and internal code issuesC-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`S-needs-infoStatus: Needs more info, such as a reproduction or more background for a feature request.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions