Version parsing crash: Invalid Version with date suffix (2.1.0 (2026-01-07))
Bug Description
Claude Code crashes on startup with ERROR Invalid Version: 2.1.0 (2026-01-07) when version cache contains version strings with date suffixes.
Environment
- OS: Linux (WSL2 on Windows)
- Node.js: v24.8.0
- Claude Code Version: 2.1.0
- Install Method: npm global + previously had Bun installation
Error Output
ERROR Invalid Version: 2.1.0 (2026-01-07)
file:///home/gabe/.nvm/versions/node/v24.8.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:869:8900
- iT (file:///...cli.js:869:8900)
- SJ8 (file:///...cli.js:869:14028)
- Object.dJ8 (file:///...cli.js:869:14584)
- (file:///...cli.js:3091:4240)
- at Array.sort (<anonymous>)
- de2 (file:///...cli.js:3091:4224)
Root Cause
The version cache in ~/.claude/statsig/ and ~/.local/share/claude/versions/ contained version strings like 2.1.0 (2026-01-07) with a date suffix. When Claude Code tries to sort versions using semver parsing, it fails because 2.1.0 (2026-01-07) is not a valid semver string.
Cached data showed:
"version":"2.1.0","versionBase":"2.1.0","buildTime":"2026-01-07T02:42:37Z"
The version string 2.1.0 (2026-01-07) appears to be constructed somewhere combining version + date, but the version sorting code doesn't strip the date suffix before parsing.
Workaround
Clearing these directories fixed the issue:
rm -rf ~/.local/share/claude
rm -rf ~/.claude/cache
rm -rf ~/.claude/statsig
hash -r
Suggested Fix
- Strip date suffixes before semver parsing in version comparison logic
- Use
versionBaseinstead of the full display version for sorting - Add try-catch around version parsing to handle malformed versions gracefully
- Consider validating/cleaning cached version data on startup
Steps to Reproduce
- Have multiple Claude Code installations (e.g., Bun + npm)
- Have cached version data with date suffixes in statsig cache
- Run
claude- crashes before showing UI
🤖 Generated with Claude Code
This issue has 7 comments on GitHub. Read the full discussion on GitHub ↗