{"record":{"id":"56c2d9e22574e00a","repo":"langchain-ai/deepagents","slug":"external-editor-executable-or-temporary-file-was-n","errorCode":null,"errorMessage":"External editor executable or temporary file was not found","messagePattern":"External editor executable or temporary file was not found","errorType":"exception","errorClass":"ExternalEditorError","httpStatus":null,"severity":"error","filePath":"libs/code/deepagents_code/editor.py","lineNumber":192,"sourceCode":"        edited = Path(tmp_path).read_text(encoding=\"utf-8\")\n\n        # Normalize line endings\n        edited = edited.replace(\"\\r\\n\", \"\\n\").replace(\"\\r\", \"\\n\")\n\n        # Most editors append a final newline on save (POSIX convention).\n        # Strip exactly one so the cursor lands on content, not a blank line,\n        # while preserving any intentional trailing newlines the user added.\n        edited = edited.removesuffix(\"\\n\")\n\n        # Chat composition historically treats a blank result as cancellation;\n        # callers with their own submit-time validation may opt in to preserving it.\n        if not allow_empty and not edited.strip():\n            return None\n\n    except FileNotFoundError as exc:\n        if raise_on_error:\n            msg = \"External editor executable or temporary file was not found\"\n            raise ExternalEditorError(msg) from exc\n        return None\n    except Exception as exc:\n        logger.warning(\"Editor failed\", exc_info=True)\n        if raise_on_error:\n            msg = \"External editor failed\"\n            raise ExternalEditorError(msg) from exc\n        return None\n    else:\n        return edited\n    finally:\n        if tmp_path is not None:\n            with contextlib.suppress(OSError):\n                Path(tmp_path).unlink(missing_ok=True)\n","sourceCodeStart":174,"sourceCodeEnd":206,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/code/deepagents_code/editor.py#L174-L206","documentation":"While opening the external editor, Python raised `FileNotFoundError` — either the editor executable was not on PATH, or the temporary markdown file could not be created or found. With `raise_on_error=True` this is re-raised as `ExternalEditorError` with this message, chained to the original exception (`raise ... from exc`).","triggerScenarios":"`open_in_editor(raise_on_error=True)` where the resolved editor binary is missing from PATH, or the `NamedTemporaryFile`/filesystem interaction raises `FileNotFoundError` (e.g. deleted TMPDIR, unmounted tmpfs).","commonSituations":"Editor configured by name that only exists in an interactive shell's PATH (dotfiles not loaded); editor uninstalled after configuration; containers missing a temp directory; sandboxed environments blocking /tmp access.","solutions":["Confirm the editor executable exists and is on PATH (`which <editor>`), or configure an absolute path.","Check that your temp directory (`$TMPDIR`/`/tmp`) exists and is writable.","Inspect `exc.__cause__` to see whether the editor binary or the temp file was missing.","If the environment cannot be fixed, catch `ExternalEditorError` and fall back to an in-app editing path."],"exampleFix":"// before\n\"editor\": \"code\"  # not on PATH in server context\n// after\n\"editor\": \"/usr/local/bin/code\"","handlingStrategy":"try-catch","validationCode":"import os, shutil, tempfile\n\ndef editor_ready() -> bool:\n    editor = os.environ.get(\"EDITOR\", \"\")\n    return (\n        bool(editor)\n        and shutil.which(editor) is not None\n        and os.path.isdir(tempfile.gettempdir())\n    )","typeGuard":null,"tryCatchPattern":"try:\n    edited = open_in_editor(text, raise_on_error=True)\nexcept ExternalEditorError as exc:\n    logger.error(\"Editor launch failed: %r (cause: %r)\", exc, exc.__cause__)\n    edited = None","preventionTips":["Configure the editor with an absolute path.","Keep the temp directory present and writable in containers.","Re-verify editor availability after environment changes (new shell, container rebuild)."],"tags":["editor","file-not-found","path","environment"],"backgroundTag":"executable-not-found","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}