当我尝试在项目中运行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的测试时会发生这种情况,例如:How do I access files in the src directory from files in my tests directory?
在OS X上,rustc 1.12.0 (3191fbae9 2016-09-23)
答案 0 :(得分:3)
感谢Matthieu M.指出我正确的github issue!
修复方法是将以下内容放入我的Cargo.toml
:
crate-type = ["rlib", "dylib"]
如果您使用rustc
选项
-C prefer-dynamic
应该解决你的问题。