< 返回版块

xBINj 发表于 2026-07-01 10:02

我的系统是Windows 11,VSCode+rust-analyzer创建rust bin工程,但是只要我在Cargo.toml里面依赖诸如mimalloc这种底层有FFI绑定的包,我的VSCode就会报错,错误信息如下:

2026-07-01T08:15:32.0928241+08:00 ERROR FetchBuildDataError: error: failed to run custom build command for libmimalloc-sys v0.1.49 note: To improve backtraces for build dependencies, set the CARGO_PROFILE_DEV_BUILD_OVERRIDE_DEBUG=true environment variable to enable debug information generation.

Caused by: process didn't exit successfully: C:\prjs_rust\_git_src\rust_learning\mytest02\target\debug\build\libmimalloc-sys-bb484ed7d47cad91\build-script-build (exit code: 1) --- stderr

error occurred in cc-rs: command did not execute successfully (status code exit code: 2): "C:\Program Files (x86)\Microsoft Visual Studio\18\BuildTools\VC\Tools\MSVC\14.51.36231\bin\HostX64\x64\cl.exe" "-nologo" "-MD" "-Z7" "-Brepro" "-std:c++17" "-I" "c_src/mimalloc/v3/include" "-I" "c_src/mimalloc/v3/src" "-W4" "/Zc:__cplusplus" "-DMI_DEBUG=0" "-FoC:\prjs_rust\_git_src\rust_learning\mytest02\target\debug\build\libmimalloc-sys-e1725bc60f4f3fe1\out\ea87f1564a68d277-mimalloc-static.o" "-c" "C:\prjs_rust\_git_src\rust_learning\mytest02\target\debug\build\libmimalloc-sys-e1725bc60f4f3fe1\out\mimalloc-static.cc"

2026-07-01T08:16:08.3452738+08:00 ERROR Flycheck failed to run the following command: CommandHandle { program: "C:\Users\ddaixi\.cargo\bin\cargo.exe", arguments: ["check", "--workspace", "--message-format=json-diagnostic-rendered-ansi", "--manifest-path", "C:\prjs_rust\_git_src\rust_learning\mytest02\Cargo.toml", "--keep-going", "--all-targets"], current_dir: Some("C:\prjs_rust\_git_src\rust_learning\mytest02") }, error=Cargo watcher failed, the command produced no valid metadata (exit code: ExitStatus(ExitStatus(101))): Blocking waiting for file lock on package cache Blocking waiting for file lock on package cache 1.822438700s INFO prepare_target{force=false package_id=mytest02 v0.1.0 (C:\prjs_rust_git_src\rust_learning\mytest02) target="mytest02"}: cargo::core::compiler::fingerprint: fingerprint error for mytest02 v0.1.0 (C:\prjs_rust_git_src\rust_learning\mytest02)/Check { test: true }/TargetInner { name_inferred: true, ..: lib_target("mytest02", ["lib"], "C:\prjs_rust\_git_src\rust_learning\mytest02\src\lib.rs", Edition2024) } 1.824259400s INFO prepare_target{force=false package_id=mytest02 v0.1.0 (C:\prjs_rust_git_src\rust_learning\mytest02) target="mytest02"}: cargo::core::compiler::fingerprint: err: failed to read C:\prjs_rust\_git_src\rust_learning\mytest02\target\debug\.fingerprint\mytest02-707d0ba1f50f9ee3\test-lib-mytest02

重装过VSCode,VS Build Tools以及构建工具,Windows 11 SDK,删除过.cargo/registry/cache和src目录下的cc, mimalloc, libmimalloc-sys的缓存和源代码,重装过VSCode里面所有插件,都无法解决,但是我的另外一个电脑环境也是如此,VSCode却不会报错。 P我直接在命令行输入cargo check/cargo run不会报错,能正常编译打包和运行程序,但是在VSCode的rust-analyzer就会报这个错。

为什么?求大神指点一下~

评论区

写评论
bestgopher 2026-07-01 14:15

大徒弟经验丰富

--
👇
Liu-WeiHu: 这种问agent啊。他会给你搞定的。我也是rust ffi 开发。ra经常没有响应,平常心吧

作者 xBINj 2026-07-01 13:20

有位大神指点了一下,说报错的是flycheck,问了agent说是可能是因为文件锁冲突或者是fingerprint文件里面文件损坏导致,但是具体为什么未知,还是需要继续追查。

作者 xBINj 2026-07-01 13:19

不是,是mimalloc。

--
👇
廴壬吉: flutter_rust_bridge 吗

廴壬吉 2026-07-01 13:02

flutter_rust_bridge 吗

作者 xBINj 2026-07-01 10:23

问了无数个agent,给出的方案都无法解决,有点崩心态了。

--
👇
Liu-WeiHu: 这种问agent啊。他会给你搞定的。我也是rust ffi 开发。ra经常没有响应,平常心吧

Liu-WeiHu 2026-07-01 10:14

这种问agent啊。他会给你搞定的。我也是rust ffi 开发。ra经常没有响应,平常心吧

1 共 6 条评论, 1 页