set setting reset

脂肪と糖にはたらくやつ

Claude Code 起動時の SessionStart:startup hook error の解決事例

概要

Claude Codeの起動時に発生していた SessionStart:startup hook error について、原因の深掘りと、プラグインの手動アップデートによる根本解決の記録です。


発生していた問題

Claude Codeセッション開始時に、以下のエラーが解消されない状態でした。

SessionStart:startup hook error

調査プロセス

1. 現状確認

ワーカープロセス自体は動作していましたが、フックスクリプトの手動実行により異常を検知しました。

claude-mem status
# Worker is running, PID: 63381, Port: 37777

2. 根本原因の特定

user-message-hook.js を直接実行したところ、Exit code 3 が返されることを発見。これはプラグイン内部で何らかの論理エラーが発生していることを示唆しています。

3. バージョンの不整合を確認

GitHubリポジトリ(marketplaces)を確認したところ、インストールされているバージョンが大幅に古いことが判明しました。

状態 バージョン 備考
インストール済み 8.0.4 20以上のコミット遅れ
最新版 (origin/main) 9.0.12 多数のバグ修正を内包

解決手順(手動アップデート)

最新版へ追従するため、以下の手順で手動更新を実施しました。

Step 1: ソースコードの更新

cd ~/.claude/plugins/marketplaces/thedotmack
git pull origin main
# 859行の変更を反映

Step 2: キャッシュディレクトリ(実行環境)の差し替え

# 古いキャッシュの削除
rm -rf ~/.claude/plugins/cache/thedotmack/claude-mem/8.0.4

# 新バージョン用ディレクトリの作成とコピー
mkdir -p ~/.claude/plugins/cache/thedotmack/claude-mem/9.0.12
cp -r ~/.claude/plugins/marketplaces/thedotmack/plugin/* \
      ~/.claude/plugins/cache/thedotmack/claude-mem/9.0.12/

Step 3: 設定ファイルの書き換え

~/.claude/installed_plugins.json 内のパスとバージョン情報を更新しました。

- "installPath": "~/.claude/plugins/cache/thedotmack/claude-mem/8.0.4",
- "version": "8.0.4",
+ "installPath": "~/.claude/plugins/cache/thedotmack/claude-mem/9.0.12",
+ "version": "9.0.12",

Step 4: 依存関係の再構築とワーカー起動

# 依存関係のインストール(Bunを使用)
node scripts/smart-install.js

# ワーカーの再起動
claude-mem restart

終結

アップデート後、すべてのステータスが正常化しました。

項目 更新前 (8.0.4) 更新後 (9.0.12)
Worker ステータス エラー Ready
MCP Ready - True
SessionStart hook Error Success

API確認:

curl -s http://127.0.0.1:37777/api/version   # {"version": "9.0.12"}
curl -s http://127.0.0.1:37777/api/readiness # {"status": "ready", "mcpReady": true}

学んだこと・まとめ

  1. バージョン不整合の罠: marketplaces(ソース)と cache(ランタイム)のバージョンが乖離すると、予期せぬ挙動を招く。
  2. Exit Code 3 の意味: フックスクリプト3 を返す場合は、内部ロジックの不備やバージョン依存のバグを疑う。
  3. 手動更新フロー: 自動更新がうまくいかない場合は「ソース取得 → キャッシュ配置 → json更新 → 依存関係解決」の順でリカバリ可能。

トラブルシューティング用コマンド

今後同様の問題が発生した際の確認用コマンドです。

# 1. プラグインの最新版(GitHub)との差分確認
cd ~/.claude/plugins/marketplaces/thedotmack
git fetch origin && git log HEAD..origin/main --oneline

# 2. ワーカーの詳細ステータス確認
claude-mem status
curl -s http://127.0.0.1:37777/api/version
curl -s http://127.0.0.1:37777/api/readiness

ThinkPadとMacBookの共用:KVM切替器と TEX Shinobi の BLE 5.0 Upgrade Kits を導入した話

背景

プライベート用の ThinkPad と仕事用の MacBook を使い分けていて、ディスプレイとキーボードを共用している。
ディスプレイは2枚。ケーブルの差し替えをせっせと行い、キーボードの切り替えには以下のスイッチャーを使っていた。

www.elecom.co.jp

これはこれで非常に便利だったが、在宅仕事の頻度が高くなるにつれ、物理的にディスプレイとキーボードを切り替えるのが面倒になってきた。

ダルい

課題

  • ディスプレイ切り替えのためのケーブルの抜き差しがダルい
  • キーボード切り替えのためにスイッチをカチカチするのがダルい

ディスプレイ切り替えの「抜き差し」をなくしたい

要はこうしたい

これを実現するためにこちらを購入した。

Amazon | UGREEN KVM切替器 2入力1出力 KVM 切り替え器 4K@60Hz HDMI KVMスイッチ ドライバ不要 USB3.0 & USB C 切替器 キーボード マウス モニターを共有 USB セレクター AVセレクター | UGREEN | 切替器 通販

結果、ディスプレイの切り替えはうまくいったが、どうにもキーボードを認識しない。
USB ケーブルを別途新規購入するなど試行錯誤してみたが、USB メモリすら認識しない。もしや初期不良?とも思われた。
しかしサポートに連絡するのも面倒で、「どうしたものかな……」となっていた。

キーボード切り替えの「スイッチ操作」をなくしたい

そういえば、愛用している TEX Shinobi には Bluetooth を拡張するモジュールが別売りされていたことを思い出した。

BLE 5.0 Upgrade Kitstex.com.tw

そもそも入力機器はバッテリーが切れるのが嫌だから有線接続という宗教であったこと、すでにケーブル等で2,000円くらい使ってしまっていたことから、送料込みで $60 ほど(今のレートだと安くはない)なのでちょっと躊躇われた。

が、引くに引けない感じだったので思い切って購入。ENELOOP もあるし。
DHL 経由で3、4日後くらいに到着した。

インフルエンザも回復したので、いざセットアップ。

……が、WindowsMac の双方でどうにも認識しない。Bluetooth 機器の検索に名前すら出てこないレベルで認識しない。
「いつでもペアリングできるでー」と Caps Lock キーは光っているのに。

BLE 5.0 Upgrade Kits doesn't workDuckDuckGo で検索すると、TEX 公式の以下のページがヒットした。

tex.com.tw

ファームウェア、そういうのもあるのか……とアップデートを試みる。
以下の2つの exe をダウンロードして、Windows 経由で実行した。 Mac でできるのかどうかはわからない。

BLE5.0 module for SHINOBI upgrade steps

1. Download Shinobi for BLE5 upgrade : Rev 4.04
2. Download BLE5 upgrade : Rev V1.0

1はすんなりできたが、2はそうもいかず。何度か PC を再起動するなど試行錯誤したらようやく完了できた。
そして BLE 5.0 キットのスイッチを ON にして、電源横のボタンを3秒長押し。Windows から Bluetooth の検索をかけると、無事認識された。

BLE 5.0 Upgrade Kit では3台までペアリングができるらしいので、MacBook でもやってみる。
2台目のペアリングは Fn + Volume Down キーを3秒長押しすることで、こちらも認識された。

これで晴れて、2台の端末からの無線操作が可能になった。

最終的に

こうなった。

  • ディスプレイの切り替えは KVM スイッチを押す
  • WindowsMac の切り替えは以下のショートカットで行う
    • Fn + Mute で Windows
    • Fn + Volume Downs で Macbook
    • Fn + Volume Up で3台めの何か

総額一万円くらいかかり、スイッチカチカチによる切り替えは残ったが、ケーブルが減ったのでよしとする。
なお、画像内でラップトップ同士を接続している謎のケーブルは、現実には存在しない。
消してといったけれど、nano banana が削除してくれなかったことだけ付言しておく。

TEX BLE Upgrade Kit クイックリファレンス

同梱の TEX BLE Upgrade Kits User Manual を元に、操作方法を整理した「チートシート」を作成した。 ShinobiとShuraでキー操作が異なるため、表形式で見やすくしている。 Shuraもほしくなってきた。

🟢 基本機能 (ユニット本体のボタン)

ボタン 機能 操作
Power button 電源 ON / OFF スイッチ切り替え
Pair button Bluetoothペアリング 3秒間 長押し

⌨️ キーボードショートカット (Bluetooth操作)

M_FN キーと組み合わせて操作します。

対象デバイス Shinobi の操作キー Shura の操作キー アクション
BT Device 1 M_FN + Mute M_FN + Q 切替: 短く押す
ペアリング: 3秒 長押し
BT Device 2 M_FN + Vol - M_FN + W 切替: 短く押す
ペアリング: 3秒 長押し
BT Device 3 M_FN + Vol + M_FN + E 切替: 短く押す
ペアリング: 3秒 長押し

🔌 有線接続モード (USB)

機能 操作キー (共通) 条件
USBホストへ切替 M_FN + ESC PCとUSBケーブルで接続されていること

💡 LEDステータス (CapsLock LED)

現在の状態をCapsLockキーのLEDで確認できます。

ステータス LEDの挙動
スタンバイ (待機) 🐢 ゆっくり点滅
ペアリング中 🐇 速く点滅
接続完了 💡 1秒間 点灯
バッテリー残量低下 ⚠️ 連続して点滅

⚠️ 重要:取り付け時の注意 BLEモジュールをキーボードのSATAコネクタに取り付ける際は、基板破損を防ぐため、必ず以下の状態で作業してください。

  • バッテリー電源スイッチを OFF にする
  • USBケーブルを 抜く

Claude Code に AWS が公開している MCP Server を追加する

AWS が公開している MCP Server 群は以下。 awslabs.github.io

今回は Claude Code が参照できるように設定追加を行う。
MCP Server が設定されているかを確認するコマンドは以下。

> /mcp 
  ⎿  No MCP servers configured. Run `claude mcp` to learn about how to configure MCP servers.

上記メッセージにあるように claude mcp コマンドを実行するとよさそうだ。

$ claude mcp --help
Usage: claude mcp [options] [command]

Configure and manage MCP servers

Options:
  -h, --help                                     Display help for command

Commands:
  serve [options]                                Start the Claude Code MCP server
  add [options] <name> <commandOrUrl> [args...]  Add a server
  remove [options] <name>                        Remove an MCP server
  list                                           List configured MCP servers
  get <name>                                     Get details about an MCP server
  add-json [options] <name> <json>               Add an MCP server (stdio or SSE) with a JSON string
  add-from-claude-desktop [options]              Import MCP servers from Claude Desktop (Mac and WSL only)
  reset-project-choices                          Reset all approved and rejected project-scoped (.mcp.json) servers within this project
  help [command]                                 display help for command

add を使うのがシンプルなようだが、https://awslabs.github.io/mcp/ にて公開されている JSON をリスペクトするために add-json を使うのがよさそうだ。
無邪気に以下のようにしてみる。

$ claude mcp add-json awslabs.aws-documentation-mcp-server '{
  "mcpServers": {
    "awslabs.aws-documentation-mcp-server": {
      "command": "uvx",
      "args": ["awslabs.aws-documentation-mcp-server@latest"],
      "env": {
        "FASTMCP_LOG_LEVEL": "ERROR",
        "AWS_DOCUMENTATION_PARTITION": "aws"
      },
      "disabled": false,
      "autoApprove": []
    }
  }
}'
Invalid name awslabs.aws-documentation-mcp-server. Names can only contain letters, numbers, hyphens, and underscores.

名前に . があると怒られる。 . を削除する。

$ claude mcp add-json aws-documentation-mcp-server '{
  "mcpServers": {
    "awslabs.aws-documentation-mcp-server": {
      "command": "uvx",
      "args": ["awslabs.aws-documentation-mcp-server@latest"],
      "env": {
        "FASTMCP_LOG_LEVEL": "ERROR",
        "AWS_DOCUMENTATION_PARTITION": "aws"
      },
      "disabled": false,
      "autoApprove": []
    }
  }
}'
Invalid configuration: : Invalid input

ダメそう。色々試してみると command の箇所からだけでよさそうだった。

$ claude mcp add-json aws_documentation_server '{"command": "uvx", "args": ["awslabs.terraform-mcp-server@latest"], "env": {"FASTMCP_LOG_LEVEL": "ERROR", "AWS_DOCUMENTATION_PARTITION": "aws"}, "disabled": false, "autoApprove": []}'
Added stdio MCP server aws_documentation_server to local config

Claude に入って /mcp すると追加されていることが確認できる。

awslabs.terraform-mcp-server@latest を追加したので、 MCP Server を参照した回答になるのか試す。

terraform で S3 を実装するうえでのベストプラクティスを教えて下さい。

初手で参照してくれている模様。

結果は以下。

● TerraformでS3を実装する際のベストプラクティスは以下の通りです:

  リソース分離

  - aws_s3_bucketは基本のバケット作成のみに使用
  - 個別設定は専用リソースで管理:
    - aws_s3_bucket_versioning でバージョニング
    - aws_s3_bucket_server_side_encryption_configuration で暗号化
    - aws_s3_bucket_acl でアクセス制御
    - aws_s3_bucket_policy でバケットポリシー

  セキュリティ

  - デフォルトでプライベートアクセス設定
  - KMS暗号化を有効化(aws:kmsまたはAES256)
  - バージョニングを有効化してデータ保護
  - 適切なIAMポリシーとバケットポリシー設定

  命名規則

  - 小文字のみ使用(63文字以内)
  - bucket_prefixでユニーク名を自動生成
  - 一貫性のあるタグ付け

  ライフサイクル管理

  - aws_s3_bucket_lifecycle_configurationでコスト最適化
  - 古いバージョンの自動削除設定
  - ストレージクラス遷移(IA、Glacierなど)

  その他

  - force_destroy = trueは慎重に使用(データ完全削除)
  - CORSやロギングは専用リソースで設定
  - プロバイダーのdefault_tags活用で統一的なタグ管理

VSCode から Roo Code を介して MCP Server にリクエストする

目標

VSCode拡張機能として提供されている Roo Code にプロンプトを入力し、 Amazon Bedrock と MCP Server が連携する様を眺める。

環境

OS/Tool Value
OS Windows 11 / Ubuntu 24.04 on WSL2
Editor VS Code
MCP Client Roo Code
Provider Amazon Bedrock
MCP Server awslabs.aws-documentation-mcp-server

Amazon Bedrock のセットアップ

今回は LLM に Bedrock を使用する。
まずは Model Access にて使いたいモデルを有効にする。

  • Management Console -> Amazon Bedrock -> Model access の順に進み、 Modify model access をクリック
  • 今回は Claude Sonnet 4 を使用するため、チェックして Next
  • 会社名、会社のHPのURL、ユースケースを問われるので入力する
  • Access Status が Available to request から Pending に変わり、しばらくすると Access granted となる

Roo Code に設定するために、モデルの Inference profile ARN を控えておく

  • Amazon Bedrock のホーム -> Cross-Region inference に進む
  • APAC Claude Sonnet 4 を検索し、ARN を控える

Roo Code のセットアップ

VSCode拡張機能から Roo Code をインストールし、 Profile を作成する。

Key Value Remark
Configration Profile 適当に名付ける
API Provider Amazon Bedrock
AWS Profile Bedrock にアクセス可能な AWS Profile 名 Roo Code は Shared Credential を読んでくれる
AWS Region 使用するリージョン 今回は ap-northeast-1
Model Use custom ARN を選択 プルダウンの一番下
Custom ARN Bedrock のセットアップで控えていた ARN を入力 プルダウン内の cloaud-sonnet-4 を選択してもエラーになった

MCP Server の設定

MCP Servers の設定を開き、 Edit Global MCP をクリックする。

mcp_settings.json が開くので、 以下より使用したい MCP Server の設定をコピペする。

awslabs.github.io

今回はいくつか設定してみることにする。

{
  "mcpServers": {
    "awslabs.core-mcp-server": {
      "command": "uvx",
      "args": [
        "awslabs.core-mcp-server@latest"
      ],
      "env": {
        "FASTMCP_LOG_LEVEL": "ERROR"
      },
      "autoApprove": [],
      "disabled": false
    },
    "awslabs.terraform-mcp-server": {
      "command": "uvx",
      "args": [
        "awslabs.terraform-mcp-server@latest"
      ],
      "env": {
        "FASTMCP_LOG_LEVEL": "ERROR"
      },
      "disabled": false,
      "autoApprove": []
    },
    "awslabs.aws-documentation-mcp-server": {
      "command": "uvx",
      "args": [
        "awslabs.aws-documentation-mcp-server@latest"
      ],
      "env": {
        "FASTMCP_LOG_LEVEL": "ERROR"
      },
      "disabled": false,
      "autoApprove": [],
      "alwaysAllow": [
        "recommend"
      ]
    }
  }
}

以上でセットアップは完了。

実践

AWS Documentation MCP Server に記載のプロンプトを入力してみる。

recommend content for page https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucketnamingrules.html

すると動き出し、以下の文言から MCP Server を参照していることがわかり、

Roo wants to use a tool on the awslabs.aws-documentation-mcp-server MCP server:

MCP Server からのレスポンスを受け取っていることも確認できる。

感想

Bedrock + AWS MCP Server での結果は以下でした。

result

Based on the AWS documentation recommendations for the S3 bucket naming rules page, here are the most relevant content recommendations organized by category:

## **Highly Related Content**

### **Object and Bucket Naming**
- **[Naming Amazon S3 objects](https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-keys.html)** - Comprehensive guide for object key naming guidelines, safe characters, and characters to avoid
- **[Creating a general purpose bucket](https://docs.aws.amazon.com/AmazonS3/latest/userguide/create-bucket-overview.html)** - Step-by-step bucket creation process with naming considerations

### **Bucket Management Fundamentals**
- **[Buckets overview](https://docs.aws.amazon.com/AmazonS3/latest/userguide/UsingBucket.html)** - Essential bucket concepts and management
- **[Bucket quotas, restrictions, and limitations](https://docs.aws.amazon.com/AmazonS3/latest/userguide/BucketRestrictions.html)** - Important constraints that complement naming rules

## **Website Hosting (Popular Use Case)**
- **[Hosting a static website using Amazon S3](https://docs.aws.amazon.com/AmazonS3/latest/userguide/WebsiteHosting.html)** - Static website hosting configuration
- **[Tutorial: Configuring a static website using a custom domain registered with Route 53](https://docs.aws.amazon.com/AmazonS3/latest/userguide/website-hosting-custom-domain-walkthrough.html)** - Custom domain setup requiring specific naming conventions

## **Security and Access Control**
- **[Security best practices for Amazon S3](https://docs.aws.amazon.com/AmazonS3/latest/userguide/security-best-practices.html)** - Comprehensive security guidance
- **[Blocking public access to your Amazon S3 storage](https://docs.aws.amazon.com/AmazonS3/latest/userguide/access-control-block-public-access.html)** - Public access management

## **Related AWS Services with Naming Requirements**
- **[Follow bucket naming requirements for Lightsail object storage](https://docs.aws.amazon.com/lightsail/latest/userguide/bucket-naming-rules-in-amazon-lightsail.html)** - Similar naming rules for Lightsail
- **[Naming requirements for CloudTrail resources, S3 buckets, and KMS keys](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-trail-naming-requirements.html)** - Cross-service naming considerations

## **Performance and Optimization**
- **[Best practices design patterns: optimizing Amazon S3 performance](https://docs.aws.amazon.com/AmazonS3/latest/userguide/optimizing-performance.html)** - Performance considerations that may relate to naming patterns
- **[Organizing objects using prefixes](https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-prefixes.html)** - Object organization strategies

The recommendations show that users reading about bucket naming rules are typically interested in bucket creation, object naming, website hosting setup, and security best practices. The content spans from basic bucket management to advanced topics like performance optimization and cross-service integrations.

I've provided comprehensive content recommendations for the AWS S3 bucket naming rules documentation page. The recommendations are organized into key categories:

**Core Related Topics:**
- Object naming guidelines and safe characters
- Bucket creation and management fundamentals
- Bucket restrictions and limitations

**Popular Use Cases:**
- Static website hosting with custom domains (requires specific naming conventions)
- Security best practices and access control

**Cross-Service Integration:**
- Lightsail object storage naming requirements
- CloudTrail resource naming requirements

**Advanced Topics:**
- Performance optimization considerations
- Object organization strategies

These recommendations help users understand not just the naming rules themselves, but also the practical applications and related concepts they'll need when working with S3 buckets in real-world scenarios.

また、 Gemini 2.5 Pro (Preview) で同じプロンプトを入力したところ以下の結果でした。

result

Based on the content of the Amazon S3 bucket naming rules documentation, here are some recommendations for additional content and improvements that could make the page even more helpful for users:

### Content Recommendations for AWS S3 Bucket Naming Rules Page:

* **Add a "Good vs. Bad Examples" Table:** While the rules are listed, a quick-reference table showing valid and invalid bucket names with explanations would be highly beneficial.

| Valid Bucket Name | Invalid Bucket Name | Reason for Invalidity |
| :--- | :--- | :--- |
| `my-awesome-bucket` | `My-Awesome-Bucket` | Contains uppercase letters |
| `123-bucket` | `127.0.0.1` | Formatted as an IP address |
|`my.bucket.name`| `my..bucket`|Contains adjacent periods|
|`bucket-for-testing-`|` -bucket-for-testing`|Cannot start or end with a hyphen|

* **Include a "Common Mistakes" or "Gotchas" Section:** This section could highlight the most frequent errors users encounter when creating buckets. This would be a proactive way to prevent common user errors. Examples of common mistakes to include are:
    * Using uppercase letters.
    * Using underscores (`_`) instead of hyphens (`-`).
    * Trying to use a bucket name that is already taken globally.
    * Ending a bucket name with a hyphen.

* **Provide Programmatic Naming Examples:** Many developers create buckets programmatically. Adding a small section with code snippets in popular languages (like Python, JavaScript, or Java) demonstrating how to generate valid and unique bucket names would be a valuable resource for the developer community.

* **Explain the "Why" Behind the Rules:** Briefly explaining the reasons for certain rules can improve comprehension and retention. For example, explaining that the no-period rule for Transfer Acceleration is due to SSL certificate validation, or that the lowercase-only and no-underscore rules are for DNS compatibility, would provide helpful context.

* **Add an Interactive Bucket Name Validator:** A simple interactive tool on the page where users could type in a proposed bucket name and have it instantly validated against the rules would provide immediate feedback and improve the user experience significantly. This would be a powerful addition to the documentation.

By incorporating these suggestions, the already informative page on S3 bucket naming rules could become an even more effective and user-friendly resource for AWS customers.

ドキュメントを要約させるようなユースケースでは、MCP Server の優位性を確認することは難しいが、
実装等において公式のドキュメントを参照してのサジェストや AI による実装が行われると考えると非常に頼もしいのではないかと感じた。

おわり

WSL2 (Ubuntu 24.04) で uv を使う

はじめに

pyenv venv pip をひとまとめにして高速と噂の uv を使ってみます。
Rust で実装されているようです。
https://docs.astral.sh/uv/

環境は Widowns 11 + WSL2 + Ubuntu 24.04 です。

uv という名前の由来はたびたび話題になっているようでした。

uv のインストール

https://docs.astral.sh/uv/getting-started/installation/ を参考にインストールします。

curl -LsSf https://astral.sh/uv/install.sh | sh

バージョンは以下です。

$ uv --version
uv 0.7.3

uv は ${HOME}/.local/bin/uv にインストールされるため、必要に応じて PATH を通します。

Python のインストール

uv は pyenv のように複数バージョンの Python をインストールできます。
https://docs.astral.sh/uv/getting-started/features/#python-versions

uv python list でインストール済み、及びインストール可能な Python のバージョンを確認できます。

cpython-3.14.0a6-linux-x86_64-gnu                 <download available>
cpython-3.14.0a6+freethreaded-linux-x86_64-gnu    <download available>
cpython-3.13.3-linux-x86_64-gnu                   ${HOME}/.local/share/uv/python/cpython-3.13.3-linux-x86_64-gnu/bin/python3.13
cpython-3.13.3+freethreaded-linux-x86_64-gnu      <download available>
cpython-3.12.10-linux-x86_64-gnu                  <download available>
cpython-3.12.3-linux-x86_64-gnu                   /usr/bin/python3.12
cpython-3.12.3-linux-x86_64-gnu                   /usr/bin/python3 -> python3.12
cpython-3.11.12-linux-x86_64-gnu                  <download available>
cpython-3.10.17-linux-x86_64-gnu                  <download available>
cpython-3.9.22-linux-x86_64-gnu                   <download available>
cpython-3.8.20-linux-x86_64-gnu                   <download available>
pypy-3.11.11-linux-x86_64-gnu                     <download available>
pypy-3.10.16-linux-x86_64-gnu                     <download available>
pypy-3.9.19-linux-x86_64-gnu                      <download available>
pypy-3.8.16-linux-x86_64-gnu                      <download available>
graalpy-3.11.0-linux-x86_64-gnu                   <download available>
graalpy-3.10.0-linux-x86_64-gnu                   <download available>
graalpy-3.8.5-linux-x86_64-gnu                    <download available>

3.12.10 をインストールしたければ uv python install cpython-3.14.0a6-linux-x86_64-gnu でインストールします。

$ uv python install cpython-3.14.0a6-linux-x86_64-gnu
Installed Python 3.14.0a6 in 2.56s
 + cpython-3.14.0a6-linux-x86_64-gnu

venv の作成

uv で venv を作成するには uv venv コマンドを使います。
https://docs.astral.sh/uv/pip/environments/

例えば test-3.12 という名前の venv を作成するには以下のようにします。

uv venv test-3.12 --python cpython-3.12.3-linux-x86_64-gnu

指定する Python のバージョンは uv python list で確認したものを指定すると確実そうですが、単に 3.12 でも機能します。
Current Directory に 3.12 のためのディレクトリが作成されます。

Using CPython 3.12.3 interpreter at: /usr/bin/python3.12
Creating virtual environment at: test-3.12
Activate with: source test-3.12/bin/activate

仮想環境を有効化するには source test-3.12/bin/activate を実行します。
次はこの仮想環境にパッケージをインストールします。

パッケージのインストール

uv でパッケージをインストールするには uv pip コマンドを使います。

$ uv pip install pandas
Using Python 3.12.3 environment at: test-3.12
Resolved 6 packages in 138ms
Prepared 4 packages in 675ms
Installed 6 packages in 23ms
 + numpy==2.2.5
 + pandas==2.2.3
 + python-dateutil==2.9.0.post0
 + pytz==2025.2
 + six==1.17.0
 + tzdata==2025.2

list でインストール済みのパッケージを確認できます。

$ uv pip list
Using Python 3.12.3 environment at: test-3.12
Package         Version
--------------- -----------
numpy           2.2.5
pandas          2.2.3
python-dateutil 2.9.0.post0
pytz            2025.2
six             1.17.0
tzdata          2025.2

requirements.txt からインストールすることもできます。

$ cat requirements.txt
boto3
requests
click

$ uv pip install -r requirements.txt
Using Python 3.12.3 environment at:
Resolved 12 packages in 92ms
Prepared 4 packages in 38ms
Installed 10 packages in 82ms
 + boto3==1.38.15
 + botocore==1.38.15
 + certifi==2025.4.26
 + charset-normalizer==3.4.2
 + click==8.2.0
 + idna==3.10
 + jmespath==1.0.1
 + requests==2.32.3
 + s3transfer==0.12.0
 + urllib3==2.4.0

インストールしたパッケージは test-3.12/lib/python3.12/site-packages に格納されます。

所感

Python の開発に欠かせないツールがまとめられており、かつ高速に動作するため、自分は乗り換えることを決めました。
pyenv + pip + venv の組み合わせよりも、uv の方が圧倒的に速いと感じます。

SSH Key を使わずに GitHub のプライベートリポジトリを Clone する

git-credential-manager-core.exe の確認

Git for Windows に同梱されている。なければ Git for Windows をインストールする。

PS C:\Program Files\Git\mingw64\bin> ls .\git-credential-manager-core.exe

    Directory: C:\\Program Files\\Git\\mingw64\\bin

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a---           10/7/2022    12:22          75688 git-credential-manager-core.exe

Global の .gitconfig を編集する

Windows

PowerShellgit config --global credential.helper manager を実行する。

Ubuntu (WSL)

WSL でも Git 操作したいときは以下の credential の部分を追記する。

$ cat .\.gitconfig
[user]
        email = hoge@example.com
        name = hoge
[credential]
        helper = /mnt/c/Program\\ Files/Git/mingw64/bin/git-credential-manager.exe

git clone などしたときに git.exe が見つからないエラーが発生したら、 Windows 側の PATH に git を追加する。

プライベートリポジトリ を Clone

https://ユーザー名@github.com とするのがポイント。

PS C:\> git clone https://hoge@github.com/org/repo.git

認証のための Web 画面が起動する。

今回は Browser/Deviceにする。 Personel Access Token の方が望ましい。

ブラウザが起動する。 2FA をしていれば、ここで入力し、 Authorize する。

成功する。

Clone が始まる。

AWS CLI v2 で 'ascii' codec can't encode characters in position 1-14: ordinal not in range(128)

背景

AWS CLI v2 をインストールし、 EventBridge のリストを取得しようしたところ表題のエラーが発生。

環境

$ /usr/local/bin/aws --version
aws-cli/2.6.0 Python/3.9.11 Linux/5.10.16.3-microsoft-standard-WSL2 exe/x86_64.ubuntu.20 prompt/off

エラー

$ aws events list-rules

'ascii' codec can't encode characters in position 1-14: ordinal not in range(128)

Description に日本語が含まれていると発生する模様。

対応

自分の環境では .bash_profile で以下のようにしたら解決した。

- export LC_ALL=C
+ export LC_ALL=C.UTF-8

export PYTHONIOENCODING=utf-8 しなさいという記事もあったが、これは効果がなかった。

参考

qiita.com