Description of the issue
Description: When .cargo/config.toml uses the include directive to pull in another TOML file, any [env] variables defined in that included file are not set when nextest runs tests. The same variables work correctly with cargo test.
Steps to reproduce:
-
Create .cargo/config.toml:
include = ["include.toml"]
[env]
DIRECT = "direct"
-
Create .cargo/include.toml:
[env]
INCLUDE = "include"
-
Add tests that read both variables at runtime:
#[test]
fn env_from_config_toml_direct() {
// DIRECT is set in [env] inside .cargo/config.toml itself
assert_eq!(&std::env::var("DIRECT").unwrap(), "direct");
}
#[test]
fn env_from_included_toml() {
// INCLUDE is set in [env] inside .cargo/include.toml, pulled in via
// `include = ["include.toml"]` at the top of .cargo/config.toml
assert_eq!(&std::env::var("INCLUDE").unwrap(), "include");
}
-
Run cargo test → all tests pass
-
Run cargo nextest run → env_from_included_toml fails, env_from_config_toml_direct passes
Expected outcome
Both DIRECT and AFF should be set when nextest runs tests, since cargo itself resolves the include directive and both variables are visible to cargo test.
Actual result
cargo nextest run passes DIRECT (from the [env] section in config.toml directly) but does not pass INCLUDE (from the [env] section in the included file):
Starting 3 tests across 1 binary
PASS [ 0.006s] (1/3) aff2 tests::it_works
PASS [ 0.006s] (2/3) aff2 tests::env_from_config_toml_direct
FAIL [ 0.007s] (3/3) aff2 tests::env_from_included_toml
stderr ───
thread 'tests::env_from_included_toml' panicked at src/lib.rs:19:42:
called `Result::unwrap()` on an `Err` value: NotPresent
cargo test passes all three tests without issue.
Nextest version
cargo-nextest 0.9.140 (a9fef2964 2026-07-05)
release: 0.9.140
commit-hash: a9fef2964e34f64ed4fceeee7c0c3559ce560920
commit-date: 2026-07-05
host: x86_64-unknown-linux-gnu
Additional context
The motivation for using include here is to separate the env variables that are system-dependent and auto-generated (produced by a environment setup step). Keeping them in a separate file allows the generated file to be included without modifying the checked-in config.toml.
Description of the issue
Description: When
.cargo/config.tomluses theincludedirective to pull in another TOML file, any[env]variables defined in that included file are not set when nextest runs tests. The same variables work correctly withcargo test.Steps to reproduce:
Create
.cargo/config.toml:Create
.cargo/include.toml:Add tests that read both variables at runtime:
Run
cargo test→ all tests passRun
cargo nextest run→env_from_included_tomlfails,env_from_config_toml_directpassesExpected outcome
Both
DIRECTandAFFshould be set when nextest runs tests, since cargo itself resolves theincludedirective and both variables are visible tocargo test.Actual result
cargo nextest runpassesDIRECT(from the[env]section inconfig.tomldirectly) but does not passINCLUDE(from the[env]section in the included file):cargo testpasses all three tests without issue.Nextest version
Additional context
The motivation for using
includehere is to separate the env variables that are system-dependent and auto-generated (produced by a environment setup step). Keeping them in a separate file allows the generated file to be included without modifying the checked-inconfig.toml.