#3906·nanoclaw

[bug] update-nanoclaw: controller archive misses setup/ since #3816, and stage-rooted commands run before deps exist

Author: glifocatCreated Sep 25, 2026Updated Sep 25, 2026
Labelskind/bugtriage/unresolved

Affected NanoClaw version or commit

c313d061 (v2.4.0)

Host platform

Linux

What happened?

Two failures in the /update-nanoclaw flow, both about what the controller can load.

1. The documented controller archive cannot load. .claude/skills/update-nanoclaw/SKILL.md:82 extracts:

bash
git archive "$upstream_ref" scripts src/install-slug.ts | tar -x -C "$controller_dir"

Since #3816 (d5c7cccc), scripts/update/transaction.ts:6-8 imports three files under setup/:

typescript
import { installGateway } from '../../setup/gateways/install.js';
import { resolveGatewaySelection } from '../../setup/gateways/selection.js';
import { upsertEnvVar } from '../../setup/set-env.js';

None of them are in the archive, so prepare crashes before it does anything:

Error: Cannot find module '../../setup/gateways/install.js'

Extracting setup/ as well is not enough. setup/gateways/install.ts:6 imports ../lib/skill-driver.js, and setup/lib/skill-driver.ts:19 imports @clack/prompts. A controller in a mktemp -d directory has no node_modules to resolve that from.

2. The stage-rooted commands run before the stage has dependencies. After a prepare that stops at phase: conflict, SKILL.md:103 says to run resume from "$stageRoot/scripts/update-nanoclaw.ts". The stage has no node_modules at that point (validate is what runs pnpm install --frozen-lockfile), so it fails the same way:

Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@clack/prompts' imported from <stageRoot>/setup/lib/skill-driver.ts

What did you expect?

The exact commands in SKILL.md should load the controller and carry an update through prepare, conflict resolution, resume and validate.

How can we reproduce it?

  1. On any checkout behind c313d061, follow SKILL.md steps 1 and 2 as written.
  2. prepare fails with Cannot find module '../../setup/gateways/install.js'.
  3. For part 2: work around part 1 (see below), let prepare stop on a merge conflict, resolve it in the stage, then run resume from $stageRoot as SKILL.md says. It fails with ERR_MODULE_NOT_FOUND for @clack/prompts.

What got me through (verified end to end on a real update, prepare to finish):

bash
git archive "$upstream_ref" scripts setup src package.json | tar -x -C "$controller_dir"
ln -s "$PWD/node_modules" "$controller_dir/node_modules"

and running every later command (resume, validate, cutover, ack, finish) from $controller_dir instead of $stageRoot.

Suggested fix

  • Make the archive match what the controller imports. The workaround above works but is broad. A narrower list is fine too, as long as something checks it.
  • Add the guard proposed in #3869: a CI test that runs the exact archive command from SKILL.md into a temp dir and imports the controller. #3750 fixed the scripts/ half of this, and #3816 broke it again a week later with nothing to catch it. This test would have.
  • Either run the stage-rooted commands from the controller dir, or have prepare install the stage's dependencies before it can hand back a conflict.

Related, but not blocking

  • #3869 and #3800 reported the same class for missing scripts/ files. I closed #3869 as fixed by #3750, which was right for scripts/ but did not cover setup/.
  • #3498: a different controller-loading bug (macOS symlinked tmpdir).

OS version and CPU architecture

Ubuntu 24.04.4 LTS, x86_64

Install or update path

Something else (/update-nanoclaw transactional update on a customized install)

Docker version

Docker 29.3.1

Channel or interface

Not channel-specific

Agent provider

Not provider-specific

Relevant redacted logs

(see the error lines above)

Last version that worked

Worked before #3816 (d5c7cccc) added the setup/ imports to transaction.ts.


Assisted by Claude; reviewed and verified by a human before submission.