Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When a build fails due to a local crate attempting to include a crate not in it's Cargo.toml, the second build will succeed #1050

Closed
Cifram opened this issue Dec 13, 2014 · 1 comment

Comments

@Cifram
Copy link

Cifram commented Dec 13, 2014

I've setup a minimal repro case here: https://github.com/Cifram/cargobug

Aside from the root (binary) crate, there are two library crates (foo and bar). The root crate specifies both library crates as dependencies in it's Cargo.toml. Neither of the libraries specify any dependencies in their Cargo.tomls. However, foo attempts to pull in bar anyway with an extern crate bar.

When you run cargo run, this fails, exactly as you'd expect:

$ cargo run
   Compiling foo v0.0.1 (file:///C:/cygwin64/home/Cifram/cargobug)
   Compiling bar v0.0.1 (file:///C:/cygwin64/home/Cifram/cargobug)
lib.rs:1:1: 1:18 error: can't find crate for `bar`
lib.rs:1 extern crate bar;
         ^~~~~~~~~~~~~~~~~
error: aborting due to previous error
Build failed, waiting for other jobs to finish...
Could not compile `foo`.

But if you immediately run cargo run again, it succeeds:

$ cargo run
   Compiling foo v0.0.1 (file:///C:/cygwin64/home/Cifram/cargobug)
   Compiling cargobug v0.0.1 (file:///C:/cygwin64/home/Cifram/cargobug)
     Running `target\cargobug`
42

Even though nothing has been done to address the failure.

Presumably it's finding the copy of bar that was compiled in the first pass, even though bar is still not in it's Cargo.toml. This is likely because rustc is run with a -L for the target/deps directory, where the compiled libraries are stored.

@alexcrichton
Copy link
Member

Closing as a dupe of #1037, but thanks for the report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants