{"content":{"title":"Move开发环境搭建（Windows版）","body":"## 前言：\r\n由于Move这门编程语言目前只能在类unix系统上进行开发，而我既没有mac电脑，也不想在vm工具上安装ubuntu系统，然后再套娃式开发。因此这篇文章，就教教大家怎么在window 11上搭建Move开发环境。为后续Aptos合约开发搭建基本环境。\r\n\r\n## 关键词：\r\nWindows11、Move开发环境、WSL2、VScode、Layer1、Aptos\r\n\r\n## Windows11系统安装WSL2。\r\n安装完成之后，在命令行简单play一下，如果没问题，那就证明WSL2安装成功。\r\n![image.png](https:\/\/img.learnblockchain.cn\/attachments\/2022\/09\/Sn1vjAUz63202f2d1fe2d.png)\r\n## 搭建vscode开发环境\r\n首先下载vscode插件remote-wsl，他可以非常方便地管理和上传文件到子系统ubuntu中，可以说是在windows上真实体验linux下的编程感觉，非常好用的vscode插件。\r\n\r\n\r\n![image.png](https:\/\/img.learnblockchain.cn\/attachments\/2022\/09\/uKGWPKbw632031b06688e.png)\r\n\r\n\r\n\r\n安装完成之后，打开窗口，让我们的vscode开发界面连接到我们的linux环境上。初次打开时，系统会自动下载相关依赖环境。因此需要你有一个稳定的网络环境，有梯子最好。\r\n\r\n\r\n\r\n![image.png](https:\/\/img.learnblockchain.cn\/attachments\/2022\/09\/baCsUrlK632031c98163c.png)\r\n\r\n窗口打开后，输入简单命令，查看是否连接成功。至此，WSL2安装调试完成。\r\n\r\n### 1、安装move开发环境\r\n```\r\n1、安装rust开发环境\r\ncurl --proto '=https' --tlsv1.2 -sSf <https:\/\/sh.rustup.rs> | sh\r\n\r\n#检查是否安装成功\r\ncargo --version\r\nrustc -V        # 注意的大写的 V\r\n```\r\n\r\n安装完成之后，需要关闭窗口，重新打开才能生效。\r\n\r\n![image.png](https:\/\/img.learnblockchain.cn\/attachments\/2022\/09\/bEAYh73D632031d9497af.png)\r\n### 2、安装move-cli脚手架\r\n```\r\ncargo install --git <https:\/\/github.com\/move-language\/move> move-cli --branch main\r\n\r\n$ move\r\nMove 0.1.0\r\n```\r\n\r\n如果你安装脚手架的过程特别慢，下载速度只有十几kb\/s，那么你就需要给WSL2设置一个代理。设置代理的过程很简单。\r\n\r\n```\r\n\/\/编写一个脚本  vi proxyrc\r\n#!\/bin\/bash\r\nhost_ip=$(cat \/etc\/resolv.conf |grep \"nameserver\" |cut -f 2 -d \" \")\r\nexport ALL_PROXY=\"http:\/\/$host_ip:7890\"\r\n\r\n\/\/让脚本生效\r\nsource proxyrc\r\n```\r\n\r\n![image.png](https:\/\/img.learnblockchain.cn\/attachments\/2022\/09\/cEa9Uc8v632031e47aa0c.png)\r\n\r\n效果立竿见影。\r\n\r\n\r\n\r\n![image.png](https:\/\/img.learnblockchain.cn\/attachments\/2022\/09\/aehukAVp632031f5c9e91.png)\r\n\r\n安装move-cli的过程共花了2h，安装完成后，输入Move进行检查是否安装成功。\r\n```\r\nouhuang@LAPTOP-HM465BTT:~$ move\r\nmove-cli 0.1.0\r\nDiem Association <opensource@diem.com>\r\nMoveCLI is the CLI that will be executed by the `move-cli` command The `cmd` argument is added here\r\nrather than in `Move` to make it easier for other crates to extend `move-cli`\r\n```\r\n\r\n\r\n![image.png](https:\/\/img.learnblockchain.cn\/attachments\/2022\/09\/qb6AFH1R632031eeb2fb5.png)\r\n\r\n至此，move开发环境安装成功。\r\n\r\n## 参考资料\r\n- [什么是WSL2](https:\/\/docs.microsoft.com\/zh-cn\/windows\/wsl\/compare-versions)\r\n- [为 WSL2 一键设置代理](https:\/\/zhuanlan.zhihu.com\/p\/153124468)\r\n\r\n- [How do I fix the Rust error \"linker 'cc' not found\" for Debian on Windows 10?](https:\/\/stackoverflow.com\/questions\/52445961\/how-do-i-fix-the-rust-error-linker-cc-not-found-for-debian-on-windows-10)\r\n\r\n- [玩转WSL 2(三)--Windows和Linux之间的文件操作_邪三一的博客-CSDN博客_wsl2访问windows本地文件](https:\/\/blog.csdn.net\/Caoyang_He\/article\/details\/107898883)"},"author":{"user":"https:\/\/learnblockchain.cn\/people\/6721","address":null},"history":"QmX8PvJUZ4n9u18ZAWd8jRxhnzrBMnKWWFMn5e3V1w8VEj","timestamp":1663223063,"version":1}