Rust-analyzer VSCode How to pass args to "Run" but not "Test" / "Tests"

I am using VSCode 1.63.2 and Rust-analyzer updated 1/11/2022.

I want to pass command line arguments to the RA's "Run" shortcut.

But I don't want to pass them to RA's "Tests" shortcut. When I do I get the following error

error: Found argument 'poem.txt' which wasn't expected, or isn't valid in this context

    cargo test --lib --package <SPEC>...

For more information try --help
The terminal process "cargo 'test', '--package', 'minigrep2', '--lib', 'the', 'poem.txt', '--', 'tests::it_works', '--exact', '--nocapture'" failed to launch (exit code: 1).

My local settings.json looks like this:

    "rust-analyzer.runnableEnv": {
        "RUST_LOG": "info"
    "rust-analyzer.runnables.cargoExtraArgs": ["the", "poem.txt"]

Is there a way to tell RA to separate the settings for "Run" and "Tests/Test"?

There is currently no such configuration yet that allows you to pass different args to run and test.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.