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

tidy tries to run unrelated x binary #106469

Closed
ehuss opened this issue Jan 4, 2023 · 7 comments
Closed

tidy tries to run unrelated x binary #106469

ehuss opened this issue Jan 4, 2023 · 7 comments
Labels
A-testsuite Area: The testsuite used to check the correctness of rustc C-bug Category: This is a bug. regression-untriaged Untriaged performance or correctness regression. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Comments

@ehuss
Copy link
Contributor

ehuss commented Jan 4, 2023

Starting with #104552, ./x.py test tidy fails on my system:

thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: Error("unexpected character 'H' while parsing major version number")', src/tools/tidy/src/x_version.rs:36:58

I have an executable installed on my system called x that is unrelated to rust. I would prefer if tidy didn't execute it at all.

@ehuss ehuss added the C-bug Category: This is a bug. label Jan 4, 2023
@jyn514
Copy link
Member

jyn514 commented Jan 4, 2023

Hmm, that's unfortunate, I didn't realize this was a name that was already being used :(

cc @DebugSteven, we might have to revert that PR :/

@ehuss would it be ok if we only ran your x command and silently hid the error, so nothing ends up happening? Or does even that cause issues?

@jyn514 jyn514 changed the title tidy fails with unexpected character tidy tried to run unrelated x binary Jan 4, 2023
@jyn514 jyn514 changed the title tidy tried to run unrelated x binary tidy tries to run unrelated x binary Jan 4, 2023
@jyn514 jyn514 added A-testsuite Area: The testsuite used to check the correctness of rustc T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Jan 4, 2023
@Mark-Simulacrum
Copy link
Member

We can probably check that the binary is in ~/.cargo/bin or so before running it, at least. We can probably also add a custom section to it or other content that we can find without running it (e.g., by reading the contents and looking for a well known version).

I seem to recall cargo tracking installed versions too, maybe we can lean on that?

@jyn514
Copy link
Member

jyn514 commented Jan 4, 2023

I seem to recall cargo tracking installed versions too, maybe we can lean on that?

Oh, that's an excellent idea! yes, cargo install --list will output something like

x v0.1.0 (/home/gh-jyn514/rust3/src/tools/x):
    x

and we can only run x if we see src/tools/x in the output.

A debug section seems slightly overkill but I'm not opposed if you think cargo install --list will be unreliable for whatever reason; I suppose PATH could be in the wrong order or something like that.

@jyn514 jyn514 added the regression-untriaged Untriaged performance or correctness regression. label Jan 4, 2023
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Jan 4, 2023
@Mark-Simulacrum
Copy link
Member

I think my point is that if we're diligent about bumping the cargo.toml version we don't ever need to run it, just look at Cargo output.

@ehuss
Copy link
Contributor Author

ehuss commented Jan 5, 2023

I think for me it might be OK to ignore any errors running the command or any parsing errors on the output.

cargo install --list isn't intended to be machine-readable, but is also an option that could work.

Opening the executable and searching for a unique sequence of bytes that precedes the version number is also an option, but possibly a bit of a hassle. (Or it could look for some unique string that identifies it as the x.py wrapper, and then execute it.)

Any option is fine, and there's no urgency here unless it affects other people.

@Ezrashaw
Copy link
Contributor

Ezrashaw commented Jan 5, 2023

I really don't like the idea of just running a arbitrary binary, even if it appears in cargo install --list. On my system, the command X (note that it is a capital but this is too close for comfort) runs X11.

Perhaps the check can be moved into bootstrap (or anywhere out of tidy) so that it can know its version without running binaries? IMO, tidy is more about linting code; it shouldn't emit an error if a user has an old version of an optional and unessential tool.

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jan 12, 2023
…er-x, r=jyn514

Revert "warn newer available version of the x tool"

Reverts rust-lang#104552

Running the x executable directly created an [issue](rust-lang#106469) here. There are other options for warning a user that a newer version of x exists in the issue's discussion as well.

r? `@jyn514`
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Jan 12, 2023
…er-x, r=jyn514

Revert "warn newer available version of the x tool"

Reverts rust-lang#104552

Running the x executable directly created an [issue](rust-lang#106469) here. There are other options for warning a user that a newer version of x exists in the issue's discussion as well.

r? ``@jyn514``
compiler-errors added a commit to compiler-errors/rust that referenced this issue Jan 21, 2023
…=albertlarsan68

check for x version updates

This PR adds a check to tidy to assert that the installed version of `x` is equal to the version in `src/tools/x/Cargo.toml`. It checks the installed version of `x` by parsing the output of `cargo install --list` (as an option proposed in this [issue](rust-lang#106469)).

It does not warn if `x` has not yet been installed, on the assumption that the user isn't interested in using it.
@jyn514
Copy link
Member

jyn514 commented Feb 5, 2023

This was fixed in #107048 :)

@jyn514 jyn514 closed this as completed Feb 5, 2023
@apiraino apiraino removed the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Feb 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-testsuite Area: The testsuite used to check the correctness of rustc C-bug Category: This is a bug. regression-untriaged Untriaged performance or correctness regression. 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

6 participants