[BUG] `claude update` downgrades from 2.1.12 to 2.1.2 due to string comparison bug

Resolved 💬 2 comments Opened Jan 19, 2026 by wzdmc Closed Jan 19, 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?

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" is true (because "1" < "2" character by character)
  • - Correct numeric comparison: 12 > 2, so 2.1.12 is actually newer than 2.1.2

What Should Happen?

The claude update command should use proper semantic versioning comparison:

  1. Version 2.1.12 should be recognized as newer than 2.1.2
  2. 2. Running claude update on version 2.1.12 should report "Already up to date" (assuming 2.1.12 is the latest)
  3. 3. The version comparison should split version strings by . and compare each segment as integers, not strings

Error Messages/Logs

Steps to Reproduce

  1. Have Claude Code version 2.1.12 installed (or any version with patch number >= 10)
  2. 2. Run claude update
  3. 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_

View original on GitHub ↗

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