windows 11 wsl cc 開發(fā)環(huán)境備忘

0x00 TLDR

嘗試了幾天Linux 主機(jī)遠(yuǎn)程開發(fā),還是有點(diǎn)不方便,今天 直接在 windows 11 的 wsl 環(huán)境下,構(gòu)建cc開發(fā)環(huán)境。
至少,生成的代碼在windows 環(huán)境下,還可以同步使用IDEA進(jìn)行查看
  • 補(bǔ)充
    windows 11 下,在 Microsoft Store 中安裝 Fluent Terminal、Ubuntu 24.04 LTS

0x01 wsl

本文使用 ubuntu 22.04
更新 /etc/apt/sources.list 內(nèi)容

# 默認(rèn)注釋了源碼鏡像以提高 apt update 速度,如有需要可自行取消注釋
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-security main restricted universe multiverse    
  • 補(bǔ)充 24.04
deb https://mirrors.aliyun.com/ubuntu/ noble main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ noble main restricted universe multiverse

deb https://mirrors.aliyun.com/ubuntu/ noble-security main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ noble-security main restricted universe multiverse

deb https://mirrors.aliyun.com/ubuntu/ noble-updates main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ noble-updates main restricted universe multiverse

# deb https://mirrors.aliyun.com/ubuntu/ noble-proposed main restricted universe multiverse
# deb-src https://mirrors.aliyun.com/ubuntu/ noble-proposed main restricted universe multiverse

deb https://mirrors.aliyun.com/ubuntu/ noble-backports main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ noble-backports main restricted universe multiverse

然后刷新鏡像源列表: sudo apt update
安裝一個(gè)測(cè)試依賴:

sudo apt install unzip

0x02 fnm、node、npm

  • 安裝 fnm:
    curl -fsSL https://fnm.vercel.app/install | bash
    初始化fnm 文件變量,手動(dòng)執(zhí)行 fnm env ,把結(jié)果放到 ~/.bashrc

  • 安裝 node:

# 安裝最新版 node
fnm install --latest
# 查看已安裝列表
fnm list 
# 激活當(dāng)前使用中的
fnm use 25.2.1
# 設(shè)置默認(rèn)版本
fnm default 25.2.1

可以打開一個(gè)新的 wsl窗口驗(yàn)證一下:

node -v
npm -v

配置兩個(gè)加速:

  • fnm 加速: export FNMR_MIRROR=https://mirrors.tuna.tsinghua.edu.cn/fnm
  • node 加速 npm config set registry https://registry.npmmirror.com

0x03 java

sudo apt install openjdk-17-jdk -y
sudo apt install maven -y
sudo apt install mysql-server-8.0 

配置 maven 加速, 這里默認(rèn)不使用私庫(kù),全部使用主倉(cāng)庫(kù)
vim ~/.m2/settings.xml

<settings>
  <mirrors>
    <mirror>
      <id>aliyunmaven</id>
      <name>阿里云公共倉(cāng)庫(kù)</name>
      <url>https://maven.aliyun.com/repository/public</url>
      <mirrorOf>*</mirrorOf>
    </mirror>                                                                                                                               </mirrors>
</settings>  

0x04 Claude Code

npm install -g @anthropic-ai/claude-code
npm install -g @fission-ai/openspec@latest

配置使用智譜AI的API給cc使用

export ANTHROPIC_BASE_URL=https://open.bigmodel.cn/api/anthropic
export ANTHROPIC_AUTH_TOKEN="zhipu api key"

0x05 MCP

本地 mysql 數(shù)據(jù)庫(kù)操作 mcp.

  • 下載mcp源碼,手動(dòng)安裝
git clone https://github.com/benborla/mcp-server-mysql.git
cd mcp-server-mysql
npm i
npm run build
  • 在某個(gè)目錄下,啟動(dòng)過 claude
  • 編輯 ~/.claude.json, 找到上述目錄相關(guān)的配置處,更新 mcpServer字段
      "mcpServers": {
        "mcp-server-mysql": {
          "command": "node",
          "args": [
            "{your_path}/mcp-server-mysql/dist/index.js"
          ],
          "env": {
            "MYSQL_HOST": "127.0.0.1",
            "MYSQL_PORT": "3306",
            "MYSQL_USER": "user",
            "MYSQL_PASS": "123456",
            "MYSQL_DB": "demo",
            "ALLOW_INSERT_OPERATION": "true",
            "ALLOW_DDL_OPERATION": "true",
            "ALLOW_UPDATE_OPERATION": "true",
            "ALLOW_DELETE_OPERATION": "true"
          }
        }
      },

2025/12/29更新:
把上述內(nèi)容,放到 ~/.claude.json 的頂級(jí)位置,即可完成全局配置。

0x06 Rust 安裝

  • 配置加速源
export RUSTUP_UPDATE_ROOT=https://mirrors.aliyun.com/rustup/rustup
export RUSTUP_DIST_SERVER=https://mirrors.aliyun.com/rustup
  • 上述配置生效后,使用阿里云的源進(jìn)行在線安裝:
curl --proto '=https' --tlsv1.2 -sSf https://mirrors.aliyun.com/repo/rust/rustup-init.sh | sh
  • 配置 crates 加速, ~/.cargo/config.toml
[source.crates-io]
replace-with = 'aliyun'

[source.aliyun]
registry = "sparse+https://mirrors.aliyun.com/crates.io-index/"
cargo install --locked cargo-zigbuild
  • 驗(yàn)證
rustup target add x86_64-pc-windows-msvc
cargo zigbuild -v --release --target x86_64-pc-windows-msvc

0x07 Vibe Coding

差不多了,接下來就可以開工寫代碼了。
記得常用一句: 解決 mvn spring-boot:run 編譯錯(cuò)誤

0x08 補(bǔ)充,github 加速

在地址前面加 https://gh-proxy.org/
git clone https://gh-proxy.org/https://github.com/benborla/mcp-server-mysql.git

阿里去加速配置中心: https://developer.aliyun.com/mirror/

0x09 bun 環(huán)境安裝

從國(guó)內(nèi)鏡像源安裝 bun

curl -fsSL https://gitee.com/akirarika/bun-cn/raw/main/install.sh | bash -
bun --version

配置鏡像加速
vim ~/.bunfig.toml

[install]
registry = "https://registry.npmmirror.com/"     

0x0A Claude Code增加 Hook 配置

使用場(chǎng)景, vibe code 一般來說會(huì)需要數(shù)分鐘時(shí)間。需要在完成的時(shí)間點(diǎn)發(fā)送消息通知用戶。此時(shí),可以通過 Stop Hook 來完成。

vim ~/.claude/settings.json

{
    "hooks": {
        "Stop": [
        {
            "matcher": "",
                "hooks": [
                {
                    "type": "command",
                    "command": "bash ~/.claude/hooks/weixin_notify.sh"
                }
                ]
        }
        ]
    }
}

0x0B 精簡(jiǎn)指令列表(2026/1/8更新)

npm install -g @anthropic-ai/claude-code
npm install -g @fission-ai/openspec@latest
npm install -g uipro-cli
mkdir work_dir
cd work_dir
openspec init
claude # 執(zhí)行 openspec init 最后一段話,生成opensec 初始文件
vim openspec/project.md # 手動(dòng)添加技術(shù)棧
uipro init --ai claude # 導(dǎo)入 ui-ux-pro-max ,用于UI風(fēng)格控制
npx vibe-kanban # 多任務(wù)管理看板

0x0C tmux

參考: https://go.lightnode.com/zh/tech/install-tmux-on-ubuntu

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容