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

Is there a simple way to install rusftmt 2.0 rc without building from source? #4582

Closed
doivosevic opened this issue Dec 9, 2020 · 8 comments

Comments

@doivosevic
Copy link

Hey!
I'm new to the rust ecosystem and would like to try out 2.0. Is there a simple way to install and then uninstall the 2.0 versions?
From what I see the nightly versions on cargo are 1.4.x as well

@doivosevic doivosevic added the bug Panic, non-idempotency, invalid code, etc. label Dec 9, 2020
@calebcartwright
Copy link
Member

hello @Kungitoo 👋 thanks for the question and welcome! 🦀

Is there a simple way to install rusftmt 2.0 rc without building from source?

No there's not. The primary distribution channel for rustfmt is via rustup and the associated rust releases.

https://github.com/rust-lang/rustfmt#installing-from-source

rustfmt is also available on crates.io (though it's several versions behind the latest version available via rustup), but there's really not must of a difference in the experience between installing from crates.io vs. installing from source: both involve building and both utilize the cargo install ...

Is there a simple way to install and then uninstall the 2.0 versions?

Think the installation bit was covered above, and cargo uninstall can be used to uninstall both an install from source or crates.io

Also regarding your question from #4437 (comment)

can we know if 2.0 is planned for 2020 or is there a roadmap somewhere?

We were actually ready to ship the 2.0 release back in the spring, but as we were starting that process there were various concerns and objections about having a breaking/2.0 release for an official tool that ships with the main Rust distribution (which itself is on a 1.x version).

There definitely won't be a 2.0 release in 2020, and long term I'm honestly not sure what the plan is going to be. It's entirely plausible we may never be able to do so, or at least not until there's a hypothetical 2.0 release of Rust, due to the combination of how seriously Rust takes stability and rustfmt's own stability guarantee.

Here was the original milestone we had tracking the 2.0 release:
https://github.com/rust-lang/rustfmt/milestone/8

@calebcartwright calebcartwright removed the bug Panic, non-idempotency, invalid code, etc. label Dec 10, 2020
@doivosevic
Copy link
Author

Could you release 2.0 version to be available under some flag? I know this would never pass, but could you bundle 2.0 code with the 1.x package and then when some flag is specified we use the 2.0 code which is completely separate so it doesn't interfere with the stable 1.x version?

@francis-du
Copy link

francis-du commented Dec 11, 2020

If you only need rust-fmt, you can build rustfmt feature from source code, and then replace it from toolchains.

  • Windows
set CFG_RELEASE=1.45.0-nightly <--(Specify yours)
set CFG_RELEASE_CHANNEL=nightly

cargo build --bin rustfmt --features="rustfmt"

cp debug\target\rust-fmt.exe C:\Users\Francis\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\bin
  • Linux/Mac
export CFG_RELEASE=1.45.0-nightly <--(Specify yours)
export CFG_RELEASE_CHANNEL=nightly

cargo build --bin rustfmt --features="rustfmt"

cp debug/target/rust-fmt ~/.rustup/toolchains/nightly-***/bin

It's mine

> cargo fmt --version
rustfmt 2.0.0-rc.2-beta (2ce75b11 2020-12-09)

@calebcartwright
Copy link
Member

Could you release 2.0 version to be available under some flag?

No. I appreciate your interest in the potential 2.0 version, but it's not released right now by design for the reasons I shared above and that's not going to change any time soon. If you want to use the unreleased version of rustfmt from the source control repository, then you're going to have to work with the source control repository in your local and/or CI environments.

Going to go ahead and close this given that the question has been answered, thanks again for reaching out!

@calebcartwright
Copy link
Member

@francis-du - I'd advise against mixing and matching different major versions of cargo fmt and rustfmt, but even if you decide you want to take that risk, note that it'd be easier to utilize the RUSTFMT environment variable to specify the custom path to the rustfmt binary instead of hacking up rustup managed directories.

https://github.com/rust-lang/rustfmt#running-cargo-fmt

Please be aware that there's substantial differences in the 2.x version of rustfmt that the 1.x version of cargo fmt doesn't necessarily work with, notably, rustfmt 2.x is not recursive by default so if you run cargo fmt 1.x it will result in only the entry point files for the respective targets in your projects being formatted (main.rs, lib.rs, build.rs, etc.); all other files would be ignored unless you change your invocation to cargo fmt -- --recursive

@francis-du
Copy link

@calebcartwright Thanks for reminding : )

@calebcartwright
Copy link
Member

@calebcartwright Thanks for reminding : )

Sure thing, thanks for sharing your findings!

@csnover
Copy link

csnover commented Dec 14, 2020

There definitely won't be a 2.0 release in 2020, and long term I'm honestly not sure what the plan is going to be. It's entirely plausible we may never be able to do so, or at least not until there's a hypothetical 2.0 release of Rust

If rustfmt 2 is not going to be released, what does that mean for the added configuration options which were stabilised only in 2.0? Are those stabilisations going to get backported? Is there a blog or discussion thread somewhere with more insight into what is going to be happening instead? I’d been holding off for an official v2 release to formally adopt rustfmt in a project I have been working on, so it would be nice to get a sense of what the plan is. A quick search did not surface anything about this on rust-internals or rust-users forums. 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

4 participants