Problem
RustRover and rust-analyzer do a two-step method to launch a debug session for the target binary:
cargo test --no-run (for rust-analyzer: https://github.com/rust-lang/rust-analyzer/blob/2cf14f4d34fd96fb763cfd9f909472a61145674a/editors/code/src/toolchain.ts#L54)
- execute the artifact by themselves.
But they don't set environment variables as cargo test does at the second step.
There are at least two kinds of environment variables that cargo sets:
- Dynamic library path (https://github.com/rust-lang/cargo/blob/2da24c9172cd638f63713aa191c9aff51c16f476/src/doc/src/reference/environment-variables.md#dynamic-library-paths)
- Environment variables from Cargo config (https://github.com/rust-lang/cargo/blob/2da24c9172cd638f63713aa191c9aff51c16f476/src/doc/src/reference/config.md#env)
- Accidential ones? (https://github.com/rust-lang/cargo/blob/2da24c9172cd638f63713aa191c9aff51c16f476/src/doc/src/reference/environment-variables.md#environment-variables-cargo-sets-for-crates)
rust-analyzer doesn't set all of them, while RustRover sets the 2. and (part of)3. (YouTrack issue)
I guess it's time to introduce a standard supporting mechanism for that?
Proposed Solution
some flags to print them (--print-info?)
{
"executable": ".../target/debug/deps/...",
"arguments": [ ... ],
"environment_variables": {
"FOO": "BAR",
"LD_LIBRARY_PATH": "...",
"CARGO_PKG_AUTHORS": "",
...
}
}
generate new message (when --message-format=json is used)
make some
impl<'a> Message for DryRun<'a> {
fn reason(&self) -> &str {
"dry-run"
}
}
and print this when --no-run is given?
{
"reason": "dry-run",
"executable": ".../target/debug/deps/...",
"arguments": [ ... ],
"environment_variables": {
"FOO": "BAR",
"LD_LIBRARY_PATH": "...",
"CARGO_PKG_AUTHORS": "",
...
}
}
Notes
No response
Problem
RustRover and rust-analyzer do a two-step method to launch a debug session for the target binary:
cargo test --no-run(for rust-analyzer: https://github.com/rust-lang/rust-analyzer/blob/2cf14f4d34fd96fb763cfd9f909472a61145674a/editors/code/src/toolchain.ts#L54)But they don't set environment variables as
cargo testdoes at the second step.There are at least two kinds of environment variables that
cargosets:rust-analyzer doesn't set all of them, while RustRover sets the 2. and (part of)3. (YouTrack issue)
I guess it's time to introduce a standard supporting mechanism for that?
Proposed Solution
some flags to print them (
--print-info?){ "executable": ".../target/debug/deps/...", "arguments": [ ... ], "environment_variables": { "FOO": "BAR", "LD_LIBRARY_PATH": "...", "CARGO_PKG_AUTHORS": "", ... } }generate new message (when
--message-format=jsonis used)make some
and print this when
--no-runis given?{ "reason": "dry-run", "executable": ".../target/debug/deps/...", "arguments": [ ... ], "environment_variables": { "FOO": "BAR", "LD_LIBRARY_PATH": "...", "CARGO_PKG_AUTHORS": "", ... } }Notes
No response