What's?
Claude Codeのドキュメントを見ていて、いつの間にかネイティブ版のインストールのセクションにWindowsがふつうに入っていたので試してみました。
Windows版のClaude Code(ネイティブ版)
Claude Codeのインストール方法はすでにネイティブ版が推奨になっていますが、Windowsはまだ、みたいな状態だったと思います。
が、いつの間にかPowerShellでのインストール方法がLinuxやmacOSと同列に記載されるようになっていました。
irm https://claude.ai/install.ps1 | iex
CHANGELOGを見ても、ネイティブ版のWindows対応に関する話は書かれていませんけどね…?
ちなみに、特に紹介されていませんがwingetにもいました。
PS > winget search claudecode
名前 ID バージョン ソース
-------------------------------------------------------------------------------------------------
Claude Code Anthropic.ClaudeCode 2.0.50 winget
claude-code-config-manager ronghuaxueleng.ClaudeCodeConfigManager 1.4.0 winget
Claude Code 配置管理器 - 命令行版本 ronghuaxueleng.ClaudeCodeConfigManager.CLI 1.6.0 winget
wingetでのマニフェストはこちら。
今回は両方を試してみたいと思います。
環境
今回の環境はこちら。Windows 11です。
PS > [System.Environment]::OSVersion
Platform ServicePack Version VersionString
-------- ----------- ------- -------------
Win32NT 10.0.22621.0 Microsoft Windows NT 10.0.22621.0
PS > $PSVersionTable.PSVersion
Major Minor Build Revision
----- ----- ----- --------
5 1 22621 6060
Claude Codeのネイティブ版をインストールする
では、こちらに従ってインストールしてみます。
実行。
PS > irm https://claude.ai/install.ps1 | iex
ネイティブ版をインストールしているらしき動きが見えます。
Setting up Claude Code...
Installing Claude Code native build stable...
完了しました。
Setting up Claude Code...
✔ Claude Code successfully installed!
Version: 2.0.50
Location: C:\Users\user\.local\bin\claude.exe
Next: Run claude --help to get started
⚠ Setup notes:
• Native installation exists but C:\Users\user\.local\bin is not in your PATH. Add it by opening: System Properties → Environment Variables → Edit User PATH → New → Add the path
above. Then restart your terminal.
✅ Installation complete!
C:\Users\user\.local\binにインストールしたようです。
すごいところ(?)にインストールしますね。Linuxなどと同じですが、XDG Base Directory Specificationをそのまま持ち込んでいる感じですね。
パスに追加しないといけないので、$PROFILEに追加しておきます。
# Pathの追加
$Env:Path=$Env:USERPROFILE+"\.local\bin;"+$Env:Path
PowerShellを再起動すればClaude Codeが使えるようになっています。
PS > claude --version
2.0.50 (Claude Code)
Welcome to Claude Code v2.0.50
…………………………………………………………………………………………………………………………………………………………
* █████▓▓░
* ███▓░ ░░
░░░░░░ ███▓░
░░░ ░░░░░░░░░░ ███▓░
░░░░░░░░░░░░░░░░░░░ * ██▓░░ ▓
░▓▓███▓▓░
* ░░░░
░░░░░░░░
░░░░░░░░░░░░░░░░
█████████ *
██▄█████▄██ *
█████████ *
…………………█ █ █ █………………………………………………………………………………………………………………
Let's get started.
Choose the text style that looks best with your terminal
To change this later, run /theme
❯ 1. Dark mode ✔
2. Light mode
3. Dark mode (colorblind-friendly)
4. Light mode (colorblind-friendly)
5. Dark mode (ANSI colors only)
6. Light mode (ANSI colors only)
╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌
1 function greet() {
2 - console.log("Hello, World!");
2 + console.log("Hello, Claude!");
3 }
ちなみに%USERPROFILE%\.localでtreeを実行すると以下のようになるので、構造もLinuxなどと同じですね。
PS C:\Users\user\.local> tree /f
Folder PATH listing for volume Windows
Volume serial number is E604-3346
C:.
├───bin
│ claude.exe
│
├───share
│ └───claude
│ └───versions
│ 2.0.50
│
└───state
└───claude
└───locks
コマンド?
ところでこちらのirmとiexが見慣れなかったので調べてみました。
PS > irm https://claude.ai/install.ps1 | iex
それぞれInvoke-RestMethod、Invoke-Expressionのエイリアスのようです。
つまり、ここで止めると
PS > irm https://claude.ai/install.ps1
PowerShellのスクリプトが返ってきます。
param(
[Parameter(Position=0)]
[ValidatePattern('^(stable|latest|\d+\.\d+\.\d+(-[^\s]+)?)$')]
[string]$Target = "stable"
)
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"
$ProgressPreference = 'SilentlyContinue'
# Check for 32-bit Windows
if (-not [Environment]::Is64BitProcess) {
Write-Error "Claude Code does not support 32-bit Windows. Please use a 64-bit version of Windows."
exit 1
}
$GCS_BUCKET = "https://storage.googleapis.com/claude-code-dist-86c565f3-f756-42ad-8dfa-d59b1c096819/claude-code-releases"
$DOWNLOAD_DIR = "$env:USERPROFILE\.claude\downloads"
# Always use x64 for Windows (ARM64 Windows can run x64 through emulation)
$platform = "win32-x64"
New-Item -ItemType Directory -Force -Path $DOWNLOAD_DIR | Out-Null
# Always download stable version (which has the most up-to-date installer)
try {
$version = Invoke-RestMethod -Uri "$GCS_BUCKET/stable" -ErrorAction Stop
}
catch {
Write-Error "Failed to get stable version: $_"
exit 1
}
try {
$manifest = Invoke-RestMethod -Uri "$GCS_BUCKET/$version/manifest.json" -ErrorAction Stop
$checksum = $manifest.platforms.$platform.checksum
if (-not $checksum) {
Write-Error "Platform $platform not found in manifest"
exit 1
}
}
catch {
Write-Error "Failed to get manifest: $_"
exit 1
}
# Download and verify
$binaryPath = "$DOWNLOAD_DIR\claude-$version-$platform.exe"
try {
Invoke-WebRequest -Uri "$GCS_BUCKET/$version/$platform/claude.exe" -OutFile $binaryPath -ErrorAction Stop
}
catch {
Write-Error "Failed to download binary: $_"
if (Test-Path $binaryPath) {
Remove-Item -Force $binaryPath
}
exit 1
}
# Calculate checksum
$actualChecksum = (Get-FileHash -Path $binaryPath -Algorithm SHA256).Hash.ToLower()
if ($actualChecksum -ne $checksum) {
Write-Error "Checksum verification failed"
Remove-Item -Force $binaryPath
exit 1
}
# Run claude install to set up launcher and shell integration
Write-Output "Setting up Claude Code..."
try {
if ($Target) {
& $binaryPath install $Target
}
else {
& $binaryPath install
}
}
finally {
try {
# Clean up downloaded file
# Wait a moment for any file handles to be released
Start-Sleep -Seconds 1
Remove-Item -Force $binaryPath
}
catch {
Write-Warning "Could not remove temporary file: $binaryPath"
}
}
Write-Output ""
Write-Output "$([char]0x2705) Installation complete!"
Write-Output ""
なので、やっていることはcurl+bashと同じですね。
wingetでインストールする
次はwingetでインストールしてみましょう。
PS > winget install Anthropic.ClaudeCode
ダウンロードが始まります。
見つかりました Claude Code [Anthropic.ClaudeCode] バージョン 2.0.50
このアプリケーションは所有者からライセンス供与されます。
Microsoft はサードパーティのパッケージに対して責任を負わず、ライセンスも付与しません。
ダウンロード中 https://storage.googleapis.com/claude-code-dist-86c565f3-f756-42ad-8dfa-d59b1c096819/claude-code-releases/2.0.50/win32-x64/claude.exe
インストールされました。こちらは自動的にパスに追加されるので、PowerShellを再起動すれば使うことができます。
PS > claude --version
2.0.50 (Claude Code)
で、どこにインストールされたかというとwingetのパッケージ管理側ですね。
PS > Get-Command claude
CommandType Name Version Source
----------- ---- ------- ------
Application claude.exe 2.0.50.0 C:\Users\user\AppData\Local\Microsoft\WinGet\Links\claude.exe
実際のファイルは以下にありました。
C:\Users\user\AppData\Local\Microsoft\WinGet\Packages\Anthropic.ClaudeCode_Microsoft.Winget.Source_8wekyb3d8bbwe\claude.exe
インストーラーはどこから取得しているかというと、マニフェストを見るとこちらになっています。
Installers:
- Architecture: x64
InstallerUrl: https://storage.googleapis.com/claude-code-dist-86c565f3-f756-42ad-8dfa-d59b1c096819/claude-code-releases/2.0.50/win32-x64/claude.exe
InstallerSha256: 4BFB8BF794484CBF4902BAED20BFDD631F17E01C4B027D841C1903ECE2EB44F5
ダウンロード時の内容を見てもよいですね。
ダウンロード中 https://storage.googleapis.com/claude-code-dist-86c565f3-f756-42ad-8dfa-d59b1c096819/claude-code-releases/2.0.50/win32-x64/claude.exe
これはirm https://claude.ai/install.ps1 | iexで実行したスクリプト内にあった、以下のURLからバージョンを直接指定してダウンロードしたものということになります。
$GCS_BUCKET = "https://storage.googleapis.com/claude-code-dist-86c565f3-f756-42ad-8dfa-d59b1c096819/claude-code-releases"
なので、インストールされるものとしては同じですね。
どちらを選ぶかはお好みなのかなと思いますが、wingetで管理できた方が個人的には嬉しかったりします…。