ReviewOS

pantry-pm/pantry

pantry install should also install npm dependencies (bun install)

#200
Closed glennmichael123 opened this 2 months ago ·
2 months ago

Problem

When migrating CI workflows from bun install to pantry install, npm dependencies are not installed. This causes builds to fail with errors like:

error: Could not resolve: "@stacksjs/clapp". Maybe you need to "bun install"?
error: Could not resolve: "ts-syntax-highlighter". Maybe you need to "bun install"?
error: Could not resolve: "bunfig". Maybe you need to "bun install"?

Current behavior

pantry install handles:

  • System packages (bun runtime, zig, etc.) from pantry.jsonc/deps.yaml
  • Workspace packages placed in pantry/
  • Lockfile management via pantry.lock
  • PHP deps via Composer delegation
  • Zig deps via build.zig.zon sync
  • Pre/post install hooks

But it does not install npm dependencies from package.json dependencies/devDependencies. These packages live in node_modules/ and are managed by bun install.

Expected behavior

pantry install should be a complete replacement for bun install in CI workflows. When a project has a package.json with npm dependencies, pantry install should also run bun install (or equivalent) to populate node_modules/.

This would allow CI workflows to simply use:

- name: Setup Pantry
  uses: home-lang/pantry/packages/action@main

- name: Install Dependencies
  run: pantry install

Instead of needing both:

- name: Setup Pantry
  uses: home-lang/pantry/packages/action@main

- name: Install Dependencies
  run: bun install

Context

We attempted to migrate 3 repos (bunpress, craft, dtsx) from bun install to pantry install in CI. All builds failed because npm packages weren't installed.

The install logic in packages/zig/src/cli/commands/install/core.zig does not delegate to bun install for npm dependencies. It handles pantry registry packages, Composer delegation for PHP, and Zig deps — but no npm/bun delegation.

Suggested implementation

After the pantry-specific install steps complete, detect if package.json exists with npm dependencies and run bun install automatically. Similar to how Composer delegation already works in install/core.zig:981-989.

// Pseudocode for the additional step:
if (fileExists("package.json") && hasNpmDependencies()) {
    runCommand("bun install");
}

This would make pantry install a true superset that handles everything — system packages, language-specific packages, AND npm dependencies.

8 days ago

Resolved on main by the package.json delegation checkpoint 4d1b539e7 and failure-semantics follow-up 3afa6ccd1.

Pantry now treats a conventional package.json dependency graph as owned by its selected JavaScript package manager and delegates it exactly once, while explicit Pantry/system dependencies stay in the native Pantry pipeline. The follow-up closes the dangerous success-on-failure case: a missing package-manager executable, spawn error, signal termination, or non-zero Bun/pnpm/Yarn/npm exit now makes pantry install non-zero on fast-path, ordinary-project, and workspace installs. The .pantry-js-installed marker is written only after a successful child install.

Verification on Darwin:

  • Pantry Zig suite: 36/36 build steps succeeded.
  • New unit regression uses a project-local fake npm that exits 42, observes JsInstallFailed, and proves no marker is written.
  • Real Pantry CLI black-box control: failing delegated npm exits 1; successful delegated npm exits 0 and writes the marker.
  • Home's user-facing install delegation preserves the same 1/0 result and marker boundary, confirming Home reuses Pantry rather than adding another user-facing package-manager path.
  • Documentation contracts: 4 pass / 0 fail; zig fmt --check and git diff --check passed.

This resolves the issue's npm-dependency installation contract. Broader layout and resolver questions remain separately tracked in #201.

Sign in to comment on this issue.