拓冰建站拓冰建站
首页 / 资讯中心 / 正文

Rustlings 提示 info.toml 的 format 版本高于支持范围怎么处理?

Rustlings 提示 info.toml 的 format 版本高于支持范围怎么处理【免费下载链接】rustlings:crab: Small exercises to get you used to reading and writing Rust code!项目地址: https://gitcode.com/gh_mirrors/ru/rustlings如果你 clone 了一个社区练习仓库进入目录后运行rustlings程序没有进入练习流程而是直接报错退出The format version specified in the info.toml file is higher than the last one supported. It is possible that you have an outdated version of Rustlings. Try to install the latest Rustlings version first.这条提示的含义是练习目录里info.toml的format_version高于当前 Rustlings 程序支持的最后一个版本。程序源码 src/main.rs 中定义了当前支持的版本常量CURRENT_FORMAT_VERSION: u8 1启动时会读取info.toml并执行判断info_file.format_version CURRENT_FORMAT_VERSION成立就直接报上面的错退出。而 src/info_file.rs 中对format_version的注释说明了它的用途——它是社区练习与 Rustlings 程序之间兼容性的指示并不等于 Rustlings 程序本身的版本号当 Rustlings 对社区练习的格式做出不可避免的破坏性变更时会提高这个版本并要求练习迁移。所以处理方向只有一个让程序支持的范围追上info.toml的要求也就是把 Rustlings 程序更新到最新版。下面的路径基于项目 Setup 文档website/content/setup/index.md。确认错误出现在哪个info.tomlRustlings 解析info.toml的规则是优先读取当前目录下的info.toml不存在时才使用程序内嵌的官方练习info.toml见 src/info_file.rs 的InfoFile::parse。因此如果你在自己刚rustlings init出的目录里遇到这个错误说明你安装的 Rustlings 程序版本与它内嵌练习的版本不匹配——同样是程序过旧照下面升级即可。如果你 clone 了别人的社区练习仓库并在其中运行rustlings报错指向的是该仓库的info.toml。打开它确认format_version …的实际值与程序支持的值当前为1对比就能判断是程序过旧还是该仓库要求了尚未被任何已发布版本支持的更新格式。安装最新版本的 RustlingsSetup 文档给出的前提和步骤需要已安装最新版本的 Rust会同时安装 Cargo。Linux 用户确认装了gcc用作链接器Debian 为sudo apt install gccFedora 为sudo dnf install gccmacOS 用户确认装了 Xcode 及其开发者工具xcode-select --install。用 Cargo 安装这会下载并编译 Rustlingscargo install rustlings如果安装失败Setup 文档给出的处理办法是运行rustup update确保 Rust 是最新版或改用cargo install rustlings --locked重试仍失败则到官方仓库报告问题。重新运行并验证安装完成后回到报错的那个目录exercises/所在目录重新运行cd rustlings/ rustlings判断是否解决错误不再出现程序显示欢迎信息首次运行时要求按 ENTER 继续并进入练习流程即版本匹配成功。仍报同样的格式版本错误说明你安装的已是最新版但该练习要求的format_version比当前最新版支持的值还高——此时只能等 Rustlings 更新支持或换一个format_version较低的练习仓库。如果你是在维护一个社区练习项目rustlings dev check对版本的要求更严格src/dev/check.rs 中当format_version低于当前支持版本时报错 format_version … (supported version)Please migrate to the latest format version高于时同样报错Try updating the Rustlings program。也就是说 dev check 要求format_version与当前支持版本一致练习项目需要自行迁移到最新格式。新建社区练习用rustlings dev new PROJECT_NAME生成的info.toml自带格式说明注释详见 Community Exercises 页面website/content/community-exercises/index.md。另外注意在 Rustlings 仓库源码目录内直接运行会报旧方法错误版本 6 之前需要 clone 仓库再运行现在不需要这属于另一种提示不要和格式版本错误混淆。小结这个错误只对应一种修复操作cargo install rustlings安装最新版程序再在练习目录重新运行。程序启动不再报错并进入练习流程即为验证通过如果最新版程序仍报错则说明练习的format_version超前于当前支持版本文档没有给出其他处理方式。【免费下载链接】rustlings:crab: Small exercises to get you used to reading and writing Rust code!项目地址: https://gitcode.com/gh_mirrors/ru/rustlings创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考
分享:

看完干货,该让你的企业上线了

免费需求沟通 · 48 小时内出具建站方案 · 河南本地可上门