cargo-sort icon indicating copy to clipboard operation
cargo-sort copied to clipboard

Please tag a new stable release

Open sjackman opened this issue 2 years ago • 2 comments

The current stable release version 1.0.9 fails with this error message:

$ cargo install cargo-sort
…
$ cargo sort -w           
Checking rust...
Finished: Cargo.toml for "rust" has been rewritten
Checking mycrate...
thread 'main' panicked at /Users/shaun.jackman/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cargo-sort-1.0.9/src/sort.rs:113:46:
called `Result::unwrap()` on an `Err` value: TomlError { message: "TOML parse error at line 13, column 6\n   |\n13 | serde.workspace = true\n   |      ^\nUnexpected `.`\nExpected `=`\n" }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

and this issue is fixed on the current main branch. Please tag a new stable release. Thank you!

The workaround is to install cargo-sort from Git:

cargo install --git=https://github.com/DevinR528/cargo-sort --branch=main cargo-sort

sjackman avatar Dec 13 '23 17:12 sjackman

@DevinR528 This would be super helpful!

mlegner avatar Apr 19 '24 08:04 mlegner

Any progress on this? 👀

orhun avatar Jun 04 '24 19:06 orhun

Well, after merge: https://github.com/DevinR528/cargo-sort/pull/81 we can close the issue.

ikrivosheev avatar Nov 19 '24 21:11 ikrivosheev

@jplatte maybe it's time for new release after upgrade toml_edit?

ikrivosheev avatar Nov 19 '24 21:11 ikrivosheev

I read changelog toml_edit, I don't see any breaking changes for this crate: https://github.com/toml-rs/toml/blob/main/crates/toml_edit/CHANGELOG.md#0220---2024-02-05

ikrivosheev avatar Nov 19 '24 21:11 ikrivosheev

The upgrade of toml_edit you just did has nothing to do with why the release was yanked. I think it was related to the previous upgrade.

You already observed that running cargo sort on its own repository rewrites a three-line comment to a single line, right? That would need to be fixed before making another release. And I think there are more issues like that. If you are interested in working on fixing those, I can spend some time on creating test cases.

jplatte avatar Nov 19 '24 21:11 jplatte

The upgrade of toml_edit you just did has nothing to do with why the release was yanked. I think it was related to the previous upgrade.

You already observed that running cargo sort on its own repository rewrites a three-line comment to a single line, right? That would need to be fixed before making another release. And I think there are more issues like that. If you are interested in working on fixing those, I can spend some time on creating test cases.

Now I see. Yes, I'll help with the new release. I'll review current test cases and improve them.

If you have test cases it'll be great.

ikrivosheev avatar Nov 19 '24 22:11 ikrivosheev

Okay so good news: In Ruma, the project that originally spawned cargo-sort, there seems to be only one thing that regresses formatting with the latest version: A trailing comma on the last item of a multi-line arrays is removed. For the following input:

[package]
name = "cargo-sort-test"
version = "0.1.0"
edition = "2021"

[features]
default = [
    "feature-a",
    "feature-b",
    "feature-c",
    "feature-d",
    "feature-e",
]
feature-a = []
feature-b = []
feature-c = []
feature-d = []
feature-e = []

the latest cargo sort from main will remove the comma in "feature-e",, whereas v1.0.9 will leave it as-is.

If that bug and the one with cargo sorts own multiline comment are fixed, I'm happy to publish another release :)

jplatte avatar Nov 19 '24 22:11 jplatte

Hi @jplatte, Please Publish it. Because Taplo, like cargo-sort, also uses the Toml crate library, Taplo can format a toml file as you expect. If using cargo-sort doesn't meet your expectations, you can use Taplo to process it again without delaying any work at all.

image

Here is the code slice processed by cargo- sort:

[workspace.package]
homepage = "https://github.com/toml-rs/toml"
repository = "https://github.com/toml-rs/toml"
license = "MIT OR Apache-2.0"
edition = "2021"
rust-version = "1.65" # MSRV
include = ["build.rs", "src/**/*", "Cargo.toml", "Cargo.lock", "LICENSE*", "README.md", "benches/**/*", "examples/**/*", "tests/**/*"]

And Here is the code slice processed by Taplo:

[workspace.package]
homepage = "https://github.com/toml-rs/toml"
repository = "https://github.com/toml-rs/toml"
license = "MIT OR Apache-2.0"
edition = "2021"
rust-version = "1.65" # MSRV
include = [
  "build.rs",
  "src/**/*",
  "Cargo.toml",
  "Cargo.lock",
  "LICENSE*",
  "README.md",
  "benches/**/*",
  "examples/**/*",
  "tests/**/*",
]

ssrlive avatar Nov 30 '24 14:11 ssrlive

Sorry, but no. I'm not going to ship a patch release with known regressions.

jplatte avatar Nov 30 '24 14:11 jplatte

Well, I have to install cargo-sort like this:

cargo install cargo-sort --git https://github.com/DevinR528/cargo-sort.git

I hope the command can help other persons.

ssrlive avatar Nov 30 '24 15:11 ssrlive

If that bug and the one with cargo sorts own multiline comment are fixed, I'm happy to publish another release :)

Is this still the latest or has there been any new discoveries since?

thomaseizinger avatar May 07 '25 08:05 thomaseizinger

I'll re-check things soon, now that your two PRs merged :)

edit: From one of the tests you added, it seems that this is not fixed. No new discoveries though.

jplatte avatar May 07 '25 08:05 jplatte

cargo-sort v2.0.0 is out!

jplatte avatar May 22 '25 19:05 jplatte

Thank you!

Bktero avatar May 23 '25 15:05 Bktero