# Atlas error: Editor exited with code <n> when opening the external editor

> Point EDITOR or VISUAL at an installed binary and use an editor that blocks until the file is closed, for example `code --wait`, not bare `code`.

Atlas fails with Editor exited with code <n>, or Editor exited with signal <sig>, because the Atlas TUI spawns your editor with stdio inherited and rejects when the child exits non-zero or is killed by a signal. Check that the EDITOR or VISUAL environment variable actually points at an installed binary, and use an editor that blocks until the file is closed, for example `code --wait` rather than bare `code`. On Windows the child is spawned with shell: true, so quote a path containing spaces. The temporary file is removed in the finally block either way, so nothing is left behind.

## Symptom

Opening the prompt in an external editor from the Atlas TUI fails with: Editor exited with code <n>, or: Editor exited with signal <sig>. The prompt you were editing does not come back into the TUI.

## Cause

The Atlas TUI spawns your editor with stdio inherited and rejects when the child exits non-zero or is killed by a signal. A missing binary behind EDITOR or VISUAL, a non-blocking editor that returns immediately, or an unquoted Windows path with spaces all produce a non-zero exit or a signal. The temporary file is removed in the finally block either way.

## Fix

1. Check the EDITOR or VISUAL environment variable actually points at an installed binary. A stale value naming an editor you removed exits non-zero immediately.
2. Use an editor that blocks until the file is closed, for example `code --wait`, not bare `code`. A non-blocking editor returns control before you have saved anything.
3. On Windows the child is spawned with shell: true, so quote a path containing spaces in EDITOR or VISUAL.
4. Retype the prompt directly in the Atlas TUI if the editor cannot be fixed right now. The TUI prompt still works without an external editor.
5. Re-open the external editor from the Atlas TUI and confirm neither Editor exited with code <n> nor Editor exited with signal <sig> appears.

## Why does Atlas say Editor exited with code <n>

Atlas says Editor exited with code <n> because the Atlas TUI spawns your editor with stdio inherited and rejects whenever the child ends with a status other than 0. The 2 messages, Editor exited with code <n> and Editor exited with signal <sig>, cover a bad exit status and a kill signal.

Opening the prompt in an external editor means Atlas writes a temporary file, hands it to the binary named by EDITOR or VISUAL, and waits. Because stdio is inherited, the editor takes over your terminal directly, which is what makes a terminal editor usable from inside the Atlas TUI. When the editor exits non-zero, Atlas has no reliable way to know whether the file reflects what you meant, so it rejects rather than guessing. The temporary file is removed in the finally block either way, so a failed edit does not litter your filesystem.

## How to fix EDITOR or VISUAL pointing at a missing binary

Check that the 2 environment variables Atlas reads, EDITOR and VISUAL, actually point at an installed binary. Atlas spawns exactly what those variables name, so a value referencing an editor you uninstalled, renamed, or never installed fails instantly and surfaces as Editor exited with code <n> before any editing buffer appears.

Print the value of EDITOR and VISUAL and run that command by hand against any file. If the shell cannot find it, Atlas cannot either. Remember that the variable must be visible to the process running the Atlas TUI, not only to your interactive shell, so a value exported in a profile that Atlas never sourced is effectively unset. Set EDITOR or VISUAL to an editor that is genuinely on PATH for that process, then re-open the external editor from the TUI.

## Why bare `code` fails and `code --wait` works with Atlas

In Atlas as of 2026, bare `code` fails because it returns immediately after handing the file to an already running VS Code window, while the Atlas TUI waits for the child process to end. Use an editor that blocks until the file is closed, for example `code --wait`.

Atlas's external editor flow depends on the child process ending when your edit ends. Without --wait, the `code` launcher exits as soon as it has delegated the file, so Atlas either reads a temporary file you have not touched yet or rejects on the exit status. Setting EDITOR to `code --wait` makes the launcher block until the tab is closed, which is the contract Atlas needs. The same rule applies to any GUI editor with a launcher shim: find its blocking flag and use it, or use a terminal editor that inherently blocks.

## How to set an editor path with spaces on Windows for Atlas

On Windows, Atlas spawns the external editor child with shell: true, so quote a path containing spaces in EDITOR or VISUAL. An unquoted Program Files path is split by the shell into 2 or more arguments, and the first is not a real binary, which produces Editor exited with code <n>.

Because shell: true routes the command through the Windows shell, quoting is the shell's problem, not Atlas's. Wrap the executable path in quotes inside the environment variable value so the shell treats it as one token. Verify by running the exact same quoted string in a Windows shell against a scratch file: if the editor opens and blocks, Atlas will get the same behavior. If it does not, fix the quoting before blaming the Atlas TUI.

## How to verify the external editor fix worked

Verify the Atlas external editor fix by opening the prompt in the editor again and saving. A working setup returns you to the Atlas TUI with the edited prompt loaded, and neither of the 2 failures, Editor exited with code <n> and Editor exited with signal <sig>, appears. Atlas removes the temporary file in the finally block regardless of outcome.

Test with a real edit rather than an immediate quit, because an editor that exits non-zero on quit without save can still fail even when the path and blocking behavior are correct. If the editor opens, blocks, saves, and hands the text back to the Atlas TUI, the configuration is right. If it still fails after fixing EDITOR or VISUAL, blocking, and quoting, retype the prompt in the TUI for now: the TUI prompt does not depend on an external editor, so you are never blocked from working.

## FAQ

### Why does Atlas say Editor exited with code <n>?

The Atlas TUI spawns your editor with stdio inherited and rejects when the child exits non-zero. The usual causes are EDITOR or VISUAL pointing at a missing binary, a non-blocking editor, or an unquoted Windows path with spaces.

### What does Editor exited with signal <sig> mean in Atlas?

Editor exited with signal <sig> means the editor child process was killed by a signal rather than exiting on its own. Atlas rejects the edit, and the temporary file is removed in the finally block either way.

### Why does bare `code` not work as my Atlas editor?

Bare `code` returns immediately instead of blocking. Use an editor that blocks until the file is closed, for example `code --wait`, so the child process stays alive until you finish editing the prompt.

### Which env var does Atlas use for the external editor?

Atlas uses the EDITOR or VISUAL environment variable. Check that the value actually points at an installed binary that is visible to the process running the Atlas TUI, not only to your login shell.

### How do I set an editor path with spaces on Windows for Atlas?

On Windows the child is spawned with shell: true, so quote a path containing spaces in EDITOR or VISUAL. Without quotes the shell splits the path into separate arguments and the spawn fails.

### Does a failed Atlas editor launch leave a temp file behind?

No. The temporary file Atlas writes for the external editor is removed in the finally block either way, so a failed edit does not leave a stray file on disk.

### Can I still write a prompt if my Atlas editor is broken?

Yes. Retype the prompt in the Atlas TUI if the editor cannot be fixed right now. The external editor is a convenience, and the TUI prompt works without it.

---

Canonical HTML: https://runatlas.sh/resources/troubleshooting/tui-external-editor-failed
Source of truth: aeo_pages row `/resources/troubleshooting/tui-external-editor-failed` (segment: Troubleshooting) (this file is generated from it, never hand-edited).
Licence: Atlas is proprietary with a free core. It is not open source and there is no public source repository.
