Book: Listing 12-14: `use minigrep;` instead of `extern crate minigrep;` results in error

Created on 10 Dec 2018  Â·  4Comments  Â·  Source: rust-lang/book

I'm following the current live version of the Rust book (master on Github) and encountered the following issue:

Listing 12-14 states to use use minigrep; "... to bring the library crate into the binary crate". Yet when I do that I get the following compile errors when calling cargo run:

error[E0432]: unresolved import `minigrep`                                                                                                                                
 --> src/main.rs:2:5                                                                                                                                                      
  |                                                                                                                                                                       
2 | use minigrep;                                                                                                                                                         
  |     ^^^^^^^^ no `minigrep` in the root                                                                                                                                

error[E0433]: failed to resolve. Use of undeclared type or module `Config`                                                                                                
  --> src/main.rs:11:18                                                                                                                                                   
   |                                                                                                                                                                      
11 |     let config = Config::new(&args).unwrap_or_else(|err| {                                                                                                           
   |                  ^^^^^^ Use of undeclared type or module `Config`    

If I change use minigrep; to extern crate minigrep; the problem goes away.

I'd be happy to open a pull request if this is a legitimate bug.

Most helpful comment

@jvivian and @anuj1102 Do you have edition="2018" in your Cargo.toml and are you using Rust 1.31.0? The current version of the book assumes 2018 Edition Rust.

All 4 comments

I'm running into the same issue as well, and the fix above worked for me.

@jvivian and @anuj1102 Do you have edition="2018" in your Cargo.toml and are you using Rust 1.31.0? The current version of the book assumes 2018 Edition Rust.

Hi @carols10cents,

Thank you for the reply — I see now that the book is in lockstep with the latest release of Rust and the version I installed last week (1.30.1) doesn't include the edition="2018" in Cargo.toml. I updated via rustup update and added edition = "2018" which resolved my issue. Thank you very much! I'll go ahead and close this.

Yep, the edition switchover is a bit confusing right now. Glad this solved
your problem!

On Mon, Dec 10, 2018, 12:54 PM John Vivian <[email protected] wrote:

Hi @carols10cents https://github.com/carols10cents,

Thank you for the reply — I see now that the book is in lockstep with the
latest release of Rust and the version I installed last week (1.30.1)
doesn't include the edition="2018" in Cargo.toml. I updated via rustup
update and added edition = "2018" which resolved my issue. Thank you very
much! I'll go ahead and close this.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/rust-lang/book/issues/1676#issuecomment-445908997,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAL1Ul1JiRUSzMA2ZSdy8SBw_AVaqhVKks5u3p_JgaJpZM4ZKYV4
.

Was this page helpful?
0 / 5 - 0 ratings