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

Use platform-defined directories for cargo state #9178

Closed
wants to merge 1 commit into from

Conversation

spacekookie
Copy link
Member

Continuation of PR #8063.


This PR changes the cargo config system to use the XDG spec directories, instead of using $HOME/.cargo.

Currently it only uses XDG_DATA_HOME and XDG_CACHE_HOME. There was some discussion in #1734 about also using the new XDG_BIN_HOME directory, but this is not yet implemented.

The priority of paths cargo will check is as follows:

  1. Use $CARGO_HOME, if it is set
  2. Use $CARGO_CACHE_DIR, $CARGO_CONFIG_DIR, etc, if they are set
  3. If no environment variables are set, and $HOME/.cargo is present,
    use that
  4. Finally, use the platform-default directory paths

@rust-highfive
Copy link

r? @alexcrichton

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 16, 2021
This commit changes the cargo data directories from $HOME/.cargo to
using the XDG spec directories.  It also adds the directories crate as
a dependency.

Currently, only `XGD_DATA_HOME` (on Linux this is `$HOME/.local/share`
by default) and `XDG_CACHE_HOME` (on Linux this is `$HOME/.cache` by
default) are used.

The priority of paths cargo will check is as follows:

1. Use `$CARGO_HOME`, if it is set
2. Use `$CARGO_CACHE_DIR`, `$CARGO_CONFIG_DIR`, etc, if they are set
3. If no environment variables are set, and `$HOME/.cargo` is present,
   use that
4. Finally, use the platform-default directory paths
@alexcrichton
Copy link
Member

To ensure I understand the current state of things, this -- #8063 (comment) -- is still the status here I think? That is, I think the RFC feedback still needs synthesis/digestion and perhaps a follow-up RFC is in order?

@spacekookie
Copy link
Member Author

spacekookie commented Feb 17, 2021

To ensure I understand the current state of things, this -- #8063 (comment) -- is still the status here I think? That is, I think the RFC feedback still needs synthesis/digestion and perhaps a follow-up RFC is in order?

Sure thing! I will have a look at the existing RFC and some of the feedback and post the work in progress I come up with here.

Somewhat unrelated, but is it possible to turn an PR back into a draft PR?

@spacekookie
Copy link
Member Author

Okay I read the OG RFC and most of the comments (which largely don't add any relevant rationale), and started a PR on my own RFC repo here: spacekookie/rfcs#1 to have discussions on (and keep this thread free for the technical implementation)

@bors
Copy link
Contributor

bors commented Feb 23, 2021

☔ The latest upstream changes (presumably #9175) made this pull request unmergeable. Please resolve the merge conflicts.

@DianaNites
Copy link

If no environment variables are set, and $HOME/.cargo is present,
use that

How could an existing $HOME/.cargo be migrated?

There are also some third-party tools that store stuff in .cargo, such as cargo-audit, at $HOME/.cargo/advisory-db

Maybe another environment variable could be set for 3rd party subcommands, giving a path where its okay to put stuff? That way they dont need to re-implement cargo logic

@oxalica
Copy link

oxalica commented Apr 20, 2021

How could an existing $HOME/.cargo be migrated?

We can write the migration guide in cargo reference and produce a warning with the URL . Most users should only handle credential, config and bin. Other cache can be simply removed.

There are also some third-party tools that store stuff in .cargo, such as cargo-audit, at $HOME/.cargo/advisory-db

Third-party tools are individual programs. They should have their own data or cache directory instead of cargo's. We can request them to switch directories. But they would not be affected by cargo changes.

@tailhook
Copy link

Is using directories = "1" intentional? (while there is already 3.0.2)

@ehuss
Copy link
Contributor

ehuss commented Aug 6, 2021

I'm gonna close this due to inactivity, and per the followup discussion on the RFC linked above. Thanks!

@ehuss ehuss closed this Aug 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants