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

Cannot set TARGET_*_RUNNER to a binary whose filename contains a whitespace #10892

Closed
RalfJung opened this issue Jul 23, 2022 · 10 comments
Closed

Comments

@RalfJung
Copy link
Member

Is it possible that when I set TARGET_*_RUNNER to a value like C:\Users\Good Game\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\bin\cargo-miri.exe, that cargo will split this at the whitespace and try to run the binary C:\Users\Good? That is my conclusion of what happens in rust-lang/miri#2417, which took me by surprise. After all, RUSTC_WRAPPER, RUSTC and RUSTDOC work fine when they contain whitespace. Only the runner variables seem to have this strange behavior.

Reading the docs more carefully now, this says "Type: string or array of strings". I guess that helps for when the variable is set via toml, but when I set this via the environment (which I think is our only choice here), then how do I configure a runner that is stored in a directory that contains a whitespace in its name? It looks like StringList (which I think is where this ends up?) interprets a single string as being separated at whitespaces, rather than interpreting it as a one-element list of strings.

@ehuss
Copy link
Contributor

ehuss commented Jul 23, 2022

I would recommend using the newly stabilized --config CLI option if possible. Otherwise, you cannot pass commands with spaces in them for CARGO_TARGET_<triple>_RUNNER.

@RalfJung
Copy link
Member Author

RalfJung commented Jul 23, 2022

--config? Sounds intriguing! Yes we could probably set that when invoking cargo run/test from cargo-miri. I'll look into it.

@RalfJung
Copy link
Member Author

RalfJung commented Jul 23, 2022

To make sure I understand correctly: would something like this

--config "target.'cfg(true)'.runner=['cargo-miri', 'runner']"

make cargo call cargo-miri runner ... to invoke all binaries?

How do quotes have to be escaped in the binary name? If I understand https://toml.io/en/v0.3.0 correctly, I should do the following:

  • replace all \ by \\ and all " by \"
  • and then surround the string in "

@ehuss
Copy link
Contributor

ehuss commented Jul 23, 2022

Depends on how you are launching cargo (whether it is from a shell script or from Rust).

Escaping \ and " should be sufficient, yea.

https://doc.rust-lang.org/nightly/cargo/reference/config.html#command-line-overrides gives some examples of different ways to escape things via shell.

@RalfJung
Copy link
Member Author

We are launching it from Rust.

@RalfJung
Copy link
Member Author

The cfg(true) does not seem to be working. Looks like I need to give the target explicitly.

I tried this on the terminal (in a random project, I used xargo):

cargo +nightly "run" "-v" "--target" "x86_64-unknown-linux-gnu" "--config" "target.'cfg(true)'.runner=[\"nonsense\", 'runx']"

and expected an error, but it actually works fine. If instead I do

cargo +nightly "run" "-v" "--target" "x86_64-unknown-linux-gnu" "--config" "target.x86_64-unknown-linux-gnu.runner=[\"nonsense\", 'runx']"

then I get the expected error.

@RalfJung
Copy link
Member Author

Also it looks like #8629 hasn't entirely fixed the issue in the PR description... when I pass "--config" "target.x86_64-unknown-linux-gnu.runner=[\"nonsense\", 'runx']" twice, it concatenates the two arrays!

@ehuss
Copy link
Contributor

ehuss commented Jul 23, 2022

true is never a truthy cfg expression. It's the same as saying cfg(foobar). I don't think there is a way to specify something unconditionally.

@RalfJung
Copy link
Member Author

Ah, that's a bummer, but you are right -- it doesn't work in rustc either.

But all() works in rustc, so maybe it works here, too... after all, universal quantification over the empty set is true. ;)

@RalfJung
Copy link
Member Author

Okay, this seems to be working. Thanks a lot. :D

I will close this issue, since the issue with setting a runner with spaces is resolved. I will open a new issue for what double---config.

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

No branches or pull requests

2 participants