Inconsistent build behaviours in Rust on macOS Mojave 10.14.2

Viewed 272

I am new to Rust and have been following the Rust book tutorials. A lot of the times when I try to run a project it seems to compile but doesn't run.

Here is an example when I try to run the first part of the program for the guessing game:

$ cargo run --verbose                                                                     (master✱)
       Fresh guessing_game v0.1.0 (/Users/rohana/Documents/Projects/rust/guessing_game)
    Finished dev [unoptimized + debuginfo] target(s) in 0.04s
     Running `target/debug/guessing_game`
[1]    30294 killed     cargo run --verbose

However the same code will sometimes run if I make any changes like adding comments, then running and reverting and running again. Not always though.

I am using Rust 1.31.1 and Cargo 1.31.0 on macOS Mojave 10.14.2.

This is the code for reference, but the same problem also occurs on a blank "Hello World!" program:

use std::io;

fn main() {
    println!("Guess the number");
    println!("Please enter your guess");
    let mut guess = String::new();

    io::stdin()
        .read_line(&mut guess)
        .expect("Failed to read line");

    println!("You guessed {}", guess);
}
0 Answers
Related