Try   HackMD

Platform Directories (XDG)

Issues:

Benefits

Questions / concerns

Proposals

  • RFC#1615
  • spacekookie's unpublished RFC
    • Introduces:
      • CARGO_BIN_DIR
        • Formerly $CARGO_HOME/bin, $CARGO_HOME/.crates.toml, $CARGO_HOME/.crates2.json
      • CARGO_CACHE_DIR
        • $CARGO_CONFIG_DIR/git
        • $CARGO_CONFIG_DIR/registry
      • CARGO_CONFIG_DIR
        • $CARGO_CONFIG_DIR/config.toml
      • $CARGO_HOME/credentials?
        • People are less likely to scrutinize what they put in a .config git repo and could accidentally leak their credentials
  • poignardazur's blog post
    • Introduces:
      • CARGO_BIN_DIR?
        • Is there enough precedence for this?
        • cargo/rustup assumes complete control
      • CARGO_CACHE_DIR
      • CARGO_CONFIG_DIR
    • Update home to support these
    • Initially, these map back to existing locations
    • Transition plan
      • Initially, home crate will provide new functions that map to old locations
      • Next, support full precedence but fallback to old locations
      • Next, change fallback to new locations
    • macOS: Use app dirs, not XDG
    • Precedence
      • If CARGO_HOME is set
        • use that as the fallback for a CARGO_*_DIR not being set
        • Else use CARGO_HOME
      • Set CARGO_HOME to the old location
      • If CARGO_*_DIR is set, use that
      • If platform-specific dir exists, use that
      • Else use (depends on transition plan)
    • rustup runs through above and sets the variables
    • Rustup currently uses RUSTUP_HOME and defaults to $HOME/.rustup. It would need its own RUSTUP_CACHE_DIR and RUSTUP_CONFIG_DIR env variables. Presumably they would be set in a way consistent with CARGO_HOME and CARGO_***_DIR, but the code should not assume that this is the case.
  • epage
    • CARGO_CONFIG_DIR
      • Like git, read $CARGO_HOME/config.toml and $CARGO_CONFIG_DIR/config.toml (if different)
    • CARGO_CACHE_DIR
      • Hard split like git->sparse registry
        • Backup: transition plan like poignardazur
    • CARGO_BIN_DIR
      • Must be separate from CARGO_CACHE_DIR since users shouldn't be as free to delete this as CARGO_CACHE_DIR
      • Must take into account that rustup expects total control of this directory atm
    • Precedence
      • If CARGO_*_DIR is set, use that
      • If CARGO_HOME is set, use that
      • Else
        • Initially, these map to existing locations
        • Eventually, switch to OS-native paths
          • macOS: use XDG as that seems to be the stronger precedent for unix-y CLI tools
            • Recognizing not everyone will agree with this
            • Can use env variables to force OS-native behavior
    • Maybe cargo --print config-dir --print cache-dir for programmatic lookup
      • Meant to model rustc --print <item>
      • Alt: cargo config get
      • Alt: cargo dirs or cargo home
    • Rustup currently uses RUSTUP_HOME and defaults to $HOME/.rustup. It would need its own RUSTUP_CACHE_DIR and RUSTUP_CONFIG_DIR env variables. Presumably they would be set in a way consistent with CARGO_HOME and CARGO_***_DIR, but the code should not assume that this is the case.
    • These new variables would be prevented from being set in cargo config