[BUG] `claude update` downgrades from 2.1.12 to 2.1.2 due to string comparison bug
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?
When running claude update, the CLI incorrectly identifies version 2.1.2 as newer than 2.1.12, resulting in a downgrade instead of staying on the current version.
Output:
Current version: 2.1.12
Checking for updates to stable version...
New version available: 2.1.2 (current: 2.1.12)
Installing update...
Using global installation update method...
Successfully updated from 2.1.12 to version 2.1.2
Root Cause (suspected):
The version comparison appears to use string comparison instead of semantic versioning comparison:
- String comparison:
"2.1.12" < "2.1.2"istrue(because"1" < "2"character by character) - - Correct numeric comparison:
12 > 2, so2.1.12is actually newer than2.1.2
What Should Happen?
The claude update command should use proper semantic versioning comparison:
- Version
2.1.12should be recognized as newer than2.1.2 - 2. Running
claude updateon version2.1.12should report "Already up to date" (assuming 2.1.12 is the latest) - 3. The version comparison should split version strings by
.and compare each segment as integers, not strings
Error Messages/Logs
Steps to Reproduce
- Have Claude Code version 2.1.12 installed (or any version with patch number >= 10)
- 2. Run
claude update - 3. Observe that it "updates" to version 2.1.2 (or lower patch version)
The bug occurs when the installed patch version (e.g., 12) has more digits than an older available version (e.g., 2), and string comparison is used instead of numeric comparison.
Claude Model
None
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
2.1.12 (downgraded to 2.1.2 after running update)
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
_No response_
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗