如何让Codebook在VS代码中运行Rust(由conda安装)

vc6uscn9  于 2023-03-12  发布在  其他
关注(0)|答案(1)|浏览(468)

我已经在Windows 10上安装了Anaconda 3和VS Code。我对在笔记本上运行Rust很感兴趣,我发现CodeBook似乎符合要求。我在conda create -n rust_env -c conda-forge rust环境中使用conda安装了Rust,然后在VS Code中安装了rust-analyzer扩展,并创建了一个标记文档,我在CodeBook中打开了该文档。
但是,当我尝试运行一个单元格时,我发现rust-analyzer已经扫描了0个根中的0个,并且“未能加载工作空间”cargo“-未找到程序”。
如果我在终端中使用conda激活rustenv,我可以运行cargo --version,但似乎CodeBook没有在正确的环境中运行Rust。
我在铁 rust 分析仪手册中找不到任何帮助:https://rust-analyzer.github.io/manual.html
VS代码显示终端中的conda环境

更新:我已经将rust可执行文件添加到路径中:C:\ProgramData\Anaconda3\envs\rustenv\Library\bin
现在出现服务器错误...

[Info  - 2:10:43 pm] Connection to server got closed. Server will restart.
[Error - 2:10:43 pm] Server initialization failed.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Error - 2:10:43 pm] Rust Analyzer Language Server client: couldn't create connection to server.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Error - 2:10:43 pm] Restarting server failed
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Info  - 2:10:45 pm] Connection to server got closed. Server will restart.
[Error - 2:10:45 pm] Server initialization failed.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Error - 2:10:45 pm] Rust Analyzer Language Server client: couldn't create connection to server.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Error - 2:10:45 pm] Restarting server failed
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Error - 2:10:45 pm] The Rust Analyzer Language Server server crashed 5 times in the last 3 minutes. The server will not be restarted. See the output for more information.

我不明白这是什么意思...

zpf6vheq

zpf6vheq1#

我的经验是,不幸的是,VS代码不能很好地与康达生 rust 。你将不得不改变设置在多个地方,我实际上从来没有得到它的工作自己。
最好在您的系统上安装rust而不使用conda,然后VS Code中的一切都可以开箱即用。

  • 在您的情况下,在Windows上,您将使用rustup-init.exe进行安装
  • 对于Linux/Mac系统,您可以使用rustup进行安装

相关问题