WSL 环境配置
WSL 安装
推荐命令行方式安装,而不是直接在商店中下载,可能会缺失一些必要组件而出现各种各样的错误代码。
1、以管理员身份打开 Powershell,执行wsl --install
2、如果执行失败,手动启用功能:
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
然后重启
3、设置 WSL 版本为 WSL2,执行wsl --set-default-version 2
4、安装想要的发行版
wsl --list --online
wsl --install -d Debian
5、多版本 linux 管理
wsl # 启动
wsl --shutdown # 关闭
wsl -l -v # 查看所有子系统和状态
wsl --set-default {name} # 设置默认子系统
wsl --unregister # 卸载默认子系统
WSL 网络配置
打开 WSL Setting(或修改.wslconfig)
WSL AI 环境配置
有关 Codex 全局中文配置模板可参考AGENTS.md。
Codex
npm install -g @openai/codex
cat > ~/.codex/config.toml << 'EOF'
model_provider = "packycode"
model = "gpt-5" #可更改为model = "gpt-5-codex"
model_reasoning_effort = "high"
disable_response_storage = true
[model_providers.packycode]
name = "packycode"
base_url = "https://codex-api.packycode.com/v1"
wire_api = "responses"
requires_openai_auth = true
EOF
cat > ~/.codex/auth.json << 'EOF'
{
"OPENAI_API_KEY": "sk-"
}
EOF
WSL 开发环境配置
Nodejs
sudo apt update && sudo apt upgrade
sudo apt-get install curl
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash
nvm install --lts
npm install -g nrm
nrm ls
nrm test
nrm use {fast}
Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# toolchain
echo 'export RUSTUP_UPDATE_ROOT=https://mirrors.tuna.tsinghua.edu.cn/rustup/rustup' >> ~/.bash_profile
echo 'export RUSTUP_DIST_SERVER=https://mirrors.tuna.tsinghua.edu.cn/rustup' >> ~/.bash_profile
#再增加下面内容在.bash_profile
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# cargo
vi ~/.cargo/config
[source.crates-io]
registry = "https://github.com/rust-lang/crates.io-index"
# 替换成要使用的镜像源
replace-with = 'tuna'
# 清华大学
[source.tuna]
registry = "https://mirrors.tuna.tsinghua.edu.cn/git/crates.io-index.git"
# 中国科学技术大学
[source.ustc]
registry = "git://mirrors.ustc.edu.cn/crates.io-index"
# 上海交通大学
[source.sjtu]
registry = "https://mirrors.sjtug.sjtu.edu.cn/git/crates.io-index"
# rustcc社区
[source.rustcc]
registry = "git://crates.rustcc.cn/crates.io-index"