Report on platform-compliance for cargo directories

Discussion on r/rust: Reddit - Dive into anything

9 Likes

Would there be a benefit in only moving cache dirs at first? That seems like it would be easier as it doesn't strictly need every cargo version to agree. At worst it doubles disk space usage (which already happens anyway due to the move to the sparse registry protocol using a different directory for everything). It will make it easier for users to clear all caches including cargo's caches. Unlike the config and bin dir duplication of the cache dir doesn't mess up any user observable state.

2 Likes

Not having caught up on everything, I was wondering why we wouldn't go in a direction like this

  • Diverge the cache dirs
  • Read both config dirs
  • Maybe write bins to both locations (if present)

One concern would be the extra space / sync time for the git index but sparse index being default will help.

1 Like

Regarding interop between tools: I can't speak to all of them, but cargo-audit uses the home crate.

Perhaps the home crate could provide a finer-grained API like cargo_cache_home, cargo_config_home, cargo_bin_home?

There is the directories crate for that already.

That's a generic cross-platform implementation of XDG.

I'm talking about having a cargo-specific API, as the home crate does today, which would make it possible to migrate from the current ~/.cargo to XDG (possibly via environment variable-based configuration?)

I didn't know the home crate has a cargo-specific API.

If someone creates a fresh install of rust and cargo using rustup, and subsequently installs and runs an older version of cargo, it seems fine if the older version of cargo doesn't share ~/.cargo by default. The index will need re-downloading, but that's going to be the case anyway if you run an older version that uses the non-sparse index. Crates will need re-downloading, but that doesn't seem like that big a deal either. And users won't have cargo configuration by default, unless they've manually created it.

Given all that, I wonder if we need new cargo to still default to the old ~/.cargo directory if no directories exist, or if it could default to the new locations?

It defines cargo_home which is the canonical function for locating ~/.cargo which is used by Cargo itself

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.