Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error: cannot satisfy dependencies so `std` only shows up once

Tags:

rust

This is an error I get when I try to run cargo test in a project. What does it mean? How do I fix it?

I can try to update with more details, but I could not reproduce it with a minimal example, unfortunately...

Full error:

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

It happens during the compilation step when I try to run tests that use the crate through an extern crate, like here: How do I access files in the src directory from files in my tests directory?

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

like image 814
The Unfun Cat Avatar asked Oct 28 '16 13:10

The Unfun Cat


1 Answers

Thanks to Matthieu M. for pointing me to the correct github issue!

The fix was to put the following in my Cargo.toml:

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

If you are using rustc the option

-C prefer-dynamic

should fix your problem.

like image 70
The Unfun Cat Avatar answered Sep 25 '22 09:09

The Unfun Cat