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

Panic in src/fake_typer.rs - broken edit and run commands #404

Closed
nuke-web3 opened this issue Mar 26, 2024 · 8 comments
Closed

Panic in src/fake_typer.rs - broken edit and run commands #404

nuke-web3 opened this issue Mar 26, 2024 · 8 comments

Comments

@nuke-web3
Copy link

Happy user that has somehow broken the tool. Not sure how to troubleshoot without building and running a debugger locally that I hope not to have to do...

Steps to reproduce

  • empty or partial start on command in terminal
  • crtl+r brings up the gui to search
  • tab or enter on selection
  • ... back to an empty terminal (erased anything prompted up front)

I reinstalled with cargo install mcfly and followed from https://github.com/cantino/mcfly?tab=readme-ov-file#install-manually-from-source , now using mcfly 0.8.4, updated from a previously working (until mysteriously broke) 0.8.2

@nuke-web3
Copy link
Author

Placing some println in main:

nuke@pop-desk:~/git/installs/mcfly$ cargo r -- -d search -o /tmp/mcfly.asdf git
    Finished dev [unoptimized + debuginfo] target(s) in 0.05s
     Running `target/debug/mcfly -d search -o /tmp/mcfly.asdf git`
=========
Selection
Some("cd git/")
=========
Settings
Settings { mode: Search, debug: true, fuzzy: 0, session_id: "xNYnvLp02hQOno1hoN1i7YE1", mcfly_history: "/tmp/mcfly.Cm4SEg8n", output_selection: Some("/tmp/mcfly.asdf"), command: "git", dir: "/home/nuke/git/installs/mcfly", results: 10, when_run: None, exit_code: None, old_dir: None, append_to_histfile: None, refresh_training_cache: false, lightmode: false, key_scheme: Emacs, history_format: Bash, limit: None, skip_environment_check: false, init_mode: Bash, delete_without_confirm: false, interface_view: Top, result_sort: Rank, result_filter: Global, disable_menu: false, prompt: "$", disable_run_command: false, time_range: TimeRange { since: None, before: None }, sort_order: Asc, pattern: None, dump_format: Json }
nuke@pop-desk:~/git/installs/mcfly$ cat /tmp/mcfly.asdf
───────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
       │ File: /tmp/mcfly.asdf
───────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   1   │ mode display
   2   │ commandline cd git/
───────┴────────────────────────────────

So output works, but there is a panic in default mode:

cargo r -- -d search git
    Finished dev [unoptimized + debuginfo] target(s) in 0.05s
     Running `target/debug/mcfly -d search git`
=========
Selection
Some("git pull")
=========
Settings
Settings { mode: Search, debug: true, fuzzy: 0, session_id: "xNYnvLp02hQOno1hoN1i7YE1", mcfly_history: "/tmp/mcfly.Cm4SEg8n", output_selection: None, command: "git", dir: "/home/nuke/git/installs/mcfly", results: 10, when_run: None, exit_code: None, old_dir: None, append_to_histfile: None, refresh_training_cache: false, lightmode: false, key_scheme: Emacs, history_format: Bash, limit: None, skip_environment_check: false, init_mode: Bash, delete_without_confirm: false, interface_view: Top, result_sort: Rank, result_filter: Global, disable_menu: false, prompt: "$", disable_run_command: false, time_range: TimeRange { since: None, before: None }, sort_order: Asc, pattern: None, dump_format: Json }
thread 'main' panicked at src/fake_typer.rs:16:13:
Error encountered when calling ioctl

So not sure what I did to break this on my machine - any tips would be great to resolve it!

mcfly/src/fake_typer.rs

Lines 10 to 19 in caad816

#[cfg(not(windows))]
#[allow(clippy::useless_conversion)]
pub fn use_tiocsti(string: &str) {
for byte in string.as_bytes() {
let a: *const u8 = byte;
if unsafe { ioctl(0, libc::TIOCSTI.try_into().unwrap(), a) } < 0 {
panic!("Error encountered when calling ioctl");
}
}
}

@nuke-web3 nuke-web3 changed the title Broken edit and run commands Broken edit and run commands - panic in rc/fake_typer.rs Mar 26, 2024
@nuke-web3 nuke-web3 changed the title Broken edit and run commands - panic in rc/fake_typer.rs Panic in rc/fake_typer.rs - broken edit and run commands Mar 26, 2024
@nuke-web3 nuke-web3 changed the title Panic in rc/fake_typer.rs - broken edit and run commands Panic in src/fake_typer.rs - broken edit and run commands Mar 26, 2024
@BernhardGruen
Copy link

Hey,

it seems broken on my systems too. I am using 0.8.4 and also tried a really old version like 0.6.0 from 2022 and it did not work at all.
I am sure both versions worked until about 3 days ago.
I am using Ubuntu if that matters.

@cantino
Copy link
Owner

cantino commented Apr 28, 2024

Hey @BernhardGruen, @nukemandan. You're probably having this issue? #333

@nuke-web3
Copy link
Author

nuke-web3 commented Apr 29, 2024

Indeed it seems that sudo sysctl -w dev.tty.legacy_tiocsti=1 and /etc/sysctl.d/10_legacy_tiocsti.conf updated to persist (persist isn't working it seems?) it via the workaround suggested here.

Running uname -u = 6.8.0-76060800daily20240311-generic

@cantino
Copy link
Owner

cantino commented May 26, 2024

It'd be great if bash users could test #416

@nuke-web3
Copy link
Author

#409 (comment) resolved behavior issues with v0.9.0 🎉

Indeed it seems that sudo sysctl -w dev.tty.legacy_tiocsti=1 and /etc/sysctl.d/10_legacy_tiocsti.conf updated to persist (persist isn't working it seems?) it via the workaround suggested here.

Running uname -u = 6.8.0-76060800daily20240311-generic

no longer needed with 0 for legacy config or unset 👍

I do see the same code that was panicing https://github.com/cantino/mcfly/blob/master/src/fake_typer.rs so unclear if that should still be looked into? I am happy to close this for now, if the maintainers are not worried.

@cantino
Copy link
Owner

cantino commented Jun 1, 2024

Yes, that code is still in the codebase but only runs in bash if you set export MCFLY_BASH_USE_TIOCSTI=1

@cantino
Copy link
Owner

cantino commented Jun 1, 2024

I believe this is fixed! Please re-open if not.

@cantino cantino closed this as completed Jun 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants