Skip to content

fix(rust): commit Cargo.lock in version bump to prevent cargo publish failure#254

Merged
konard merged 5 commits intomainfrom
issue-253-2cc259d4dbc8
Apr 13, 2026
Merged

fix(rust): commit Cargo.lock in version bump to prevent cargo publish failure#254
konard merged 5 commits intomainfrom
issue-253-2cc259d4dbc8

Conversation

@konard
Copy link
Copy Markdown
Contributor

@konard konard commented Apr 12, 2026

Summary

Fixes #253 — CI/CD flow for Rust publishing was failing with exit code 101 in the `Publish to crates.io` step.

Root Causes

1. Script: Missing Cargo.lock in version bump commit

The `scripts/rust-version-and-commit.mjs` script bumped the version in `Cargo.toml` and committed it, but did not include `Cargo.lock` in the commit.

The CI workflow then ran `cargo build --release`, which updated `Cargo.lock` to reflect the new version from `Cargo.toml`. When `cargo publish` ran next, it detected the uncommitted `Cargo.lock` and failed:

```
error: 1 files in the working directory contain changes that were not yet committed into git:

Cargo.lock

to proceed despite this and include the uncommitted changes, pass the --allow-dirty flag
```

Evidence: The automated `chore(rust): release v0.9.0` commit (SHA: `3c23cdb`) only contained `Cargo.toml` + `CHANGELOG.md` — no `Cargo.lock`.

2. CI Workflow: cargo package --list failing due to build-modified Cargo.lock

In the `Build Package` CI job, `cargo build --release` ran before `cargo package --list`. The build step modified `Cargo.lock`, making the working directory dirty. `cargo package --list` then failed with the same exit code 101 / "uncommitted changes" error.

Fixes

Fix 1: `scripts/rust-version-and-commit.mjs`

  1. Run `cargo generate-lockfile --manifest-path <Cargo.toml>` to regenerate `Cargo.lock` with the new version
  2. Stage `Cargo.lock` along with `Cargo.toml` and changelog files in the same version bump commit

Fix 2: `.github/workflows/rust.yml`

Move `cargo package --list` before `cargo build --release` in the `Build Package` job. This way the working directory is clean when the package check runs.

Fix 3: `js/.changeset/fix-rust-cargo-lock-version-bump.md`

Add required changeset file to pass the JS CI/CD "Check for Changesets" check, which requires exactly one changeset per PR when `scripts/` files are modified.

Case Study

Full analysis with CI logs, timeline, root causes, and solution options:

How to Reproduce the Issue

  1. Have a Rust project in a `rust/` subdirectory with a `Cargo.toml` and `Cargo.lock`
  2. Run `node scripts/rust-version-and-commit.mjs --bump-type patch` (without fix 1)
  3. Observe that `Cargo.lock` is NOT included in the commit
  4. Run `cargo build --release` — Cargo.lock is now modified
  5. Run `cargo publish --verbose` — fails with exit code 101

🤖 Generated with Claude Code

Adding .gitkeep for PR creation (default mode).
This file will be removed when the task is complete.

Issue: #253
@konard konard self-assigned this Apr 12, 2026
… failure

When bumping the version in Cargo.toml, regenerate and commit Cargo.lock
in the same commit. Without this, `cargo build --release` (run after the
version commit) updates Cargo.lock, leaving it dirty. `cargo publish`
then rejects publishing with exit code 101 because of uncommitted changes.

Root cause: scripts/rust-version-and-commit.mjs staged Cargo.toml and
CHANGELOG.md but not Cargo.lock. After the commit, `cargo build` updated
Cargo.lock to reflect the new version, and `cargo publish` detected the
mismatch.

Fix: run `cargo generate-lockfile --manifest-path` after updating
Cargo.toml and stage Cargo.lock in the same version bump commit.

Also adds case study analysis in docs/case-studies/issue-253/ with
CI logs, timeline, root cause analysis, and solution options.

Fixes #253

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@konard konard changed the title [WIP] CI/CD flow for rust publishing should be fixed fix(rust): commit Cargo.lock in version bump to prevent cargo publish failure Apr 12, 2026
@konard konard marked this pull request as ready for review April 12, 2026 13:53
@konard
Copy link
Copy Markdown
Contributor Author

konard commented Apr 12, 2026

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost estimation:

  • Public pricing estimate: $1.371850
  • Calculated by Anthropic: $1.391850
  • Difference: $0.020000 (+1.46%)

📊 Context and tokens usage:

Claude Sonnet 4.6:

  • Context window: 66.1K / 1M (7%) input tokens, 15.7K / 64K (25%) output tokens

Total: (56.8K + 2.8M cached) input tokens, 15.7K output tokens, $1.283045 cost

Claude Haiku 4.5:

Total: (55.6K + 81.9K cached) input tokens, 2.5K / 64K (4%) output tokens, $0.088805 cost

🤖 Models used:

  • Tool: Anthropic Claude Code
  • Requested: sonnet
  • Main model: Claude Sonnet 4.6 (claude-sonnet-4-6)
  • Additional models:
    • Claude Haiku 4.5 (claude-haiku-4-5-20251001)

📎 Log file uploaded as Gist (1675KB)


Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard
Copy link
Copy Markdown
Contributor Author

konard commented Apr 12, 2026

🔄 Auto-restart triggered (iteration 1)

Reason: CI failures detected

Starting new session to address the issues.


Auto-restart-until-mergeable mode is active. Will continue until PR becomes mergeable.

- Move `cargo package --list` before `cargo build --release` in the
  Rust Build Package CI job. Previously, `cargo build --release` would
  update Cargo.lock, leaving it dirty and causing `cargo package --list`
  to fail with exit code 101 ("1 files in the working directory contain
  changes that were not yet committed into git: Cargo.lock").

- Add changeset file for the JS pipeline's "Check for Changesets" check,
  which requires exactly one changeset file per PR when scripts/ changes.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@konard
Copy link
Copy Markdown
Contributor Author

konard commented Apr 12, 2026

🔄 Auto-restart-until-mergeable Log (iteration 1)

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost: $0.842616

📊 Context and tokens usage:

  • Context window: 68.4K / 1M (7%) input tokens, 7.6K / 64K (12%) output tokens

Total: (57.0K + 1.7M cached) input tokens, 7.6K output tokens, $0.842616 cost

🤖 Models used:

  • Tool: Anthropic Claude Code
  • Requested: sonnet
  • Model: Claude Sonnet 4.6 (claude-sonnet-4-6)

📎 Log file uploaded as Gist (3574KB)


Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard
Copy link
Copy Markdown
Contributor Author

konard commented Apr 12, 2026

🔄 Auto-restart triggered (iteration 2)

Reason: CI failures detected

Starting new session to address the issues.


Auto-restart-until-mergeable mode is active. Will continue until PR becomes mergeable.

- Update Cargo.lock package version from 0.8.0 to 0.9.0 to match
  Cargo.toml. The mismatch caused `cargo package --list` to modify
  Cargo.lock at CI time, making the working directory dirty and failing
  with exit code 101 ("uncommitted changes in Cargo.lock").

- Fix Prettier formatting in changeset file: change double quotes to
  single quotes in the YAML front matter to match the project's
  Prettier config (singleQuote: true).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@konard
Copy link
Copy Markdown
Contributor Author

konard commented Apr 12, 2026

🔄 Auto-restart-until-mergeable Log (iteration 2)

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost: $0.684123

📊 Context and tokens usage:

  • Context window: 46.6K / 1M (5%) input tokens, 7.8K / 64K (12%) output tokens

Total: (35.4K + 1.5M cached) input tokens, 7.8K output tokens, $0.684123 cost

🤖 Models used:

  • Tool: Anthropic Claude Code
  • Requested: sonnet
  • Model: Claude Sonnet 4.6 (claude-sonnet-4-6)

📎 Log file uploaded as Gist (5557KB)


Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard
Copy link
Copy Markdown
Contributor Author

konard commented Apr 12, 2026

✅ Ready to merge

This pull request is now ready to be merged:

  • All CI checks have passed
  • No merge conflicts
  • No pending changes

Monitored by hive-mind with --auto-restart-until-mergeable flag

@konard konard marked this pull request as draft April 13, 2026 01:14
@konard
Copy link
Copy Markdown
Contributor Author

konard commented Apr 13, 2026

🤖 AI Work Session Started

Starting automated work session at 2026-04-13T01:14:22.558Z

The PR has been converted to draft mode while work is in progress.

This comment marks the beginning of an AI work session. Please wait for the session to finish, and provide your feedback.

@konard konard marked this pull request as ready for review April 13, 2026 01:16
@konard
Copy link
Copy Markdown
Contributor Author

konard commented Apr 13, 2026

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost: $0.365441

📊 Context and tokens usage:

  • Context window: 45.7K / 1M (5%) input tokens, 2.7K / 64K (4%) output tokens

Total: (45.7K + 513.1K cached) input tokens, 2.7K output tokens, $0.365441 cost

🤖 Models used:

  • Tool: Anthropic Claude Code
  • Requested: sonnet
  • Model: Claude Sonnet 4.6 (claude-sonnet-4-6)

📎 Log file uploaded as Gist (599KB)


Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard
Copy link
Copy Markdown
Contributor Author

konard commented Apr 13, 2026

✅ Ready to merge

This pull request is now ready to be merged:

  • All CI checks have passed
  • No merge conflicts
  • No pending changes

Monitored by hive-mind with --auto-restart-until-mergeable flag

@konard konard merged commit cb37cb7 into main Apr 13, 2026
24 of 25 checks passed
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.

CI/CD flow for rust publishing should be fixed

1 participant