Rust format失败

现象:

使用vscode 格式化.rs 文档的时候,一直没有反应。
cargo run命令没问题
cargo fmt会报错This version of rustfmt is deprecated. Use rustfmt-nightly. Use --force to run deprecated rustfmt.

询问GPT,一直让rustup component add rustfmt来安装,却提示已经安装,而cargo fmt仍然报错。

原因:

cargo 的所有命令是在这个文件夹下的。

我使用的 brew 安装,所以这里都应该是软链接,连接到/opt/homebrew/Cellar/rustup文件夹下。

~/.cargo/bin % ls -n /opt/homebrew/Cellar/rustup/1.27.1_1/bin/cargo-fmt
lrwxr-xr-x  1 501  80  11 Apr 24  2024 /opt/homebrew/Cellar/rustup/1.27.1_1/bin/cargo-fmt -> rustup-init

但是这里却有一些二进制文件,应该之前使用别的方式安装的时候,没清理干净,导致这里生成软链接失败。

所以找到 brew安装目录下的二进制文件,软链接过来就好了。

相关推荐
十八朵郁金香13 分钟前
通俗易懂的DOM1级标准介绍
开发语言·前端·javascript
阿尔法波16 分钟前
python与pycharm如何设置文件夹为源代码根目录
开发语言·python·pycharm
xing251625 分钟前
pytest下allure
开发语言·python·pytest
眸笑丶30 分钟前
使用 Python 调用 Ollama API 并调用 deepseek-r1:8b 模型
开发语言·python
计算机毕设指导632 分钟前
基于Springboot学生宿舍水电信息管理系统【附源码】
java·spring boot·后端·mysql·spring·tomcat·maven
计算机-秋大田40 分钟前
基于Spring Boot的兴顺物流管理系统设计与实现(LW+源码+讲解)
java·vue.js·spring boot·后端·spring·课程设计
enyp801 小时前
Qt QStackedWidget 总结
开发语言·qt
gu201 小时前
c#编程:学习Linq,重几个简单示例开始
开发语言·学习·c#·linq
lly2024061 小时前
SQLite 删除表
开发语言
wjs20241 小时前
HTML 字符实体
开发语言