rexpect icon indicating copy to clipboard operation
rexpect copied to clipboard

PtySession::expect_eof never finishes with current nightly build

Open Jonathas-Conceicao opened this issue 4 years ago • 3 comments

I've traced down the source of a faulty execution in a application that I contribute to the PtySession::expect_eof never finishing execution on Rut's currently nightly build.

I have a little example that can reproduce the problem:

// On Cargo.toml
// [dependencies]
// rexpect = "0.4"

fn main() {
    let mut p = rexpect::spawn("echo 'working as expected'", Some(10000)).unwrap();
    println!("{}", p.exp_eof().unwrap());
}

When I run this on nightly the timeout is reached, and if no timeout is set the execution just hangs indefinitely. On stable it just works as expected.

Here's my rust and cargo version for the nightly build:

$ rustc --version --verbose
rustc 1.56.0-nightly (30a0a9b69 2021-08-17)
binary: rustc
commit-hash: 30a0a9b694cde95cbab863f7ef4d554f0f46b606
commit-date: 2021-08-17
host: x86_64-unknown-linux-gnu
release: 1.56.0-nightly
LLVM version: 12.0.1

$ cargo --version --verbose
cargo 1.56.0-nightly (b51439fd8 2021-08-09)
release: 1.56.0
commit-hash: b51439fd8b505d4800a257acfecf3c69f81e35cf
commit-date: 2021-08-09

Would appreciate if you guys could make it compatible with nightly again as it is what I use during development. In the mean time I'll be pining down my nightly to the last working release.

Jonathas-Conceicao avatar Aug 19 '21 18:08 Jonathas-Conceicao

From what I've tested, error started from nightly-2021-07-03 onward.

Jonathas-Conceicao avatar Aug 19 '21 18:08 Jonathas-Conceicao

Good catch @Jonathas-Conceicao. The issue most likely here

https://github.com/philippkeller/rexpect/blob/db3b17d33af0db39134d82010f0e848a2b404769/src/reader.rs#L171-L172

I have a guess after a short investigation and as I was facing something as strange in the nearest.

ref: https://github.com/zhiburt/ptyprocess/issues/7

Essentially they introduce a new type of io::Error on nightly.


@philippkeller I hope you don't mind if I refer to expectrl here

Note: Just tested expectrl against this issue and master branch works.

[dependencies]
expectrl = {git = "https://github.com/zhiburt/expectrl"}
use expectrl::Eof;

fn main() {
    let mut p = expectrl::spawn("echo 'working as expected'").unwrap();
    println!("{:?}", String::from_utf8_lossy(p.expect(Eof).unwrap().found_match()));
}
[mzhiburt@fedora exampleexpectrl]$ cargo run
   Compiling exampleexpectrl v0.1.0 (/home/mzhiburt/projects/exampleexpectrl)
    Finished dev [unoptimized + debuginfo] target(s) in 1.47s
     Running `target/debug/exampleexpectrl`
"'working as expected'\r\n"
[mzhiburt@fedora exampleexpectrl]$ cargo --version --verbose
cargo 1.56.0-nightly (e96bdb0c3 2021-08-17)
release: 1.56.0
commit-hash: e96bdb0c3d0a418e7fcd7fbd69be08abf830b4bc
commit-date: 2021-08-17

zhiburt avatar Aug 27 '21 15:08 zhiburt

@zhiburt thanks for stepping in and I have absolutely nothing against promoting your repo - as I currently have not time maintaining this

philippkeller avatar Sep 15 '21 13:09 philippkeller

Closed with #40

ekarlsn avatar Sep 17 '22 13:09 ekarlsn