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

doc: fix instruction about running Rustfmt from source code #5838

Merged
merged 3 commits into from
Jul 19, 2023

Conversation

xxchan
Copy link
Contributor

@xxchan xxchan commented Jul 17, 2023

cargo-fmt uses rustfmt from PATH, so cargo run --bin cargo-fmt still uses installed rustfmt instead of built one.

@xxchan
Copy link
Contributor Author

xxchan commented Jul 17, 2023

I also tried RUSTFMT="..." cargo fmt directly, but it usually leads to dyld[19277]: Library not loaded: @rpath/librustc_driver-85e0fbb5b589cfca.dylib

I'm not sure what's the most idiomatic way you usually do @calebcartwright

@ytmimi
Copy link
Contributor

ytmimi commented Jul 17, 2023

Thanks for the PR, but the current recommendation of running rustfmt with cargo run --bin cargo-fmt or cargo run --bin rustfmt is correct.

@ytmimi ytmimi closed this Jul 17, 2023
@ytmimi
Copy link
Contributor

ytmimi commented Jul 17, 2023

Maybe I was too quick to close this. We probably want to update the recommendation to say cargo run --bin rustfmt instead of cargo run --bin cargo-fmt.

Also, @xxchan dyld[19277]: Library not loaded: @rpath/librustc_driver-85e0fbb5b589cfca.dylib is related to #5675, and that's partially why we recommend using cargo run to run rustfmt from source while you're developing rustfmt.

@ytmimi ytmimi reopened this Jul 17, 2023
@xxchan
Copy link
Contributor Author

xxchan commented Jul 17, 2023

I know cargo run --bin rustfmt works, but I do need a way to run cargo fmt with compiled rustfmt.

@xxchan
Copy link
Contributor Author

xxchan commented Jul 17, 2023

Also, @xxchan dyld[19277]: Library not loaded: @rpath/librustc_driver-85e0fbb5b589cfca.dylib is related to #5675, and that's partially why we recommend using cargo run to run rustfmt from source while you're developing rustfmt

This is also why I wanted to install rustfmt and run cargo +nightly-x fmt.. #5755

@ytmimi
Copy link
Contributor

ytmimi commented Jul 17, 2023

Got it. Assuming the user hasn't compiled rustfmt maybe we want to add that as an extra step in the instructions or change the command to:

cargo build -bin rustfmt && RUSTFMT="./target/debug/rustfmt" cargo run --bin cargo-fmt -- --manifest-path path/to/project/you/want2test/Cargo.toml

@xxchan
Copy link
Contributor Author

xxchan commented Jul 17, 2023

Added the build step, and also mentioned cargo run --bin rustfmt

@ytmimi
Copy link
Contributor

ytmimi commented Jul 17, 2023

@xxchan I think you pushed to wrong branch by accident. I'm seeing those changes applied to #5839

@xxchan
Copy link
Contributor Author

xxchan commented Jul 17, 2023

Yes 🤣

Contributing.md Outdated

```
cargo run --bin cargo-fmt -- --manifest-path path/to/project/you/want2test/Cargo.toml
cargo build --bin rustfmt && RUSTFMT="./target/debug/rustfmt" cargo run --bin cargo-fmt -- --manifest-path path/to/project/you/want2test/Cargo.toml
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with this as is (I have run into the current non-ideal behavior myself on occasion, but I haven't heard of anyone else doing so while developing rustfmt)

However, this line is starting to get a bit long. What if we went with the one-liner as your original proposal and just included a note above or below (something to the effect of "you may need to build rustfmt first)"

The audience for these docs are strictly rustfmt developers, and I'm content structuring the docs under the assumption they already know/can easily determine this is one binary invoking another and that a build might be involved

Copy link
Contributor

@ytmimi ytmimi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xxchan thanks for helping to improve the docs. If you could rebase on the current master I can go ahead and merge.

`cargo-fmt` uses `rustfmt` from `PATH`, so `cargo run --bin cargo-fmt` still uses installed `rustfmt` instead of built one.
@ytmimi
Copy link
Contributor

ytmimi commented Jul 19, 2023

@xxchan If possible could you squash these into a single commit.

@calebcartwright
Copy link
Member

Agreed they should be squashed @ytmimi though just want to note we can also do that on behalf of contributors as part of the merge strategy:

image

@ytmimi
Copy link
Contributor

ytmimi commented Jul 19, 2023

@calebcartwright appreciate you pointing that out. I knew we had that capability. I asked to give @xxchan the opportunity to squash the commits themselves and amend the commit message if they'd like to before merging

@xxchan
Copy link
Contributor Author

xxchan commented Jul 19, 2023 via email

@ytmimi ytmimi merged commit c6d39a2 into rust-lang:master Jul 19, 2023
8 checks passed
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

Successfully merging this pull request may close these issues.

3 participants