错误:不能满足依赖,所以' std '只显示一次



这是我尝试在项目中运行cargo test时得到的错误。这是什么意思?我怎么修理它?

我可以尝试更新更多的细节,但我不能用一个最小的例子来复制它,不幸的是…

完全错误:

cargo test
   Compiling ranges v0.1.0 (file:///Users/user/code/rust-project)
error: cannot satisfy dependencies so `std` only shows up once
  |
  = help: having upstream crates all available in one format will likely make this go away
error: cannot satisfy dependencies so `core` only shows up once
  |
  = help: having upstream crates all available in one format will likely make this go away
error: cannot satisfy dependencies so `collections` only shows up once
  |
  = help: having upstream crates all available in one format will likely make this go away
error: cannot satisfy dependencies so `rustc_unicode` only shows up once
  |
  = help: having upstream crates all available in one format will likely make this go away
error: cannot satisfy dependencies so `alloc` only shows up once
  |
  = help: having upstream crates all available in one format will likely make this go away
error: cannot satisfy dependencies so `rand` only shows up once
  |
  = help: having upstream crates all available in one format will likely make this go away
error: cannot satisfy dependencies so `libc` only shows up once
  |
  = help: having upstream crates all available in one format will likely make this go away
error: cannot satisfy dependencies so `unwind` only shows up once
  |
  = help: having upstream crates all available in one format will likely make this go away
error: cannot satisfy dependencies so `panic_unwind` only shows up once
  |
  = help: having upstream crates all available in one format will likely make this go away
error: cannot link together two allocators: alloc_jemalloc and alloc_system
error: aborting due to 10 previous errors

在编译步骤中,当我尝试通过extern crate运行使用crate的测试时,就会发生这种情况,例如:我如何从我的测试目录中的文件访问src目录中的文件?

在OS X上,rustc 1.12.0 (3191fbae9 2016-09-23)

感谢Matthieu M.为我指出正确的github问题!

修复是在我的Cargo.toml中放入以下内容:

crate-type = ["rlib", "dylib"]

如果你使用的是rustc选项

-C prefer-dynamic

最新更新