We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
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
I'm not 100% sure of what I am looking at, so feel free to close. Does cargo support expanding env vars when setting --target-dir or CARGO_TARGET_DIR?
--target-dir
CARGO_TARGET_DIR
I am using
$ cargo --version cargo 1.87.0 (99624be96 2025-05-06)
and this is my ~/.cargo/config.toml
~/.cargo/config.toml
[build] target-dir = "$HOME/.cargo/target" # or # target-dir = "~/.cargo/target"
Both variants seems to be ignored, same if I use the CLI option --target-dir or the corresponding CARGO_TARGET_DIR env var.
I've added a small test to cargo to verify my assumption:
#[cargo_test] fn cargo_target_dir_env_var() { write_config_toml( "\ [build] target-dir = \"$HOME/.cargo/target\" ", ); let gctx = new_gctx(); assert_eq!( gctx.target_dir().unwrap(), Some(Filesystem::new("/home/my-user/.cargo/target".into())) ); }
and it fails with this error:
assertion `left == right` failed left: Some(Filesystem { root: "/home/my-user/$HOME/.cargo/target/tmp/cit/t0/$HOME/.cargo/target" }) right: Some(Filesystem { root: "/home/my-user/.cargo/target" })
Am I doing something wrong?
Thanks!
The text was updated successfully, but these errors were encountered:
Cargo does not support environment variable or ~ expansion.
~
In #14125, we're tracking the creation of a build-dir (all intermediate artifacts) and have some built-in variables that can be used, like {cargo-cache-home}. See https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#build-dir
build-dir
{cargo-cache-home}
Would that fit your needs?
Sorry, something went wrong.
Variable expansions are also discussed here #10789
ah great thanks for the superquick reply :) For some reason I didn't find the relevant issue
Closing this as duplicate. I'll subscribe to (and maybe also test) #14125
No branches or pull requests
I'm not 100% sure of what I am looking at, so feel free to close.
Does cargo support expanding env vars when setting
--target-dir
orCARGO_TARGET_DIR
?I am using
and this is my
~/.cargo/config.toml
Both variants seems to be ignored, same if I use the CLI option
--target-dir
or the corresponding CARGO_TARGET_DIR env var.I've added a small test to cargo to verify my assumption:
Details
and it fails with this error:
Am I doing something wrong?
Thanks!
The text was updated successfully, but these errors were encountered: