Skip to content

hunk update via pnpm fails #866

Description

@flexdinesh

What happened?

I installed hunk globally in my machine using pnpm

pnpm i -g hunkdiff

I update hunk everyday in my machine using

pnpm update -g hunkdiff

In the last two days updating hunk has been giving me pnpm store errors

pnpm update -g hunkdiff
Packages: +83
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Packages are cloned from the content-addressable store to the virtual store.
  Content-addressable store is at: /Users/myuser/Library/pnpm/store/v11
  Virtual store is at:             Library/pnpm/store/v11/links
Progress: resolved 105, reused 83, downloaded 0, added 1, done
Library/pnpm/store/v11/links/@/bun/1.4.0/8cf3571ed46409fd110f7047cceec5ad1aced284059b0508de35ea7ad52d19f8/node_modules/bun: Running postinstall script, failed in 220ms
.../node_modules/bun postinstall$ node install.js
│ Failed to find package "@oven/bun-darwin-aarch64". You may have used the "--no-optional" flag when running "npm install".
│ Error: Failed to install package "bun"
│     at /Users/myuser/Library/pnpm/store/v11/links/@/bun/1.4.0/8cf3571ed46409fd110f7047cceec5ad1aced284059b0508de35ea7ad52d19f8/nod…
│     at Generator.throw (<anonymous>)
│     at rejected (/Users/myuser/Library/pnpm/store/v11/links/@/bun/1.4.0/8cf3571ed46409fd110f7047cceec5ad1aced284059b0508de35ea7ad5…
└─ Failed in 220ms at /Users/myuser/Library/pnpm/store/v11/links/@/bun/1.4.0/8cf3571ed46409fd110f7047cceec5ad1aced284059b0508de35ea7ad52d19f8/node_modules/bun
[ELIFECYCLE] Command failed with exit code 1.

The interim solution I have figured out for myself is to clear the pnpm store cache using

pnpm store prune

and running update again

pnpm update -g hunkdiff
Packages: +83
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Packages are cloned from the content-addressable store to the virtual store.
  Content-addressable store is at: /Users/myuser/Library/pnpm/store/v11
  Virtual store is at:             Library/pnpm/store/v11/links
Downloading @oven/bun-darwin-aarch64@1.4.0: 26.34 MB/26.34 MB, done
Progress: resolved 105, reused 0, downloaded 83, added 83, done
Library/pnpm/store/v11/links/@/bun/1.4.0/8cf3571ed46409fd110f7047cceec5ad1aced284059b0508de35ea7ad52d19f8/node_modules/bun: Running postinstall script, done in 752ms
Downloading hunkdiff-darwin-arm64@0.19.0: 31.13 MB/31.13 MB, done

global:
+ hunkdiff 0.19.0

Done in 11.4s using pnpm v11.23.0

Debugging output

I don't mean to be a meat proxy but adding my clanker debug output here since I don't understand the details of the interop b/w pnpm / bun / hunk. Please ignore if it's not helpful. It appears that it's a bun issue with pnpm that's showing up via hunkdiff because hunkdiff uses bun to build the cli.

Your local Library/pnpm/global/v11/6ab3-1a036121604-0ecc873c0536c2c2/node_modules/hunkdiff/package.json declares bun: ^1.3.14.

  The root cause is an interaction between two bugs/design assumptions:

  1. Bun’s npm postinstall script moves its executable out of @oven/bun-darwin-aarch64 into the bun wrapper package.
  2. pnpm 11 global installs use a shared global virtual store. Moving the executable therefore damages the shared cached projection.

  I confirmed that pnpm’s store index expects bin/bun, and the 63.5 MB binary still exists in the content-addressable store, but the projected
  directory below is empty:

  Library/pnpm/store/v11/links/@oven/bun-darwin-aarch64/1.4.0/.../bin/

  The sequence is:

  prune → pnpm rebuilds projection → Bun moves binary → first install succeeds
  next update → shared projection has no binary → Bun postinstall fails

  That precisely matches the [open Bun bug](https://github.com/oven-sh/bun/issues/25031) (https://github.com/oven-sh/bun/issues/25031). Bun’s current install source still uses rename, and
  there is an [open PR to replace it with linking/copying](https://github.com/oven-sh/bun/pull/25303) (https://github.com/oven-sh/bun/pull/25303). pnpm also has an open issue about not
  [repairing incomplete global-store projections](https://github.com/pnpm/pnpm/issues/11385) (https://github.com/pnpm/pnpm/issues/11385).

Expected behavior

Update should work without having to prune pnpm store every time

Version

0.19.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions