尧图建网站 尧图建网站 YAOTU WEB BUILD 免费咨询
ARTICLE DETAIL

资讯详情

深耕网站建设与建站编程的一线实战洞察。

在windows上安装wsl,迁移D盘,在Ubuntu安装opencode全过程(无废话)

在windows上安装wsl,迁移D盘,在Ubuntu安装opencode全过程(无废话) 第一步 winX选择Windows Powershell管理员第二步# 开启WSL子系统功能dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart# 开启虚拟机平台功能WSL2核心依赖dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart重启电脑第三步 winX选择Windows Powershell管理员#安装适用于 Linux 的 Windows 子系统可能连不上外网wsl --update --web-download#安装ubuntuwsl --install第四步 检查是否安装成功wsl -l -v下面开始迁移到D盘第五步 停止 WSLwsl --shutdown第六步 导出发行版到文件wsl --export Ubuntu D:\0-application\WSL\wsl-export.tar第七步 注销原发行版wsl --unregister Ubuntu第八步 导入到新位置wsl --import Ubuntu D:\0-application\WSL D:\0-application\WSL\wsl-export.tar迁移完成该安装opencode了第九步 踩的坑给大家参考如果遇到了同样的坑直接去第十步1.由于连不上网curl和wget都无法安装node.js2.镜像设置好后sudo apt install -y nodejs npm # 安装 Node.js 和 npm安装的版本太老了。安装好后无法升级到新版本。所以卸载了。卸载代码sudo apt-get remove --purge nodejs npmsudo apt-get autoremove第十步我在官网下载了node-v24.19.0-linux-x64.tar.xz。在windows资源管理器里面打开\\wsl.localhost\Ubuntu\home\user\work把文件放在里面。cd /home/Ubuntu/worktar -xJf node-v24.19.0-linux-x64.tar.xz#解压export PATH/home/xinyu/work/node-v24.19.0-linux-x64/bin:$PATHnode -vnpm -v#测试一下版本第十一步#安装opencodenpm install -g opencode-ai#测试一下opencode --version第十一步 配置gitgit config --global user.name 你的名字 git config --global user.email 你的邮箱第十二步 配置用户名密码SSH配置好windows的SSH后在wsl上执行# 1. 复制私钥(把 27844 换成你的 Windows 用户名)cp /mnt/c/Users/27844/.ssh/id_ed25519 ~/.ssh/# 2. 修正权限(关键!权限不对 SSH 会拒绝使用) chmod 600 ~/.ssh/id_ed25519ssh -T gitgithub.com#看到这行就说明成功了Hi 你的用户名! Youve successfully authenticated, but GitHub does not provide shell access.第十三步 安装omonpx oh-my-opencode install按实际情况填写就好了。#认证模型提供商opencode auth login输入opencode开始你的对话吧
返回列表