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

The rust plugin ignores environment variables #4023

Closed
jdx opened this issue Jan 9, 2025 Discussed in #4022 · 0 comments · Fixed by #4026
Closed

The rust plugin ignores environment variables #4023

jdx opened this issue Jan 9, 2025 Discussed in #4022 · 0 comments · Fixed by #4026

Comments

@jdx
Copy link
Owner

jdx commented Jan 9, 2025

Discussed in #4022

Originally posted by hqnna January 9, 2025
Unlike other plugins such as the Go plugin which respects environment variables, the Rust plugin for Mise seems to completely ignore if the CARGO_HOME and RUSTUP_HOME environment variables are set in the shell's environment, the code for this can be seen here.

fn rustup_home() -> PathBuf {
    SETTINGS
        .rust
        .rustup_home
        .clone()
        .unwrap_or(dirs::HOME.join(".rustup"))
}

fn cargo_home() -> PathBuf {
    SETTINGS
        .rust
        .cargo_home
        .clone()
        .unwrap_or(dirs::HOME.join(".cargo"))
}

While the ability to set these paths via the Mise configuration file is nice, having it blatantly ignore the environment seems like a poor choice. A good example of why this would be bad is environment configurations that respect the XDG standard, such as my own.

# XDG Standard Directories
export XDG_DATA_HOME="$HOME/.local/share"
export XDG_STATE_HOME="$HOME/.local/state"
export XDG_CONFIG_HOME="$HOME/.config"
export XDG_CACHE_HOME="$HOME/.cache"

# Software Directory Paths
export NPM_CONFIG_USERCONFIG="$XDG_CONFIG_HOME/npm/npmrc"
export NODE_REPL_HISTORY="$XDG_STATE_HOME/node_history"
export SQLITE_HISTORY="$XDG_STATE_HOME/sqlite_history"
export LESSHISTFILE="$XDG_STATE_HOME/less_history"
export MISE_CONFIG_DIR="$XDG_CONFIG_HOME/mise"
export CUDA_CACHE_PATH="$XDG_CACHE_HOME/nv"
export CARGO_HOME="$XDG_DATA_HOME/cargo"
export GNUPGHOME="$XDG_DATA_HOME/gnupg"
export GOPATH="$XDG_DATA_HOME/golang"

I'm proposing to by default detect the environment variables RUSTUP_HOME and CARGO_HOME from the shell environment, and if not set in the environment fallback to Mise's own configuration file allowing both to be possible and respect shell environment setups.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant