title: Resolving imports in Rust
body: <p>I'm having trouble with importing <strong>rand</strong> crate from <strong>crates.io</strong>. After adding the line rand=&quot;0.8.3&quot; and then running command <strong>cargo build</strong> for the project, it keeps displaying the same errors:</p>
  <pre class="lang-rust prettyprint-override"><code>error[E0432]: unresolved import `rand`
   --&gt; main.rs:1:5
    |
  1 | use rand::Rng;
    |     ^^^^ maybe a missing crate `rand`?
  
  error[E0433]: failed to resolve: use of undeclared crate or module `rand`
   --&gt; main.rs:4:25
    |
  4 |     let secret_number = rand::thread_rng().gen_range(1..=11);
    |                         ^^^^ use of undeclared crate or module `rand`
  
  error: aborting due to 2 previous errors
  </code></pre>
  <p>the <strong>cargo.toml</strong> file</p>
  <pre><code>[package]
  name = &quot;roller&quot;
  version = &quot;0.1.0&quot;
  authors = [&quot;User&quot;]
  edition = &quot;2018&quot;
  
  # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
  
  [dependencies]
  rand = &quot;0.8.3&quot;
  
  </code></pre>
  <p>Basically the simplest reproducible example is this single line of code:</p>
  <pre><code> use rand::Rng;
  
   fn main(){
      let secret_number = rand::thread_rng().gen_range(1..=11);
      print!(&quot;{}&quot;,secret_number);
   }
  </code></pre>
  <p>What's wrong with it?</p>
  <br>
  Just in case:
  <br>
  The **cargo.lock**file:
  <pre><code># This file is automatically @generated by Cargo.
  # It is not intended for manual editing.
  [[package]]
  name = &quot;cfg-if&quot;
  version = &quot;1.0.0&quot;
  source = &quot;registry+https://github.com/rust-lang/crates.io-index&quot;
  checksum = &quot;baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd&quot;
  
  [[package]]
  name = &quot;getrandom&quot;
  version = &quot;0.2.2&quot;
  source = &quot;registry+https://github.com/rust-lang/crates.io-index&quot;
  checksum = &quot;c9495705279e7140bf035dde1f6e750c162df8b625267cd52cc44e0b156732c8&quot;
  dependencies = [
   &quot;cfg-if&quot;,
   &quot;libc&quot;,
   &quot;wasi&quot;,
  ]
  
  [[package]]
  name = &quot;libc&quot;
  version = &quot;0.2.86&quot;
  source = &quot;registry+https://github.com/rust-lang/crates.io-index&quot;
  checksum = &quot;b7282d924be3275cec7f6756ff4121987bc6481325397dde6ba3e7802b1a8b1c&quot;
  
  [[package]]
  name = &quot;ppv-lite86&quot;
  version = &quot;0.2.10&quot;
  source = &quot;registry+https://github.com/rust-lang/crates.io-index&quot;
  checksum = &quot;ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857&quot;
  
  [[package]]
  name = &quot;rand&quot;
  version = &quot;0.8.3&quot;
  source = &quot;registry+https://github.com/rust-lang/crates.io-index&quot;
  checksum = &quot;0ef9e7e66b4468674bfcb0c81af8b7fa0bb154fa9f28eb840da5c447baeb8d7e&quot;
  dependencies = [
   &quot;libc&quot;,
   &quot;rand_chacha&quot;,
   &quot;rand_core&quot;,
   &quot;rand_hc&quot;,
  ]
  
  [[package]]
  name = &quot;rand_chacha&quot;
  version = &quot;0.3.0&quot;
  source = &quot;registry+https://github.com/rust-lang/crates.io-index&quot;
  checksum = &quot;e12735cf05c9e10bf21534da50a147b924d555dc7a547c42e6bb2d5b6017ae0d&quot;
  dependencies = [
   &quot;ppv-lite86&quot;,
   &quot;rand_core&quot;,
  ]
  
  [[package]]
  name = &quot;rand_core&quot;
  version = &quot;0.6.2&quot;
  source = &quot;registry+https://github.com/rust-lang/crates.io-index&quot;
  checksum = &quot;34cf66eb183df1c5876e2dcf6b13d57340741e8dc255b48e40a26de954d06ae7&quot;
  dependencies = [
   &quot;getrandom&quot;,
  ]
  
  [[package]]
  name = &quot;rand_hc&quot;
  version = &quot;0.3.0&quot;
  source = &quot;registry+https://github.com/rust-lang/crates.io-index&quot;
  checksum = &quot;3190ef7066a446f2e7f42e239d161e905420ccab01eb967c9eb27d21b2322a73&quot;
  dependencies = [
   &quot;rand_core&quot;,
  ]
  
  [[package]]
  name = &quot;roller&quot;
  version = &quot;0.1.0&quot;
  dependencies = [
   &quot;rand&quot;,
  ]
  
  [[package]]
  name = &quot;wasi&quot;
  version = &quot;0.10.2+wasi-snapshot-preview1&quot;
  source = &quot;registry+https://github.com/rust-lang/crates.io-index&quot;
  checksum = &quot;fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6&quot;
  </code></pre>