这是indexloc提供的服务,不要输入任何密码
Skip to content

Always update workspace Cargo.toml #197

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

FloezeTv
Copy link
Contributor

Currently, the workspace's Cargo.toml is only updated when at least one crate uses common versioning.
However, one can specify dependencies in workspace.dependencies, which is currently not updated when all packages use independent versioning.
This PR changes the behavior to always update the workspace's Cargo.toml, updating the versions of workspace-crates.

Was previously only updated when at least one package uses common version.
However, one can specify dependencies in `workspace.dependencies`,
which was not updated when all packages use independent versions.
This changes the behavior to always update workspace `Cargo.toml`.
@pksunkara
Copy link
Owner

I'm sorry, but could you please clarify a bit more? I'm quite confused about the issue you're experiencing. Please leave a detailed example in a comment, explaining what's happening with the current version versus what's expected.

@FloezeTv
Copy link
Contributor Author

Sure.

As an example, I have created a workspace with three crates a, b, and c where b depends on a and c depends on a and b.
You can download it here.
To only specify the versions of dependencies once, they are added in the workspace's Cargo.toml under workspace.dependencies:

[workspace.dependencies]
a = {path = "a", version="0.0.0"}
b = {path = "b", version="0.0.0"}
c = {path = "c", version="0.0.0"}

When I now run cargo workspaces version --no-git-commit -y minor (note that this requires the latest version from master due to #196), I get the following output:

$ cargo workspaces version --no-git-commit -y minor

Changes:
 - a: 0.0.0 => 0.1.0
 - b: 0.0.0 => 0.1.0
 - c: 0.0.0 => 0.1.0

error: failed to select a version for the requirement `a = "^0.0.0"`
candidate versions found which didn't match: 0.1.0
location searched: /path/to/example/a
required by package `b v0.1.0 (/path/to/example/b)`
info success ok

resulting in the following diff:

diff --git a/a/Cargo.toml b/a/Cargo.toml
index ec6df27..cffa73a 100644
--- a/a/Cargo.toml
+++ b/a/Cargo.toml
@@ -1,6 +1,6 @@
 [package]
 name = "a"
-version = "0.0.0"
+version = "0.1.0"
 edition = "2024"
 
 [dependencies]
diff --git a/b/Cargo.toml b/b/Cargo.toml
index 410485f..7f12d6b 100644
--- a/b/Cargo.toml
+++ b/b/Cargo.toml
@@ -1,6 +1,6 @@
 [package]
 name = "b"
-version = "0.0.0"
+version = "0.1.0"
 edition = "2024"
 
 [dependencies]
diff --git a/c/Cargo.toml b/c/Cargo.toml
index 610480a..4afede4 100644
--- a/c/Cargo.toml
+++ b/c/Cargo.toml
@@ -1,6 +1,6 @@
 [package]
 name = "c"
-version = "0.0.0"
+version = "0.1.0"
 edition = "2024"
 
 [dependencies]

Note that the workspace's Cargo.toml, which specifies the versions for our dependencies, is unchanged.
Therefore, the crates still depend on the old versions of the crates which, of course, don't exist at that path anymore.

When doing the same with this PR merged, I instead get the following output:

$ cargo workspaces version --no-git-commit -y minor

Changes:
 - a: 0.0.0 => 0.1.0
 - b: 0.0.0 => 0.1.0
 - c: 0.0.0 => 0.1.0

     Locking 3 packages to latest Rust 1.85.0 compatible versions
    Updating a v0.0.0 (/path/to/example/a) -> v0.1.0
    Updating b v0.0.0 (/path/to/example/b) -> v0.1.0
    Updating c v0.0.0 (/path/to/example/c) -> v0.1.0
info success ok

and the following diff:

diff --git a/Cargo.lock b/Cargo.lock
index 2497d4a..90b7477 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -4,18 +4,18 @@ version = 4
 
 [[package]]
 name = "a"
-version = "0.0.0"
+version = "0.1.0"
 
 [[package]]
 name = "b"
-version = "0.0.0"
+version = "0.1.0"
 dependencies = [
  "a",
 ]
 
 [[package]]
 name = "c"
-version = "0.0.0"
+version = "0.1.0"
 dependencies = [
  "a",
  "b",
diff --git a/Cargo.toml b/Cargo.toml
index ae76085..01dcca1 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -7,6 +7,6 @@ members = [
 ]
 
 [workspace.dependencies]
-a = {path = "a", version="0.0.0"}
-b = {path = "b", version="0.0.0"}
-c = {path = "c", version="0.0.0"}
+a = {path = "a", version="0.1.0"}
+b = {path = "b", version="0.1.0"}
+c = {path = "c", version="0.1.0"}
diff --git a/a/Cargo.toml b/a/Cargo.toml
index ec6df27..cffa73a 100644
--- a/a/Cargo.toml
+++ b/a/Cargo.toml
@@ -1,6 +1,6 @@
 [package]
 name = "a"
-version = "0.0.0"
+version = "0.1.0"
 edition = "2024"
 
 [dependencies]
diff --git a/b/Cargo.toml b/b/Cargo.toml
index 410485f..7f12d6b 100644
--- a/b/Cargo.toml
+++ b/b/Cargo.toml
@@ -1,6 +1,6 @@
 [package]
 name = "b"
-version = "0.0.0"
+version = "0.1.0"
 edition = "2024"
 
 [dependencies]
diff --git a/c/Cargo.toml b/c/Cargo.toml
index 610480a..4afede4 100644
--- a/c/Cargo.toml
+++ b/c/Cargo.toml
@@ -1,6 +1,6 @@
 [package]
 name = "c"
-version = "0.0.0"
+version = "0.1.0"
 edition = "2024"
 
 [dependencies]

Note how now there is no error and the version has correctly been updated in the workspace' s Cargo.toml.

Let me know if you have any further questions.

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.

2 participants