ENXIO error when using --mcp-config or --settings flags in VS Code/Cursor terminal
Description
Claude Code crashes with an ENXIO error when using --mcp-config or --settings CLI flags from within VS Code or Cursor's integrated terminal. The error occurs because Claude Code attempts to watch socket files in /tmp.
Reproduction
- Open VS Code or Cursor integrated terminal
- Run:
cat > /tmp/test-mcp.json << 'CONF' {"mcpServers": {}} CONF cat > /tmp/test-settings.json << 'CONF' {"permissions": {}} CONF claude --mcp-config /tmp/test-mcp.json --settings /tmp/test-settings.json
Error
This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:
Error: ENXIO: no such device or address, watch '/tmp/vscode-ipc-99f341f6-5ab5-4174-ae1c-4222ae9eaf99.sock'
at watch (unknown)
at new FSWatcher (node:fs:30:31)
at watch (node:fs:300:23)
at oMI (/$bunfs/root/claude:389:6265)
at Nv0 (/$bunfs/root/claude:389:11478)
at _watchWithNodeFs (/$bunfs/root/claude:389:6746)
at _handleFile (/$bunfs/root/claude:389:7489)
at _addToNodeFs (/$bunfs/root/claude:389:10516)
at processTicksAndRejections (native:7:39)
Environment
- Claude Code version: 2.0.76
- Platform: Linux (Ubuntu)
- Terminal: Cursor integrated terminal
- Installation: Native binary (~/.local/bin/claude)
Notes
- Running plain
claudewithout these flags works fine - The socket file being watched (
/tmp/vscode-ipc-*.sock) is a VS Code IPC socket - Unsetting
VSCODE_IPC_HOOK_CLIand related env vars does not fix the issue - Setting
TMPDIRto a different directory also does not help - Issue does not occur in external terminals (outside VS Code/Cursor)
Workaround
Use .mcp.json project file instead of --mcp-config flag, or run from an external terminal.
Additional info: The issue is broader than just VS Code sockets. Claude Code appears to be watching the entire /tmp directory when config files are passed from there via --mcp-config or --settings flags.
Multiple types of stale files in /tmp trigger this:
wandb_gpu_stats-*.sock(Weights & Biases GPU monitoring)vscode-ipc-*.sock(VS Code/Cursor IPC)- Deleted temp files (
/tmp/tmps92pqyn0,/tmp/0083cff0-...)
Workaround: Store config files in a directory other than /tmp (e.g., ~/.cache/myapp/) to avoid the watching issue.
Found 3 possible duplicate issues:
- https://github.com/anthropics/claude-code/issues/14438
- https://github.com/anthropics/claude-code/issues/15073
- https://github.com/anthropics/claude-code/issues/15068
This issue will be automatically closed as a duplicate in 3 days.
- If your issue is a duplicate, please close it and 👍 the existing issue instead
- To prevent auto-closure, add a comment or 👎 this comment
🤖 Generated with Claude Code
#!/bin/bash
This script creates temporary JSON config files and runs the 'claude' command with them.
It includes error handling, unique temp file creation, and cleanup for robustness.
Function to clean up temp files on exit
cleanup() { if [[ -n "$MCP_FILE" && -f "$MCP_FILE" ]]; then rm -f "$MCP_FILE" fi if [[ -n "$SETTINGS_FILE" && -f "$SETTINGS_FILE" ]]; then rm -f "$SETTINGS_FILE" fi } trap cleanup EXIT # Ensure cleanup runs on script exit
Check if 'claude' command is available
if ! command -v claude &> /dev/null; then echo "Error: 'claude' command not found. Please ensure it is installed and in your PATH." echo "If this is Claude AI, you might need to install the CLI tool (e.g., via npm or pip)." exit 1 fi
Create unique temp files
MCP_FILE=$(mktemp /tmp/test-mcp-XXXXXX.json) if [[ $? -ne 0 ]]; then echo "Error: Failed to create temporary MCP config file." exit 1 fi
SETTINGS_FILE=$(mktemp /tmp/test-settings-XXXXXX.json) if [[ $? -ne 0 ]]; then echo "Error: Failed to create temporary settings file." exit 1 fi
Write JSON content to temp files
cat > "$MCP_FILE" << 'EOF' {"mcpServers": {}} EOF if [[ $? -ne 0 ]]; then echo "Error: Failed to write to $MCP_FILE." exit 1 fi
cat > "$SETTINGS_FILE" << 'EOF' {"permissions": {}} EOF if [[ $? -ne 0 ]]; then echo "Error: Failed to write to $SETTINGS_FILE." exit 1 fi
Run the claude command with the configs
echo "Running: claude --mcp-config $MCP_FILE --settings $SETTINGS_FILE" claude --mcp-config "$MCP_FILE" --settings "$SETTINGS_FILE" EXIT_CODE=$?
Report success or failure
if [[ $EXIT_CODE -eq 0 ]]; then echo "Command completed successfully." else echo "Error: 'claude' command failed with exit code $EXIT_CODE." exit $EXIT_CODE fi
Cleanup is handled by the trap on exit
Try this one 👆🏻
A workaround which worked for me since claude code seems to respect TMPDIR:
#!/usr/bin/env bash
export TMPDIR=/tmp/claude-tmp
mkdir -p "$TMPDIR"
claude
Since there are no socket files in /tmp/claude-tmp, this should work
Also seeing this with node-cdp sockets:
Error: ENXIO: no such device or address, watch '/tmp/node-cdp.4602-eb06ee52-77.sock'
Same root cause - FSWatcher trying to watch transient socket files in /tmp. Doesn't block anything but pollutes the logs.
Environment: Linux 6.14.0, VS Code extension
Closing for now — inactive for too long. Please open a new issue if this is still relevant.
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.