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 not properly escaping quotes in Windows command lines #1661

Closed
analogrelay opened this issue May 29, 2015 · 7 comments
Closed

Cargo not properly escaping quotes in Windows command lines #1661

analogrelay opened this issue May 29, 2015 · 7 comments

Comments

@analogrelay
Copy link

I'm getting an error when trying to build code that depends on the libc crate in cargo:

   Compiling libc v0.1.8
     Running `rustc C:\Users\Andrew\.cargo\registry\src\github.com-1ecc6299db9ec823\libc-0.1.8\rust/src/liblibc/lib.rs --crate-name libc --crate-type lib -g --cfg feature="cargo-build" --cfg feature="default" -C metadata=2eda841eb12a3090 -C extra-filename=-2eda841eb12a3090 --out-dir C:\Users\Andrew\Code\anurse\cargo-bug-repro\doesnotwork\target\debug\deps --emit=dep-info,link -L dependency=C:\Users\Andrew\Code\anurse\cargo-bug-repro\doesnotwork\target\debug\deps -L dependency=C:\Users\Andrew\Code\anurse\cargo-bug-repro\doesnotwork\target\debug\deps -Awarnings`
cfgspec:1:9: 1:14 error: unexpected token: `cargo`
cfgspec:1 feature=cargo-build
                  ^~~~~
Could not compile `libc`.

Caused by:
  Process didn't exit successfully: `rustc C:\Users\Andrew\.cargo\registry\src\github.com-1ecc6299db9ec823\libc-0.1.8\rust/src/liblibc/lib.rs --crate-name libc --crate-type lib -g --cfg feature="cargo-build" --cfg feature="default" -C metadata=2eda841eb12a3090 -C extra-filename=-2eda841eb12a3090 --out-dir C:\Users\Andrew\Code\anurse\cargo-bug-repro\doesnotwork\target\debug\deps --emit=dep-info,link -L dependency=C:\Users\Andrew\Code\anurse\cargo-bug-repro\doesnotwork\target\debug\deps -L dependency=C:\Users\Andrew\Code\anurse\cargo-bug-repro\doesnotwork\target\debug\deps -Awarnings` (exit code: 101)

I have a small repro project at https://github.com/anurse/cargo-bug-repro, to repro this bug just do the following on a Windows machine:

  1. Install latest rust and cargo nightlies (I have rustc 1.2.0-nightly (f76d9bcfc 2015-05-28) and cargo 0.2.0-nightly (ac61996 2015-05-17))
  2. Clone the repo referenced above and cd to doesnotwork OR create a new binary crate that depends upon the libc crate
  3. cargo build

It looks like cargo is passing feature config switches to rustc, but the quotes are being stripped, probably by either the shell or the Windows command line parsing api CommandLineToArgvW (see also: http://blogs.msdn.com/b/oldnewthing/archive/2010/09/17/10063629.aspx).

Obviously, this would likely repro in any crate that uses features, but libc is where I saw it.

@alexcrichton
Copy link
Member

Hm, this is quite surprising! We've got Cargo builds working all the time on Windows, many of which depend on libc. Where are you running cargo from? (e.g. PowerShell, cmd.exe, MSYS2 bash, etc).

@analogrelay
Copy link
Author

I tried in both PowerShell and cmd. Haven't tried msys2 bash but I can try that later

@alexcrichton
Copy link
Member

I'm also unable to reproduce this in either cmd.exe or PowerShell. Do you know if anything could possibly be intercepting calls to CreateProcess and may perhaps have a bug in it?

@analogrelay
Copy link
Author

It's certainly possible, thanks for trying to repro it. I'll try some things on different machines and see if I can narrow down the exact cause. I'm using Windows 10 Preview (I realize you probably don't "officially" support that yet ;)), so it's possible there's something coming down that line that may break this, though I doubt it.

I've also got a fairly customized environment so it could be that something I'm doing is messing it up :).

I'll keep investigating and re-open this if I find anything further. Thanks again for your help!

@analogrelay
Copy link
Author

Finally got a chance to try this on a fresh machine and it does not repro. So it definitely looks like it's an issue on my machine. Thanks for your help!

@alexcrichton
Copy link
Member

No problem, thanks for investigating @anurse!

analogrelay added a commit to analogrelay/scoop-extras that referenced this issue May 30, 2015
* remove separate cargo manifest, cargo is built in now

* rust really doesn't like running through a shim, so use env_add_path instead (see rust-lang/cargo#1661)
@analogrelay
Copy link
Author

To circle back for anyone arriving via a search: The issue was with the Windows package manager I use (Scoop). I submitted a PR there to see if I could fix their rust-nightly package: ScoopInstaller/Extras#98

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