Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't achieve the given example #3

Closed
ChandelierX opened this issue May 2, 2018 · 6 comments
Closed

Can't achieve the given example #3

ChandelierX opened this issue May 2, 2018 · 6 comments
Assignees
Labels

Comments

@ChandelierX
Copy link

ChandelierX commented May 2, 2018

No matter whether I use cargo build or sudo make install, when I call echo 'fee fi fo fum' | retest 'f\w\w' or retest '\w+\s' --subject 'fee fi fo fum', I get the same error like below:

thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', libcore/option.rs:335:21
note: Run with `RUST_BACKTRACE=1` for a backtrace.

The install process itself gives me:

warning: unused import: `Terminal`
 --> src/retest.rs:4:25
  |
4 | use term::{self, color, Terminal};
  |                         ^^^^^^^^
  |
  = note: #[warn(unused_imports)] on by default

    Finished release [optimized] target(s) in 122.51 secs
Installing to //usr/local/bin...
install -m 0755 target/release/retest //usr/local/bin

Because I don't know anything about Rust, could you please do me a favor? I really want to use this useful CLI tool for regex test.
Besides, I have

------------------------
 OS: Manjaro Linux x86_64
 Host: ThinkPad Edge E540
 Kernel: 4.14.34-1-MANJARO
 Shell: zsh 5.5.1
 DE: KDE
 WM: KWin
 Terminal: Konsole
@sagebind
Copy link
Owner

sagebind commented May 2, 2018

Thanks for this bug report! I'll look into this as soon as I can.

@ChandelierX Could you re-run the example with the RUST_BACKTRACE environment variable set, and then post the backtrace? That would help me debug.

export RUST_BACKTRACE=1
retest '\w+\s' --subject 'fee fi fo fum'

@sagebind sagebind self-assigned this May 2, 2018
@sagebind sagebind added the bug label May 2, 2018
@ChandelierX
Copy link
Author

Of course I'd like to post the backtrace. The following snippet is the output:

export RUST_BACKTRACE=1
retest '\w+\s' --subject 'fee fi fo fum'
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', libcore/option.rs:335:21
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
   1: std::sys_common::backtrace::_print
   2: std::panicking::default_hook::{{closure}}
   3: std::panicking::default_hook
   4: std::panicking::rust_panic_with_hook
   5: std::panicking::begin_panic
   6: std::panicking::begin_panic_fmt
   7: rust_begin_unwind
   8: core::panicking::panic_fmt
   9: core::panicking::panic
  10: retest::retest::print_match
  11: retest::retest::print_subject_highlighted
  12: retest::main
  13: std::rt::lang_start::{{closure}}
  14: std::panicking::try::do_call
  15: __rust_maybe_catch_panic
  16: std::rt::lang_start_internal
  17: main
  18: __libc_start_main
  19: _start

I can't figure out what's wrong with it. And sorry for the delayed reply.

@sagebind
Copy link
Owner

sagebind commented May 4, 2018

Thanks, that helped me identify the issue. Oddly, it seems that the program crashes when it tries to write color escape codes to your terminal. Perhaps it could not load the terminfo database? Try installing ncurses and try again.

For the future, I will update the code to fail more gracefully and print an error message in this situation.

@sagebind
Copy link
Owner

sagebind commented May 4, 2018

@ChandelierX The latest version (0.2.3) now prints an error message when this happens giving a hint to the problem.

@ChandelierX
Copy link
Author

@sagebind The good news is: now it works well in both konsole and xTerm of mine.
I'd better mention some weird facts:

  1. ncurses is in my computer since the very beginning. Therefore it's unlikely the main reason.
  2. I found it originally works well in xterm (even before I did anything like update retest), but not in konsole.
  3. After I updated it to your newest version (by sudo make install), it works well in both of them.

@sagebind
Copy link
Owner

sagebind commented May 4, 2018

I did update my dependencies, so perhaps that pulled in an upstream bugfix. I'm glad it is working now!

@sagebind sagebind closed this as completed May 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants