Skip to content

read_line() fails with an unknown error when run in PowerShell (Windows 7 x64) #13590

Closed
@rillomas

Description

@rillomas

The following readline_sample.rs fails with an unknown error when I run it from cmd and PowerShell. The same sample works when I run it from mintty.
I'm using rust 0.10 on Windows 7 x64.

readline_sample.rs

use std::io;

fn main() {
    println!("Enter line.");
    match io::stdin().read_line() {
        Ok(s) => println!("typed {}", s),
        Err(e) => println!("error: {}", e)
    }
}

PowerShell output

PS C:\rust_sample> rustc -v .\readline_sample.rs
C:\Program Files (x86)\Rust\bin\rustc.exe 0.10
host: i686-pc-mingw32
PS C:\rust_sample> .\readline_sample.exe
Enter line.
error: unknown error (OS Error 8 (FormatMessageW() returned error 998))

mintty output

$ rustc -v ./readline_sample.rs
c:\Program Files (x86)\Rust\bin\rustc.exe 0.10
host: i686-pc-mingw32

$ ./readline_sample.exe
Enter line.
aaaaaa
typed aaaaaa

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