Skip to content

Cargo.toml edits from releases cause cargo sort --workspace --check to fail #1703

@jselig-rigetti

Description

@jselig-rigetti

I think this is just due to an extra whitespace, because if you run the fix command via cargo sort --workspace that is the only change.

diff --git a/Cargo.toml b/Cargo.toml
index f60f543..3e5bcb4 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -2,5 +2,5 @@
 members = ["one", "two"]

 [workspace.dependencies]
-one = { path = "one" , version = "0.1.2" }
+one = { path = "one", version = "0.1.2" }
 two = { path = "two" }

Reproduce:

Dependency versions

Project files

Cargo.toml
[workspace]
members = ["one", "two"]

[workspace.dependencies]
one = { path = "one" }
two = { path = "two" }
knope.toml
[packages.one]
versioned_files = [
    "Cargo.lock",
    "one/Cargo.toml",
]
changelog = "one/CHANGELOG.md"
scopes = ["one"]

[packages.two]
versioned_files = [
    "Cargo.lock",
    "two/Cargo.toml",
    { path = "Cargo.toml", dependency = "one" },
]
changelog = "two/CHANGELOG.md"
scopes = ["two"]

[[workflows]]
name = "release"

[[workflows.steps]]
type = "PrepareRelease"

[[workflows.steps]]
type = "Command"
command = 'git commit -m "chore: prepare new release(s)"'

[[workflows.steps]]
type = "Release"
one/Cargo.toml
[package]
name = "one"
version = "0.1.0"
edition = "2024"
publish = false

[dependencies]
two/Cargo.toml
[package]
name = "two"
version = "0.1.1"
edition = "2024"
publish = false

[dependencies]
one = { workspace = true }

Actions

  • Create a repo with these files and a single conventional commit e.g. "feat: commit"
  • Run cargo sort --workspace --check, everything should pass
  • Run knope release, which produce a diff on Cargo.toml like the following:
❯ git diff HEAD~1 Cargo.toml
diff --git a/Cargo.toml b/Cargo.toml
index d67ca8e..f60f543 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -2,5 +2,5 @@
 members = ["one", "two"]

 [workspace.dependencies]
-one = { path = "one" }
+one = { path = "one" , version = "0.1.2" }
 two = { path = "two" }
  • Running cargo sort --workspace should now fail.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions