Skip to content

./x test ui -- --help requires an additional -- when going through ./x in PowerShell (msvc) #140157

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

Closed
jieyouxu opened this issue Apr 22, 2025 · 5 comments
Labels
C-bug Category: This is a bug. O-windows-msvc Toolchain: MSVC, Operating system: Windows T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Comments

@jieyouxu
Copy link
Member

On Windows MSVC + PowerShell,

# Unix
$ ./x test tests/ui/ -- --n

requires an additional --

# PowerShell
$ ./x test tests/ui/ -- -- --n

Not a huge deal, just a papercut. Probably has to do with ./x.ps1 or sth treating -- as its own arg separator.

This isn't a problem if x.py is directly invoked via python, i.e.

$ python x.py -- --help

works the same on Unix / MSVC.

@jieyouxu jieyouxu added C-bug Category: This is a bug. O-windows-msvc Toolchain: MSVC, Operating system: Windows T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Apr 22, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 22, 2025
@jieyouxu jieyouxu removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 22, 2025
@jieyouxu jieyouxu changed the title ./x test ui -- --helprequires an additional -- when going through ./x in PowerShell (msvc) ./x test ui -- --help requires an additional -- when going through ./x in PowerShell (msvc) Apr 22, 2025
@ChrisDenton
Copy link
Member

The problem is our use of the $args magic variable that will process and remove -- before the script ever sees it:

rust/x.ps1

Line 11 in 6bc57c6

$xpy_args = @($xpy) + $args

This could be fixed by passing on the raw arguments instead of using the $args magic variable. jyn514 suggested $MyInvocation could be used for this.

E.g. $MyInvocation.Statement will get the raw command line and then $MyInvocation.InvocationName can be used to replace the script path with the path to x.py.

@ChrisDenton
Copy link
Member

Oh wait this is harder than I thought if we want to handle all edge cases. E.g. if the user does something like this:

& <# this is a comment #> "./x.p*" --help

Then parsing where the arguments gets much more complicated.

@ChrisDenton
Copy link
Member

Ok, I don't think we can or should attempt to parse arbitrary powershell syntax. So this might need to be closed as can't fix (unless powershell provides a proper way to get the raw arguments including --).

Users can workaround it by escaping the --:

./x test tests/ui/ `-- --n

That's not ideal, admittedly.

@jieyouxu
Copy link
Member Author

Yeah, it's not a big deal

@jieyouxu jieyouxu closed this as not planned Won't fix, can't repro, duplicate, stale Apr 22, 2025
@jyn514
Copy link
Member

jyn514 commented May 2, 2025

one possible workaround would be to use a batch file instead of powershell. but. that kinda sucks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. O-windows-msvc Toolchain: MSVC, Operating system: Windows T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

No branches or pull requests

4 participants