Skip to content

fix(install): fetch the skills CLI with npm so npx never takes its lock - #978

Merged
2 commits merged into
mainfrom
fix/skill-fetch-ecompromised
Oct 15, 2026
Merged

2 commits merged into
mainfrom
fix/skill-fetch-ecompromised

Conversation

@fpresta0607

Copy link
Copy Markdown
Owner

Fixes #888

Why

The skill fetch in install.ps1 failed with npm error code ECOMPROMISED ("Lock compromised"), even after its retry with a fresh npm cache.
The fresh cache could not help, because the cache was never the cause.

ECOMPROMISED comes from one place in npm: libnpmexec/lib/with-lock.js.
That is the lock npx holds on its _npx/<hash>/concurrency.lock folder while it installs a package into its cache.
In npm before 11.6.3 the lock checks itself on a setInterval.
When one fs.stat is slow, which happens on a busy runner or while Defender scans, the next check overlaps it and reads a stale mtime, and npm calls the lock compromised.
This is npm/cli#8710, fixed by npm/cli#8733 in npm 11.6.3.
Node.js 24.13.0, which the Install workflow sets up and which many users run, ships npm 11.6.2.

What changes

The fix makes the skill fetch survive the lock failure by never taking the lock.
The workflow still fails a job whose fetch really failed.

  • The npm beside the npx installs the pinned skills CLI with npm install --prefix <its own temp folder> skills@1.7.1.
    npm's install takes no such lock.
  • npx --no skills@1.7.1 add ... runs each skill from that folder.
    --no means npx never installs a package itself, so it never reaches the locked path.
    npx finds the CLI in the folder it runs in.
    I checked this by hand: with the CLI in place, npx ran it and wrote nothing to _npx, and in an empty folder it refused with "npx canceled due to missing packages".
  • The CLI fetch is tried once more if it fails.
    If it fails twice, every skill is named in the install's closing note and npx never runs.
  • The fresh-cache retry is removed, since the cause it guessed at was wrong.
  • The Install workflow's "Check the installed home" step now names a failed fetch of the skills CLI itself.
    Before, that case would have fallen through to "its log does not say the fetch failed".

Test plan

  • Red first: TestOneLineInstallAddsSkillsWithoutNpxInstallingAPackage fails on the old install.ps1 and passes on the fix.
    In this test, the stand-in npx fails with ECOMPROMISED whenever it would install the CLI itself.
  • TestOneLineInstallNamesEverySkillWhenTheSkillsCliCannotBeFetched (new), TestOneLineInstallTriesASkillAgainAndNamesOneThatStillFails, TestOneLineInstallRefusesALavishDownloadThatDoesNotMatchItsPin and TestTheInstallPinsEveryPackageItFetchesFromNpm pass locally, run by name.
  • go vet ./internal/installscript is clean.
  • CI: the Install workflow's real installs on hosted runners fetch the three skills through the new path.

An npx that installs a package holds a lock on its cache folder, and npm
before 11.6.3, the npm Node.js 24.13 ships, reports that lock compromised
(ECOMPROMISED) whenever the file system answers slowly: overlapping touch
timers read a stale mtime (npm/cli#8710). The fresh-cache retry could not
help, since the lock, not a cache entry, was the cause, and run 38628936476
failed after it.

npm's install takes no such lock, so the npm beside the npx now installs the
pinned skills CLI into a folder of the install's own, and npx runs it from
that folder with --no, never installing a package itself. The fresh-cache
retry goes, and the Install workflow names a failed fetch of the CLI itself.
The skills CLI is fetched by the npm beside the npx, and where there is
none the fetch was tried again after a wait, though a missing program
never appears on a second try. Such a session, as a test's with only a
stand-in npx, now reports the skills' Node.js prerequisite at once, as it
does when npx itself is missing, and waits for nothing.
@fpresta0607 fpresta0607 closed this pull request by merging all changes into main in 317e2a7 Oct 15, 2026
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.

Install's skill fetch fails with npm ECOMPROMISED even after its fresh-cache retry

1 participant