A lockfile can record the versions of your own packages and the ranges between them. After a release, a stale lockfile makes a frozen install fail, such as npm ci or bun install --frozen-lockfile. So bump updates each lockfile in the release commit, together with the manifests.
Which lockfiles
| Lockfile | How bump updates it |
|---|---|
Cargo.lock |
bump edits the text. |
package-lock.json |
bump runs npm. |
bun.lock or bun.lockb |
bump runs bun. |
pnpm-lock.yaml |
bump runs pnpm. |
yarn.lock, Yarn 2 or later |
bump runs yarn. |
bump updates only a lockfile that git tracks. A lockfile that git does not track stays as it is.
Cargo.lock
bump edits Cargo.lock as text, so it does not need cargo. It changes only the version strings of the released crates:
- the
versionof each[[package]]entry of a released crate that has nosource; - the version in each
"<name> <version>"string of adependencieslist, when<name>is a released crate.
bump edits the Cargo.lock in the Cargo workspace root of each crate that it finds, when git tracks it. A path dependency can cross workspaces, so each tracked Cargo.lock gets the changes, not only the lockfile of the released crates.
$ bump minor
BUMP acme-core 1.2.0 → 1.3.0 (changed)
BUMP acme-cli 0.4.1 → 0.4.2 (dependent)
EDIT acme-cli dependencies["acme-core"] 1.2.0 → 1.3.0
DONE Committed 425dc9c release: acme-core@1.3.0, acme-cli@0.4.2
Tagged acme-core@1.3.0, acme-cli@0.4.2The release commit holds Cargo.lock, crates/cli/Cargo.toml, and crates/core/Cargo.toml. The log does not list lockfiles.
When git does not track Cargo.lock, bump does not write it. Cargo makes it again on the next build. See Cargo.
npm lockfiles
The npm lockfile formats belong to their package managers. So bump runs the package manager to update them, and does not edit them as text. It runs each command in the root:
| Lockfile | Command |
|---|---|
package-lock.json |
npm install --package-lock-only --ignore-scripts |
bun.lock or bun.lockb |
bun install --lockfile-only --ignore-scripts |
pnpm-lock.yaml |
pnpm install --lockfile-only --ignore-scripts --no-frozen-lockfile |
yarn.lock, Yarn 2 or later |
yarn install --mode=update-lockfile --no-immutable |
- bump runs them only when the release changes an npm package: a new version, or a new range in a
package.json. A release of only crates runs none of them. - With more than one lockfile, bump runs each command, in the order of the table.
- The commands update only the lockfile. They do not install packages into
node_modules, and they do not run scripts. - The commands can need network access, as a normal install does.
- They run after bump writes the manifests.
- The release commit holds a lockfile only when its text changed.
A release with a tracked package-lock.json looks like any other release:
$ bump minor
BUMP @acme/core 1.2.0 → 1.3.0 (changed)
BUMP @acme/cli 0.4.1 → 0.4.2 (dependent)
EDIT app devDependencies["@acme/core"] ^1.2.0 → ^1.3.0
EDIT @acme/cli dependencies["@acme/core"] ^1.2.0 → ^1.3.0
DONE Committed 3578567 release: @acme/core@1.3.0, @acme/cli@0.4.2
Tagged @acme/core@1.3.0, @acme/cli@0.4.2The commit holds package-lock.json and the three package.json files, and npm ci passes after it.
Package managers
Before it writes a file, bump checks that each package manager that it needs is on your PATH. If one is missing, the release stops, and nothing changes:
$ bump minor
FAIL Missing "yarn" binary to update "/private/tmp/acme/yarn.lock"Install the package manager, or remove the lockfile from git if you do not use it.
Yarn 1
Yarn 1 cannot update a lockfile without a full install. When yarn --version starts with 1., bump prints a warning, does not update yarn.lock, and continues the release:
$ bump minor
WARN Yarn 1 cannot update "/private/tmp/acme/yarn.lock" without an install; the lockfile is not updated
BUMP @acme/core 1.2.0 → 1.3.0 (changed)
BUMP @acme/cli 0.4.1 → 0.4.2 (dependent)
EDIT app devDependencies["@acme/core"] ^1.2.0 → ^1.3.0
EDIT @acme/cli dependencies["@acme/core"] ^1.2.0 → ^1.3.0
DONE Committed 60b4b28 release: @acme/core@1.3.0, @acme/cli@0.4.2
Tagged @acme/core@1.3.0, @acme/cli@0.4.2After the release, run yarn install and commit yarn.lock yourself. Or move to Yarn 2 or later.
CI
In CI, when the CI environment variable is set, pnpm and Yarn freeze their lockfiles by default. A frozen lockfile cannot change, so the update would fail. bump adds --no-frozen-lockfile for pnpm and --no-immutable for Yarn to turn that off, because the update is the goal. You do not need to change your CI. See CI.
Dry run
With --dryrun, bump does not run the lockfile commands. It still checks that each package manager is on your PATH, and it prints the Yarn 1 warning. The files field of the JSON result lists each npm lockfile that bump would run a command for, changed or not. See JSON output.
Failures
When a lockfile command fails, bump undoes the release. It restores the manifests and the lockfiles, and makes no commit and no tags:
$ bump minor
BUMP @acme/core 1.2.0 → 1.3.0 (changed)
BUMP @acme/cli 0.4.1 → 0.4.2 (dependent)
EDIT app devDependencies["@acme/core"] ^1.2.0 → ^1.3.0
EDIT @acme/cli dependencies["@acme/core"] ^1.2.0 → ^1.3.0
FAIL Could not update "package-lock.json": npm error code E404
│ The release was undone: no files, commits, or tags changed.The error gives the first error: or fatal: line of the tool's output, without that prefix, else its first line. bump reads stderr, and stdout only when stderr is empty. Here, a dependency of app is not in the npm registry. Run the command of the table yourself to see the full output, fix the cause, and run bump again.