Skip to content

fix(worker-build): honour the root package's wasm-bindgen pin in Cargo.lock - #1102

Open
PedroRosalba wants to merge 1 commit into
cloudflare:mainfrom
PedroRosalba:fix/worker-build-lockfile-version
Open

PedroRosalba wants to merge 1 commit into
cloudflare:mainfrom
PedroRosalba:fix/worker-build-lockfile-version

Conversation

@PedroRosalba

Copy link
Copy Markdown

Problem

get_package_version in worker-build/src/lockfile.rs meant to prefer the version the root package pins in its dependencies list when several packages share a name, but it checks for the space at package.len() + 1 instead of package.len(), so that branch never matches and the first (lowest) [[package]] entry always wins. Cargo also writes name version (source) when the same version is locked from two sources, which Version::parse rejects.

Fix

Split the entry on spaces and parse the version token. One behaviour change worth calling out: a root package that pins an unreleased path/git wasm-bindgen now resolves that version, so such setups need WASM_BINDGEN_BIN to point at a matching binary (before, the lowest locked release silently won).

Tests

Four unit tests covering the duplicate-version case, the root pin, the source-suffix form, and the single-entry form.

Tested on macOS (Apple Silicon) only.

…o.lock

`get_package_version` meant to prefer the version the root package pins
in its `dependencies` list when several packages share a name, but it
checked for the space at `package.len() + 1` instead of `package.len()`,
so the branch never matched and the first (lowest) `[[package]]` entry
always won. Cargo also writes `name version (source)` when the same
version is locked from two sources, which `Version::parse` rejects.
Split the entry on spaces and parse the version token instead.
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.

1 participant