error: can't create new files

Resolved 💬 3 comments Opened Apr 17, 2025 by mykeln Closed Aug 7, 2025

First, wonderful tool. Wow.

Second: it spent a good ~5 minutes rolling through my app, then when it went to start implementing, it asks to run the following shell command:
Shell Command │
│ │
│$ apply_patch "* Begin Patch │
│
* Add File: scripts/convert-zwo-to-fit.js

  • when I say 'y' it then "runs" the apply_patch tool, but it never actually does -- ENOENT: no such file or directory, open 'scripts/convert-zwo-to-fit.js'

TEMP FIX: If I manually create the file/directory, it immediately pastes the contents into the file and continues.

View original on GitHub ↗

3 Comments

LCEnzo · 1 year ago

I'm running Kubuntu 24, Konsole, zsh, node v22.14, codex version 0.1.2504161551. I encounter a similar issue, but with a different error message:

node:internal/child_process:420
    throw new ErrnoException(err, 'spawn');
          ^

Error: spawn ENAMETOOLONG
    at ChildProcess.spawn (node:internal/child_process:420:11)
    at spawn (node:child_process:753:9)
    at KI (file:///home/lcenzo/.nvm/versions/node/v22.14.0/lib/node_modules/@openai/codex/dist/cli.js:364:1784)
    at gte (file:///home/lcenzo/.nvm/versions/node/v22.14.0/lib/node_modules/@openai/codex/dist/cli.js:437:223)
    at EN (file:///home/lcenzo/.nvm/versions/node/v22.14.0/lib/node_modules/@openai/codex/dist/cli.js:437:5562)
    at async Tte (file:///home/lcenzo/.nvm/versions/node/v22.14.0/lib/node_modules/@openai/codex/dist/cli.js:437:4863)
    at async R0.handleFunctionCall (file:///home/lcenzo/.nvm/versions/node/v22.14.0/lib/node_modules/@openai/codex/dist/cli.js:461:3960)
    at async R0.processEventsWithoutStreaming (file:///home/lcenzo/.nvm/versions/node/v22.14.0/lib/node_modules/@openai/codex/dist/cli.js:462:4719)
    at async R0.run (file:///home/lcenzo/.nvm/versions/node/v22.14.0/lib/node_modules/@openai/codex/dist/cli.js:462:3045) {
  errno: -36,
  code: 'ENAMETOOLONG',
  syscall: 'spawn'
}

Node.js v22.14.0

---

Prompt that caused the issue

Hi GPT! Checkout gpt.txt in the current dir for more info.

These are your instructions in a sense. Besides these, keep in mind I'll need to review any code changes you make. But that's for later, for now, formulate a plan and explore the code for info you need.

Also, get back to me after reading ~20k words or more, I have a rate limit of 200k tokens, and the CLI we're interacting in crashes if we hit it which is .... aweful. Use a file to store findings as you work, update it frequently.

Another thing, this is our 3rd try. The first failed due to rate limits, the second had a ErrnoException.

Here's the error:

node:internal/child_process:420
    throw new ErrnoException(err, 'spawn');
          ^

Error: spawn ENAMETOOLONG
    at ChildProcess.spawn (node:internal/child_process:420:11)
    at spawn (node:child_process:753:9)
    at KI (file:///home/lcenzo/.nvm/versions/node/v22.14.0/lib/node_modules/@openai/codex/dist/cli.js:364:1784)
    at gte (file:///home/lcenzo/.nvm/versions/node/v22.14.0/lib/node_modules/@openai/codex/dist/cli.js:437:223)
    at EN (file:///home/lcenzo/.nvm/versions/node/v22.14.0/lib/node_modules/@openai/codex/dist/cli.js:437:5562)
    at async Tte (file:///home/lcenzo/.nvm/versions/node/v22.14.0/lib/node_modules/@openai/codex/dist/cli.js:437:4863)
    at async R0.handleFunctionCall (file:///home/lcenzo/.nvm/versions/node/v22.14.0/lib/node_modules/@openai/codex/dist/cli.js:461:3960)
    at async R0.processEventsWithoutStreaming (file:///home/lcenzo/.nvm/versions/node/v22.14.0/lib/node_modules/@openai/codex/dist/cli.js:462:4719)
    at async R0.run (file:///home/lcenzo/.nvm/versions/node/v22.14.0/lib/node_modules/@openai/codex/dist/cli.js:462:3045) {
  errno: -36,
  code: 'ENAMETOOLONG',
  syscall: 'spawn'
}

Node.js v22.14.0

Here's the file content you wanted to write:

$ "apply_patch << 'EOF'
*** Begin Patch
*** Add File: FOO_BAR.md
+ # FOO BAR Exploration Log
+
+ **Date:** 2025-04-17
+
+ ## Project Context Summary
+
+ - **Services:**
// Removed to not leak information
*** End Patch
EOF"
gytis-ivaskevicius · 1 year ago

same issue while editing a file

codex-maintainers · 1 year ago

Thank you for the feedback! Please try again on the latest version of Codex CLI. If the issue persists, we're happy to take a look.