agentleFS
lamxylamxy/agent-prompt-rules-system/skills/skills-codex-repair/npm-codex-enotempty-repair/SKILL.md

npm-codex-enotempty-repair

Skill4 starsChanged 6 months agoMITView on GitHub

Fix npm global install failures for @openai/codex when ENOTEMPTY rename conflicts occur in the global node_modules path.

  • Deletes or force-pushes
  • Installs packages

The file

We split this skill into the rules it gives an agent

3 rules. About 0 are common, 3 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use this Skill when the user reports an error like:

    line 9
  2. Distinctive:

    After running the repair, report:

    line 64
  3. Distinctive:

    If reinstall still fails, capture and include the latest npm debug log path from output.

    line 74

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

npm Codex ENOTEMPTY Repair

Use this Skill when the user reports an error like:

  • npm ERR! code ENOTEMPTY
  • rename .../@openai/codex -> .../@openai/.codex-*

Goal

Recover from stale temporary directories left by failed npm reify moves, then reinstall Codex CLI cleanly.

Procedure

Step 1: Resolve global prefix and inspect paths

npm prefix -g
npm root -g

Expected affected paths:

  • <PREFIX>/lib/node_modules/@openai/codex
  • <PREFIX>/lib/node_modules/@openai/.codex-*
  • <PREFIX>/bin/codex
  • <PREFIX>/bin/.codex-*

Step 2: Remove stale temp directories first

PREFIX="$(npm prefix -g)"
find "$PREFIX/lib/node_modules/@openai" -maxdepth 1 -type d -name '.codex-*' -exec rm -rf {} + 2>/dev/null || true
find "$PREFIX/bin" -maxdepth 1 -type f -name '.codex-*' -delete 2>/dev/null || true

Step 3: If uninstall fails, continue with hard cleanup

npm uninstall -g @openai/codex || true

PREFIX="$(npm prefix -g)"
rm -rf "$PREFIX/lib/node_modules/@openai/codex"
rm -f "$PREFIX/bin/codex"
find "$PREFIX/lib/node_modules/@openai" -maxdepth 1 -type d -name '.codex-*' -exec rm -rf {} + 2>/dev/null || true
find "$PREFIX/bin" -maxdepth 1 -type f -name '.codex-*' -delete 2>/dev/null || true

Step 4: Reinstall and verify

npm install -g @openai/codex@latest
command -v codex
codex --version

Reporting Checklist

After running the repair, report:

  • whether stale .codex-* directories were found and removed;
  • whether uninstall failed or succeeded;
  • whether reinstall succeeded;
  • final codex --version output.

Notes

  • This issue is usually local filesystem state, not a package version issue.
  • If reinstall still fails, capture and include the latest npm debug log path from output.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.