Skip to content
This repository was archived by the owner on Dec 8, 2020. It is now read-only.
This repository was archived by the owner on Dec 8, 2020. It is now read-only.

Rust IDE Issues (VSCode, Atom) #396

Open
@rebelC0der

Description

@rebelC0der

Hello.

I can't get VSCode or Atom to work with Rust properly (in a productive way). This seems to be a very widespread issue:

  • Latest VSCode
  • Rust Beta (rustc 1.41.0-beta.1 (eb3f7c2d3 2019-12-17)) Same issue with other versions
  • rls 1.41.0 (8f1c275 2019-12-10)
  • Rust extension: Rust (rls)
  • Script running extension: Code Runner

Basically cargo run works just fine and runs the project. But VSCode can't figure out where crates are:

Code:

use rand::Rng;

fn main() {
    let rnd_num = rand::thread_rng().gen_range(1, 100);
    println!("Random number: {}", rnd_num);
}

cargo run from terminal:

[jurisl@JurisLinuxPC game]$ cargo run
    Finished dev [unoptimized + debuginfo] target(s) in 0.01s
     Running `target/debug/game`
Random number: 54

Errors when running from code editor:

error[E0432]: unresolved import `rand`
 --> main.rs:1:5
  |
1 | use rand::Rng;
  |     ^^^^ maybe a missing crate `rand`?

error[E0433]: failed to resolve: use of undeclared type or module `rand`
 --> main.rs:4:19
  |
4 |     let rnd_num = rand::thread_rng().gen_range(1, 100);
  |                   ^^^^ use of undeclared type or module `rand`

error: aborting due to 2 previous errors

Some errors have detailed explanations: E0432, E0433.
For more information about an error, try `rustc --explain E0432`.

Adding extern crate rand; results in the same error:

error[E0463]: can't find crate for `rand`
 --> main.rs:1:1
  |
1 | extern crate rand;
  | ^^^^^^^^^^^^^^^^^^ can't find crate

error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.

Changing edition = "2018" - Does not help.
Restarting RLS/VSCode - Does not help.

NOTE:

  1. The exact same issue is present in Atom editor.
  2. Autocomplete almost does not work:
    image

Basically, out of two editors (VSCode and Atom), that have Debugging capabilities, unlike Intellij Rust, both don't work for me and I just can't code in Rust as tools are literally broken/not mature enough for productive work. Please let me know if I am wrong and it is just a case of one little flag, that everyone forgets to mention, is missing in some config.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions