logoalt Hacker News

phyrexlast Wednesday at 8:36 PM3 repliesview on HN

workaround from the issue discussion:

```

  Problem: Claude Code 2.1.0 crashes with Invalid Version: 2.1.0 (2026-01-07) because the CHANGELOG.md format changed to include dates in version headers (e.g., ## 2.1.0 (2026-01-07)). The code parses these headers as object keys and tries to sort them using semver's .gt() function, which can't parse version strings with date suffixes.

  Affected functions: W37, gw0, and an unnamed function around line 3091 that fetches recent release notes.

  Fix: Wrap version strings with semver.coerce() before comparison. Run these 4 sed commands on cli.js:

  CLI_JS="$HOME/.nvm/versions/node/$(node -v)/lib/node_modules/@anthropic-ai/claude-code/cli.js"

  # Backup first
  cp "$CLI_JS" "$CLI_JS.backup"

  # Patch 1: Fix ve2.gt sort (recent release notes)
  sed -i 's/Object\.keys(B)\.sort((Y,J)=>ve2\.gt(Y,J,{loose:!0})?-1:1)/Object.keys(B).sort((Y,J)=>ve2.gt(ve2.coerce(Y),ve2.coerce(J),{loose:!0})?-1:1)/g' "$CLI_JS"

  # Patch 2: Fix gw0 sort
  sed -i 's/sort((G,Z)=>Wt\.gt(G,Z,{loose:!0})?1:-1)/sort((G,Z)=>Wt.gt(Wt.coerce(G),Wt.coerce(Z),{loose:!0})?1:-1)/g' "$CLI_JS"

  # Patch 3: Fix W37 filter
  sed -i 's/filter((\[J\])=>!Y||Wt\.gt(J,Y,{loose:!0}))/filter(([J])=>!Y||Wt.gt(Wt.coerce(J),Y,{loose:!0}))/g' "$CLI_JS"

  # Patch 4: Fix W37 sort
  sed -i 's/sort((\[J\],\[X\])=>Wt\.gt(J,X,{loose:!0})?-1:1)/sort(([J],[X])=>Wt.gt(Wt.coerce(J),Wt.coerce(X),{loose:!0})?-1:1)/g' "$CLI_JS"

  Note: If installed via different method, adjust CLI_JS path accordingly (e.g., /usr/lib/node_modules/@anthropic-ai/claude-code/cli.js).
```

Replies

MattDaEskimolast Wednesday at 8:57 PM

Parsing markdown into a data structure without any sort of error handling is diabolical for a company like Anthropic

show 2 replies
wowoclast Thursday at 9:40 AM

Running sed commands manually in 2026? Just tell Codex to fix your Claude Code