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

Installation of 2.0 RC fails / is surprisingly challenging #5107

Closed
bluenote10 opened this issue Nov 23, 2021 · 2 comments
Closed

Installation of 2.0 RC fails / is surprisingly challenging #5107

bluenote10 opened this issue Nov 23, 2021 · 2 comments

Comments

@bluenote10
Copy link
Contributor

I'm trying to install the latest version of the 2.0 release candidate, but I'm running into quite some challenges. After a while of experimenting I've arrived at:

rustup toolchain install nightly-2021-04-26 --profile minimal

CFG_RELEASE=nightly rustup run nightly-2021-04-26 \
    cargo install rustfmt-nightly \
    --git https://github.com/rust-lang/rustfmt \
    --rev cc5521d9b2fff696a852454dd2aa89e7942464dd \
    --features rustfmt cargo-fmt rustfmt-format-diff

I was hoping this should work because:

Unfortunately I'm facing a number of issues:

  • I had to setup the nightly-2021-04-26 toolchain with --profile minimal because otherwise there was a rustfmt related error during the toolchain setup.
  • Without exporting a CFG_RELEASE variable the build fails, and digging through the repo indicated that I need a value of "nightly".
  • Without specifying any features, the installation fails due to lack of binaries to install.
  • Even with the features specified the install only succeeds for rustfmt but fails for the other binaries. Specifically I'm now stuck at this error:
    Replaced package `rustfmt-nightly v1.4.38 (https://github.com/rust-lang/rustfmt?rev=826eba8984690b7c23aab8604b6a85587bb93edb#826eba89)` with `rustfmt-nightly v2.0.0-rc.2 (https://github.com/rust-lang/rustfmt?rev=cc5521d9b2fff696a852454dd2aa89e7942464dd#cc5521d9)` (executables `cargo-fmt`, `git-rustfmt`, `rustfmt-format-diff`)
    Replaced package `rustfmt-nightly v2.0.0-rc.2 (https://github.com/rust-lang/rustfmt?rev=cc5521d9b2fff696a852454dd2aa89e7942464dd#cc5521d9)` with `rustfmt-nightly v2.0.0-rc.2 (https://github.com/rust-lang/rustfmt?rev=cc5521d9b2fff696a852454dd2aa89e7942464dd#cc5521d9)` (executable `rustfmt`)
    Updating git repository `https://github.com/rust-lang/rustfmt`
error: could not find `cargo-fmt` in https://github.com/rust-lang/rustfmt?rev=cc5521d9b2fff696a852454dd2aa89e7942464dd with version `*`
    Updating git repository `https://github.com/rust-lang/rustfmt`
error: could not find `rustfmt-format-diff` in https://github.com/rust-lang/rustfmt?rev=cc5521d9b2fff696a852454dd2aa89e7942464dd with version `*`
     Summary Successfully installed rustfmt-nightly! Failed to install cargo-fmt, rustfmt-format-diff (see error(s) above).
error: some crates failed to install

Is this an issue that I can fix on my side or is there something broken on that branch?

@calebcartwright
Copy link
Member

Thanks for your question! There's a lot to unpack here, and that includes several items that aren't actually related to rustfmt. My tl;dr response would be that I'd advise against trying to build and use the 2.0 version from source because a 2.0 release is definitely not going to happen any time soon, and it's increasingly unlikely that there will ever be a major/breaking release of an official tool outside a holistic major/breaking release of Rust (and the rest of the official tooling).

More broadly,

If you are going to try to build rustfmt from source, especially on different branches, be sure to review the documentation on the respective branch, e.g. the instructions for installing rustfmt from source on that branch can be found in https://github.com/rust-lang/rustfmt/tree/rustfmt-2.0.0-rc.2#installing-from-source

I had to setup the nightly-2021-04-26 toolchain with --profile minimal because otherwise there was a rustfmt related error during the toolchain setup.

This is a feature of rustup and is applicable for any and all toolchains that are missing any components (not just rustfmt) which you had installed with other toolchains. You can use the --force option to tell rustup to grab the toolchain-with-some-missing-components anyway, but that's not at all related to rustfmt (much less a specific branch of rustfmt)

Without exporting a CFG_RELEASE variable the build fails, and digging through the repo indicated that I need a value of "nightly".

This is an attribute of the compiler internals (rustfmt uses some of rustc's internal modules). It's a pain but was never anything that we had any control over. I do feel like it was covered pretty thoroughly in the install instructions on that branch though

Without specifying any features, the installation fails due to lack of binaries to install.

Same story here where I feel like this was detailed in the install instructions. By any chance were you trying to install based on docs on the master/1.x branch?

Even with the features specified the install only succeeds for rustfmt but fails for the other binaries. Specifically I'm now stuck at this error:

Can't say I've seen that before. I'd suggest trying to uninstall your prior manual install, and then follow the 2.0 installation instructions if you still really want to.


Please feel free to follow up with any additional comments/questions/observations/etc., but I am going to go ahead and close this issue. That's due to the strategy outlined above and an acknowledgement of the fact that we aren't in a position to take action nor provide additional troubleshooting around installations from a source branch that's bordering on dead.

@bluenote10
Copy link
Contributor Author

bluenote10 commented Nov 24, 2021

@calebcartwright Thanks a lot for that detailed explanation!

My tl;dr response would be that I'd advise against trying to build and use the 2.0 version from source

The problem is that we have projects that must rely on unstable features. In particular, the decision was to use rustfmt only if it is possible to have blank_lines_upper_bound = 2 (#3381) in these projects. So even if 2.0 may never happen, at this point in time it is the best option to not lose our formattings, hopefully bridging the gap until some of the features get stabilized.

The goal now was to find a way to run 2.0 reliably in CI jobs. The approach with cargo make seems to do the job, thanks!

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