cantino / mcfly

Fly through your shell history. Great Scott!
MIT License
6.75k stars 176 forks source link

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

Closed nuke-web3 closed 4 weeks ago

nuke-web3 commented 3 months ago

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

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 commented 3 months ago

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!

https://github.com/cantino/mcfly/blob/caad8168c407ee239e61ec10e4e02101a77cd0e4/src/fake_typer.rs#L10-L19

BernhardGruen commented 3 months ago

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 commented 2 months ago

Hey @BernhardGruen, @NukeManDan. You're probably having this issue? https://github.com/cantino/mcfly/issues/333

nuke-web3 commented 2 months ago

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 commented 1 month ago

It'd be great if bash users could test https://github.com/cantino/mcfly/pull/416

nuke-web3 commented 4 weeks ago

https://github.com/cantino/mcfly/issues/409#issuecomment-2143273341 resolved behavior issues with v0.9.0 :tada:

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 :+1:

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 commented 4 weeks ago

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

cantino commented 4 weeks ago

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