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

[Cargo run] passing arguments to the binary works unexpectedly #2213

Closed
JanLikar opened this issue Dec 16, 2015 · 6 comments · Fixed by #5429
Closed

[Cargo run] passing arguments to the binary works unexpectedly #2213

JanLikar opened this issue Dec 16, 2015 · 6 comments · Fixed by #5429
Labels

Comments

@JanLikar
Copy link
Contributor

I'm trying to pass arguments to a binary that then passes arguments after -- to another binary.

`jan@hp:~/Projekti/rustfmt$ cargo run --bin cargo-fmt -- -- --write-mode=diff
Running `target/debug/cargo-fmt --write-mode=diff`

I would expect cargo to run target/debug/cargo-fmt -- --write-mode

@alexcrichton
Copy link
Member

Huh, I thought this was a fixed bug...

cc @BurntSushi

@BurntSushi
Copy link
Member

I would have thought so too given this test. There might be something else going on with two uses of --. I'll dig into this soon.

@JanLikar
Copy link
Contributor Author

I have additional info: If a flag is passed to both binaries, it works just as expected, if a flag is passed only to the "final" binary, it doesn't work.

@carols10cents
Copy link
Member

Triage: this is still a problem as far as I can tell.

 $ cargo new --bin foo
     Created binary (application) `foo` project
$ cd foo/
$ mkdir src/bin
$ mv src/main.rs src/bin/
$ cargo run --bin main  -- -- --write-mode=diff
    Finished dev [unoptimized + debuginfo] target(s) in 0.0 secs
     Running `target/debug/main --write-mode=diff`

and the last line should instead say:

     Running `target/debug/main -- --write-mode=diff`

@carols10cents carols10cents modified the milestone: impl period Sep 12, 2017
@arcuru
Copy link

arcuru commented Apr 28, 2018

This appears to be fixed in the latest nightly but not yet in stable.

Using @carols10cents repro steps:

$ cargo --version
cargo 0.26.0 (41480f5cc 2018-02-26)
$ cargo run --bin main  -- -- --write-mode=diff
    Finished dev [unoptimized + debuginfo] target(s) in 0.0 secs
      Running `target/debug/main --write-mode=diff`
$ rustup default nightly
$ cargo --version
cargo 1.27.0-nightly (0a1add2d8 2018-04-20)
$ cargo run --bin main  -- -- --write-mode=diff
    Finished dev [unoptimized + debuginfo] target(s) in 0.0 secs
      Running `target/debug/main -- --write-mode=diff`

bors added a commit that referenced this issue Apr 28, 2018
Extend dashes forwarding test

Closes #2213

Looks like this was fixed when we've transitioned to clap!
@matklad
Copy link
Member

matklad commented Apr 28, 2018

@patricksjackson indeed!

I've added a test for this in #5429

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants