[BUG] 'claude update' downgrades from 2.1.0 to 2.0.76 due to lexicographic version comparison

Resolved 💬 7 comments Opened Jan 7, 2026 by ras434 Closed Feb 22, 2026

Bug Description

The claude update command incorrectly identifies version 2.0.76 as newer than 2.1.0, resulting in a downgrade instead of an update.

Reproduction Steps

  1. Have Claude Code version 2.1.0 installed
  2. Run claude update
  3. Observe the downgrade to 2.0.76

Expected Behavior

The update command should recognize that 2.1.0 is newer than 2.0.76 and either:

  • Report "Already on latest version"
  • Not perform any update

Actual Behavior

Current version: 2.1.0
Checking for updates...
New version available: 2.0.76 (current: 2.1.0)
Installing update...
Using local installation update method...
Successfully updated from 2.1.0 to version 2.0.76

Root Cause Analysis

The version comparison logic appears to use lexicographic (string) comparison instead of semantic versioning comparison:

  • String comparison: "2.0.76" > "2.1.0" → true (because "0" > "1" is false, but "76" has more digits)
  • Semantic version comparison: 2.0.76 < 2.1.0 → true (correct: minor version 1 > 0)

Verification

Confirmed that 2.1.0 is the latest published version on npm:

$ npm view @anthropic-ai/claude-code version
2.1.0

Published versions ending with:

  ...
  "2.0.74",
  "2.0.75",
  "2.0.76",
  "2.0.77",
  "2.1.0"

Impact

  • Users on 2.1.0 are unintentionally downgraded to 2.0.76
  • Loss of features/fixes introduced in 2.1.0
  • Confusing user experience ("update" performs downgrade)

Suggested Fix

Implement proper semantic version comparison using a library like semver:

const semver = require('semver');
if (semver.gt(latestVersion, currentVersion)) {
  // Perform update
}

Environment

  • Platform: macOS (likely affects all platforms)
  • Version before: 2.1.0
  • Version after: 2.0.76
  • Installation method: npm/local

Related Issues

Possibly related to #15672 (plugin update downgrade issue), though that specifically mentions "oldest cached version" for plugins.

View original on GitHub ↗

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