[BUG] TypeError "Cannot assign to read only property" when launching in PTY mode with large workspace

Resolved 💬 5 comments Opened Jan 3, 2026 by matcampi Closed Feb 20, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

Claude CLI 2.0.76 crashes with TypeError: Cannot assign to read only property '0' of object '[object String]' when launched in PTY (pseudo-terminal) mode with a workspace containing multiple markdown files. The same workspace works correctly in normal interactive mode.

Title: TypeError "Cannot assign to read only property" when launching in PTY mode with large workspace

---

Description

Claude CLI 2.0.76 crashes with TypeError: Cannot assign to read only property '0' of object '[object String]' when launched in PTY (pseudo-terminal) mode with a workspace containing multiple markdown files. The same workspace works correctly in normal interactive mode.

---

Steps to Reproduce

  1. Create a workspace with:
  • CLAUDE.md (~500 lines)
  • 15-27 skill files in .claude/skills/ (each ~100-300 lines markdown)
  • .claude/rules/, .claude/commands/, .claude/hooks/
  • .claude.json with MCP server configuration
  1. Launch Claude CLI using PTY fork in Python:

```python
import pty
import os

env = os.environ.copy()
env['TERM'] = 'xterm-256color'

pid, master_fd = pty.fork()
if pid == 0:
os.chdir('/path/to/workspace')
os.execvpe('claude', ['claude'], env)
```

  1. Claude starts loading workspace and crashes immediately

---

Expected Behavior

Claude should successfully load the workspace and start an interactive session, as it does when launched normally (without PTY).

---

Actual Behavior

Claude crashes during workspace loading with:

ERROR  Cannot assign to read only property '0' of object '[object String]'

file:///home/agent/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:12:1257

- gw9 (file:///.../cli.js:12:1257)
- Xq9 (file:///.../cli.js:12:3539)
- Le9 (file:///.../cli.js:43:10406)
- xe9 (file:///.../cli.js:43:11195)
- (file:///.../cli.js:3548:641)
- Array.forEach (<anonymous>)
- O47 (file:///.../cli.js:3548:162)
- (file:///.../cli.js:3548:1066)
- Array.map (<anonymous>)
- VH1 (file:///.../cli.js:3548:917)

Process exits immediately after error.

---

Environment

  • Claude Code Version: 2.0.76
  • Installation Method: npm install -g @anthropic-ai/claude-code
  • Node.js Version: (run node --version to check)
  • OS: Ubuntu 20.04 LTS (Linux 5.15.0-164-generic)
  • Execution Mode: PTY fork via Python pty.fork()

---

Additional Context

Key Observations:

  1. PTY-specific bug: Same workspace loads successfully in normal mode

``bash
cd /path/to/workspace && claude # ✅ Works fine
``

  1. Size threshold: Bug appears with ~15+ markdown files
  • Workspace with 5 skills: ✅ Works
  • Workspace with 27 skills: ❌ Crashes
  1. Call stack indicates string mutation: The error occurs in minified code trying to modify immutable string properties during array operations
  1. Use case impact: This bug blocks web-based terminal implementations that need to spawn Claude CLI in PTY for browser-based interaction

Workaround:

Reduce workspace to <10 skill files for PTY mode. This limits functionality but prevents crash.

---

Suggested Fix

The code at cli.js:12:1257 (in functions gw9, Xq9, etc.) appears to be modifying strings in-place during file parsing. Strings in JavaScript are immutable - the code should create copies before modification:

// Current (buggy):
stringArray.forEach(str => {
    str[0] = str[0].toUpperCase(); // TypeError!
});

// Fixed:
stringArray = stringArray.map(str => {
    return str[0].toUpperCase() + str.slice(1); // Creates new string
});

What Should Happen?

Claude should successfully load the workspace and start an interactive session, as it does when launched normally (without PTY).

Error Messages/Logs

Claude crashes during workspace loading with:


ERROR  Cannot assign to read only property '0' of object '[object String]'

file:///home/agent/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:12:1257

- gw9 (file:///.../cli.js:12:1257)
- Xq9 (file:///.../cli.js:12:3539)
- Le9 (file:///.../cli.js:43:10406)
- xe9 (file:///.../cli.js:43:11195)
- (file:///.../cli.js:3548:641)
- Array.forEach (<anonymous>)
- O47 (file:///.../cli.js:3548:162)
- (file:///.../cli.js:3548:1066)
- Array.map (<anonymous>)
- VH1 (file:///.../cli.js:3548:917)


Process exits immediately after error.

Steps to Reproduce

  1. Create a workspace with:
  • CLAUDE.md (~500 lines)
  • 15-27 skill files in .claude/skills/ (each ~100-300 lines markdown)
  • .claude/rules/, .claude/commands/, .claude/hooks/
  • .claude.json with MCP server configuration
  1. Launch Claude CLI using PTY fork in Python:

```python
import pty
import os

env = os.environ.copy()
env['TERM'] = 'xterm-256color'

pid, master_fd = pty.fork()
if pid == 0:
os.chdir('/path/to/workspace')
os.execvpe('claude', ['claude'], env)
```

  1. Claude starts loading workspace and crashes immediately

Claude Model

Sonnet (default)

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.0.76

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

_No response_

View original on GitHub ↗

This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗