Skip to content

[Bug]: Skill update fails with "exited with code 126" when npx resolves to a broken asdf/mise shim #13807

Closed

Description

@spanishkangaroo

Short summary

Clicking Update on an outdated skill (and the background auto-update) fails with "skills update exited with code 126". The failure is caused by Orca resolving npx to an asdf shim whose declared node version is not installed; the dialog headline gives no hint about the real cause.

Environment

  • macOS (arm64)
  • Orca 1.4.180
  • Node managed with asdf; ~/.asdf/shims precedes /opt/homebrew/bin in the shell PATH, and the app was launched from a terminal so it inherits that ordering

What happened

  1. Skill freshness dialog reports an outdated skill
  2. Clicking Update shows "The update didn't finish" with message skills update exited with code 126
  3. The run log contains the asdf shim's stderr: No version is set for command npx / Consider adding one of the following versions in your config file at .../.tool-versions / nodejs 22.22.2

Root cause

  • SkillUpdateRunner resolves npx via resolveCliCommand('npx') (src/shared/node-cli-command-resolution.ts)
  • That resolver only checks accessSync(X_OK), which asdf/mise shims pass, so ~/.asdf/shims/npx is chosen over a real npx later in PATH (e.g. /opt/homebrew/bin/npx)
  • The shim itself then exits 126 because the node version declared in ~/.tool-versions (nodejs 24.9.0) is not installed (only 22.22.2), so asdf cannot exec anything
  • patchPackagedProcessPath (src/main/startup/configure-process.ts) only prepends missing dirs; it never reorders an inherited PATH where shims come before real binaries, so the broken shim wins
  • The runner turns exit code 126 into the bare message skills update exited with code 126 (src/main/skills/skill-update-run.ts), which is not actionable

In a login shell the same machine resolves npx to /opt/homebrew/bin/npx and the update works, which is why this looks like a recent Orca regression: no skill-update/CLI-resolution code changed in v1.4.176..v1.4.180 — the trigger is environment PATH ordering.

Repro

  1. asdf with ~/.tool-versions declaring a node version that is not installed (asdf install missing), only an older one installed
  2. PATH ordered with ~/.asdf/shims before /opt/homebrew/bin
  3. Launch Orca from that shell (inherited PATH), open Skills, click Update on an outdated skill
  4. Observe exit code 126

Expected behavior

  • The update should not be permanently blocked by a dead shim: when the resolved npx is a version-manager shim that exits 126 on POSIX, Orca should fall back to the next runnable npx candidate in PATH (e.g. /opt/homebrew/bin/npx) and retry once
  • If the retry also fails, the message should name the resolved binary and suggest checking the version-manager config (install the declared node version)

Proposed fix

In SkillUpdateRunner (src/main/skills/skill-update-run.ts):

  1. Resolve all runnable npx candidates (new shared helper alongside resolveCliCommand)
  2. On POSIX, if the spawned candidate exits 126 and another candidate exists, respawn with the next candidate once, same run token
  3. If it still fails, include the resolved binary path and a version-manager hint in the error message instead of a bare exit code

Relevant files:

  • src/main/skills/skill-update-run.ts
  • src/shared/node-cli-command-resolution.ts
  • src/main/startup/configure-process.ts

Activity

  1. manuaudio commented on Aug 11, 2026

    @manuaudio
    Contributor

    Every citation in this checks out, including the "not a regression" claim, which I verified independently. Two things to add to the root cause and three traps in the proposed fix. Checked against upstream/main at a0a654c3a9.

    Confirming what you found

    isRunnableCommand (src/shared/node-cli-command-resolution.ts:70-86) is exactly the predicate you describe — statSync().isFile() plus accessSync(candidate, constants.X_OK), nothing more. An asdf shim is a real, executable file, so it passes and wins on first match.

    patchPackagedProcessPath (src/main/startup/configure-process.ts:130-134) confirms the second half:

      const missing = extraPaths.filter((path) => !existing.has(path))
    
      if (missing.length > 0) {
        process.env[pathKey] = [...missing, ...currentPath.split(pathDelimiter).filter(Boolean)].join(

    And the runner's bare message is at src/main/skills/skill-update-run.ts:179, resolving npx at :92-94.

    Your regression claim holds and I'd state it more strongly. Across the 317 commits in v1.4.176..upstream/main, skill-update-run.ts, node-cli-command-resolution.ts and cli/handlers/skills.ts are untouched. configure-process.ts shows two commits — but they're 17b3dff3c4 and its revert 17cfc968cf, and git diff v1.4.176 upstream/main -- src/main/startup/configure-process.ts is empty. Net zero. Nothing in this path moved.

    Two additions to the root cause

    The fallback list has the same preference baked in. You frame this as inherited PATH ordering, but even with a clean PATH the resolver would still pick the shim: getBaseVersionManagerDirectories puts join(homePath, '.asdf', 'shims') at position two (:91), ahead of ~/.local/bin and everything else. So the shim preference isn't only environmental — it's in the resolver's own fallback order.

    The PATH patcher is disabled by the very thing that would have saved you. /opt/homebrew/bin is in extraPaths and gets prepended when missing — which would have put the real npx first. But your PATH already contains it (just later), so it isn't "missing" and never gets promoted. Having homebrew on PATH is what stops the patcher from fixing the ordering. (It's also app.isPackaged-gated at :94-96, so it does nothing in dev at all.)

    Trap 1 — this is one call site of seven

    src/main/codex-cli/command.ts is a single line: export * from '../../shared/node-cli-command-resolution'. So the imports in skill-update-run.ts and the shared module are the same function. Non-test call sites:

    Call site What breaks with a dead shim
    src/main/skills/skill-update-run.ts:92 your bug
    src/cli/handlers/skills.ts:122 orca skills install/update from the CLI
    src/cli/handlers/account.ts:92 account command resolution
    src/main/external-editor-launch.ts:138, :235 opening an external editor
    src/main/text-generation/commit-message-text-generation.ts:362, :656 commit-message generation

    A retry-on-126 inside SkillUpdateRunner fixes one row. The same machine, same shim, still breaks the other four — with different and probably worse symptoms, since none of them has a dialog to report into.

    Trap 2 — the CLI path makes it worse, and your fix doesn't touch it

    src/cli/handlers/skills.ts resolves npx independently at :122, then builds the child's PATH with buildNpxPath (:105-115):

    /** PATH with the resolved npx's own directory first, so its `env node` shebang resolves. */

    For a resolved ~/.asdf/shims/npx, that prepends ~/.asdf/shims to the child's PATH — actively promoting the broken shim directory to the front for the spawned process. The // Why: explains it ("every version manager ships node beside npx in the same bin directory"), and the reasoning is sound for a working version manager; it just compounds the failure for a dead one. Worth fixing in the same pass, since it's the same user hitting the same shim through orca skills update.

    Trap 3 — a blind retry on 126 can re-run a partially applied update

    The child is npx --yes skills update <names> --global -y. Exit 126 is not exclusive to the shim: if npx runs fine and the inner skills CLI exits 126 for its own reasons, "respawn with the next candidate" re-runs a global skill update that may already have written to disk.

    That isn't hypothetical here — the runner's own // Why: (:196-199) says the outcome is decided by re-hashing disk:

    "when the re-scan produces a verdict it *is* the answer — it re-hashes what landed on disk, which is what the user actually cares about. The exit code only decides the outcome when no verdict is available, because skills update reports nothing else we can trust."

    If the exit code is the weakest evidence the runner has, it's a thin basis for deciding to run the whole thing again.

    The discriminator is already in hand: a dead shim fails before the inner tool produces any output, and its stderr is distinctive — the string you quoted, No version is set for command npx. Gating the retry on 126 and shim-shaped stderr (or 126 with no inner-tool output) keeps it safe. The bare exit code alone doesn't.

    The part of your proposal that's already precedented

    Your point 3 — name the resolved binary in the message — has a sibling three lines up. The unsafe-command-path branch (:109-118) already does exactly that:

              `Could not run ${npxCommand} safely from this location: its path contains one of ` +

    So "publish an error that names npxCommand" is an established shape in this file, not a new one. Of your three proposals I'd rank this one first: it's the smallest change, it can't re-run anything, and it turns exited with code 126 into a message that would have saved you the investigation. The candidate-fallback is the part that deserves the design discussion.

    What would sharpen it

    Two things that would help whoever picks this up:

    1. Does orca skills update from the CLI fail the same way on your machine? That confirms Trap 2 and shows the fix has to be shared rather than runner-local.
    2. Does the run log show any output from the skills CLI itself before the 126, or only the asdf stderr? That's what decides whether stderr-gating is enough to make a retry safe.

    What I did not verify

    No asdf install here, so I haven't reproduced the 126 or confirmed that a fallback candidate would succeed — your repro is specific enough that I'd take it as given. Everything above is read from source or measured in git; the trap analysis is about what the fix runs into, not whether your diagnosis is right. It is.

  2. spanishkangaroo commented on Aug 11, 2026

    @spanishkangaroo
    Author

    Thank you very much guys for your implication and quick review.
    It was actually one of my agents, working autonomously who picked it up - I went out for lunch, then came back and you already had everything sorted out!
    I'll test it asap.

  3. AmethystLiang commented on Aug 11, 2026

    @AmethystLiang
    Contributor

    thanks for reporting. looking into it

  4. manuaudio commented on Aug 11, 2026

    @manuaudio
    Contributor

    Following up because main just moved into this exact subsystem, and chasing that turned up a second PATH mutator that neither your analysis nor my earlier comment accounted for. It strengthens your root cause and changes where a fix has to go. Checked against upstream/main at c96ded8dfd.

    There are two PATH mutators at startup, not one

    src/main/index.ts:629-637:

    patchPackagedProcessPath()
    // Why: the sync seed above covers early IPC (homebrew/nix); the async login-shell probe below (packaged only) then adds the user's rc PATH.
    if (app.isPackaged && process.platform !== 'win32') {
      void hydrateShellPath().then((result) => {
        if (result.ok) {
          mergePathSegments(result.segments)
        }
      })
    }

    My earlier comment only discussed the first one. The second is the one that matters for you, because of how it merges — hydrate-shell-path.ts:308-311:

      const merged = [
        ...shellSegments,
        ...currentSegments.filter((segment) => !shellSegmentSet.has(pathKey(segment)))
      ]

    The shell's segments go in front, and the trailing // Why: (:316) states the intent outright: "shell-provided entries must win over hardcoded packaged-app fallbacks."

    Why that makes your case stronger, not weaker

    The probe is not a plain login shell. shellPathProbe (:96-99) spawns with -ilc — interactive and login — so it sources .zshrc, not just .zprofile. asdf is conventionally initialised in .zshrc.

    So on a packaged macOS build, the sequence is:

    1. patchPackagedProcessPath() prepends any missing dirs (which, as established, does nothing for you because /opt/homebrew/bin is already present, just late).
    2. Moments later, hydrateShellPath() probes an interactive login shell — the same one that puts ~/.asdf/shims ahead of /opt/homebrew/bin — and mergePathSegments installs that ordering at the front.

    So Orca doesn't merely inherit your bad ordering from the launching terminal. On a packaged build it re-derives and re-applies it, in front of anything the packaged-app seeding added. Even a fix that taught patchPackagedProcessPath to reorder would be overwritten a moment later.

    I want to be explicit that this kills a theory I had while writing this: I expected the probe to be login-only (-lc), which would have skipped .zshrc, missed asdf, and produced a good ordering — making this a race you could win by retrying. The -ilc at :99 rules that out. It isn't a race; it's deterministic.

    Why this is timely

    The commit that just landed, #13792 fix(startup): restore Windows PATH before shell changes (c96ded8dfd), is about precisely this collision — the packaged-app seeding versus the shell probe fighting over PATH. It adds src/main/startup/windows-shell-path-ownership.ts and reworks hydrate-shell-path.ts.

    But it is scoped to win32 only, and your report is macOS. So the ownership question that PR settles for Windows is still open on the platform you hit. Worth flagging to whoever picks this up: the shape of the fix may already exist one platform over.

    What this changes about the fix

    My earlier three traps still stand. This adds a fourth, and it's the load-bearing one: any fix that works by reordering PATH has to survive mergePathSegments. Otherwise it's correct for a few hundred milliseconds and then silently undone.

    Which pushes toward the conclusion your own report reached from the other direction: resolution shouldn't depend on PATH order at all. resolveCliCommand's isRunnableCommand accepts any executable file, so a shim that cannot exec still wins — and now we know PATH order is actively re-asserted from the user's rc files, so "fix the ordering" isn't a durable strategy on macOS either.

    One measurement that would confirm it

    In the failing app, compare the PATH at launch with the PATH a second later — or simply check whether ~/.asdf/shims sits ahead of /opt/homebrew/bin in the packaged app's process.env.PATH after startup settles. If the shims are in front there, mergePathSegments put them there, and the hydration path is confirmed as the dominant ordering authority.

    What I did not verify

    No packaged build running here, so I have not observed the merged PATH at runtime — the two call sites, the merge order and the -ilc flag are read from source at c96ded8dfd. Whether hydration completes before your Update click is a timing question I can't answer from here, but given -ilc it doesn't change the outcome either way.

  5. added
    bug
    os:macos
    on Sep 19, 2026
  6. added theissue type on Sep 19, 2026
  7. nwparker commented on Oct 26, 2026

    @nwparker
    Contributor

    Thanks @spanishkangaroo for the detailed report and root-cause analysis. This is fixed on main by #31688 (d3dbd96): skill updates (the Update button and the background update) now run through Orca's own in-process installer instead of spawning npx skills, so a broken asdf/mise npx shim on PATH can no longer cause the exited with code 126 failure. The change shipped in v1.4.239 and later. If you still see a skill update fail on the latest build, please comment here and we'll take another look.

  8. manuaudio commented on Oct 26, 2026

    @manuaudio
    Contributor

    Confirmed on my side: #31688 merged as d3dbd9683fa, and that commit is included in v1.4.239. Moving skill updates into the in-process installer removes the npx resolution path entirely, so the PATH-order and unsafe-retry concerns I raised no longer apply to this flow. This is cleaner than retrying around a dead shim.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugos:macos

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions