cantino / mcfly

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

Installing mcfly on Ubuntu 24.04 doesn't bind CTRL+R and "mcfly search" throws error #409

Closed dineshdharme closed 4 weeks ago

dineshdharme commented 1 month ago

I installed mcfly. First, mcfly didn't bind the CTRL+R. So I typed out "mcfly search" and following error was thrown.

thread 'main' panicked at src/settings.rs:217:25:
McFly error: Please ensure that MCFLY_HISTORY is set (environment variable not found)
stack backtrace:
   0:     0x7803a1e12a93 - std::backtrace_rs::backtrace::libunwind::trace::h52ca2b0d25f2719e
                               at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7803a1e12a93 - std::backtrace_rs::backtrace::trace_unsynchronized::h8ecf8ccac15e6f0b
                               at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7803a1e12a93 - std::sys_common::backtrace::_print_fmt::ha547c9f801690007
                               at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x7803a1e12a93 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hc77012dcf440636d
                               at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7803a1cc3f8c - core::fmt::rt::Argument::fmt::h8d1182dd103c25f4
                               at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/core/src/fmt/rt.rs:138:9
   5:     0x7803a1cc3f8c - core::fmt::write::hb214628b9e439901
                               at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/core/src/fmt/mod.rs:1114:21
   6:     0x7803a1de24dd - std::io::Write::write_fmt::h35bdcfd19819fb86
                               at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/std/src/io/mod.rs:1763:15
   7:     0x7803a1e13fc8 - std::sys_common::backtrace::_print::h84f013b3df84c128
                               at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7803a1e13fc8 - std::sys_common::backtrace::print::h5d062a74a110f9b5
                               at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7803a1e13d62 - std::panicking::default_hook::{{closure}}::h1a02f94cc37e9fc3
                               at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/std/src/panicking.rs:272:22
  10:     0x7803a1e14519 - std::panicking::default_hook::hca89f101c0314563
                               at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/std/src/panicking.rs:292:9
  11:     0x7803a1e14519 - std::panicking::rust_panic_with_hook::h25d867c939cdb86e
                               at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/std/src/panicking.rs:731:13
  12:     0x7803a1e1417c - std::panicking::begin_panic_handler::{{closure}}::h422b3052a79a1dfa
                               at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/std/src/panicking.rs:609:13
  13:     0x7803a1e140d6 - std::sys_common::backtrace::__rust_end_short_backtrace::hfc34c535d009440b
                               at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/std/src/sys_common/backtrace.rs:170:18
  14:     0x7803a1e140c1 - rust_begin_unwind
                               at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/std/src/panicking.rs:597:5
  15:     0x7803a1c28734 - core::panicking::panic_fmt::h65dd93d9a613f35c
                               at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/core/src/panicking.rs:72:14
  16:     0x7803a1d19313 - mcfly::settings::Settings::parse_args::h0e7096c0f70d6126
  17:     0x7803a1c34911 - mcfly::main::hcbb02a1c84be6c1e
  18:     0x7803a1d41b23 - std::sys_common::backtrace::__rust_begin_short_backtrace::h466d605917367fcd
cantino commented 1 month ago

Did you also add it to your ~/.bashrc, ~/.zshrc, or ~/.config/fish/config.fish file?

dineshdharme commented 1 month ago

Yes. It is already there. I merely upgraded from 22.04 to 24.04 and this error started showing up.

If I set MCFLY_HISTORY , the error goes away.

cantino commented 1 month ago

This means that mcfly's setup shell code isn't being executed, I suspect. If you're in a new shell and getting this error, and then you run the appropriate one of these, does it work?

Bash: eval "$(mcfly init bash)"

Zsh: eval "$(mcfly init zsh)"

Fish: mcfly init fish | source

dineshdharme commented 1 month ago

I started a new shell. Executed the command.

mcfly init fish | source

Still same error. CTRL+R is not binded.

mcfly search throws the same error.

cantino commented 1 month ago

I'm not sure what's going on. Does it work in Zsh?

dineshdharme commented 1 month ago

I tried it in Bash shell and it works in Bash.

Switched to Bash shell,

executed : eval "$(mcfly init bash)"

CTRL+R is binded properly and no error is thrown.

nuke-web3 commented 1 month ago

Yes. It is already there. I merely upgraded from 22.04 to 24.04 and this error started showing up.

If I set MCFLY_HISTORY , the error goes away.

This could be related to #333 ? see also https://github.com/cantino/mcfly/issues/404 I am betting kernel changes breaking a few things: https://itsfoss.com/ubuntu-24-04-vs-22-04/#8-linux-kernel-version

dineshdharme commented 1 month ago

I am using kernel 6.8.0-31-generic #31-Ubuntu SMP PREEMPT_DYNAMIC

slothyrulez commented 1 month ago

Something similar here:

❯ uname -a
Linux micri 6.8.0-31-generic #31-Ubuntu SMP PREEMPT_DYNAMIC Sat Apr 20 00:40:06 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
❯ mcfly -V
mcfly 0.8.5

CTRL+r works as always, but, once I hit enter, there is fraction of a second of a text being shown, and nothing happens.

https://github.com/cantino/mcfly/assets/1327353/02548ca6-5c13-445e-bf43-a311362bf7d6

mikionakajima commented 1 month ago

I got the same trouble.

deskmini with AMD Ryzen 2200G, 16G

> uname -a
Linux deskmini 6.8.0-31-generic #31-Ubuntu SMP PREEMPT_DYNAMIC Sat Apr 20 00:40:06 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
> mcfly -V
mcfly 0.8.6

CTRL-R works and MCFLY_HISTORY is correct. When I push Enter, nothing happen. IF I push TAB, nothing will display.

When I try CTRL-R as a root, it works. I think the trouble is related with a permission.

I checked the temp files and I think the permission for them are set correctly.

# echo $MCFLY_HISTORY
/tmp/mcfly.SBmH3qQ5
> echo $MCFLY_HISTORY
/tmp/mcfly.FxOY7CBm
> ls -l /tmp
-rw------- 1 root  root  1872  6月  1 09:49 mcfly.SBmH3qQ5
-rw------- 1 myusr myusr 1251  6月  1 09:55 mcfly.FxOY7CBm
cantino commented 4 weeks ago

Should hopefully be fixed by https://github.com/cantino/mcfly/pull/416 and https://github.com/cantino/mcfly/releases/tag/v0.9.0.

mikionakajima commented 4 weeks ago

Thank you. I cloned the repository and compiled. mcfly works perfect for a user and the root.

dineshdharme commented 4 weeks ago

I did the same. I followed the cargo installation steps. It works now.

dineshdharme commented 4 weeks ago

I have one feature suggestion. Harmful and common destructive commands should be filtered out. So there should be prompting just like cloud companies have when we deleter a bucket or object e.g. type 'DELETE'.

e.g. "rm -rf *"

nuke-web3 commented 4 weeks ago

I have one feature suggestion. Harmful and common destructive commands should be filtered out. So there should be prompting just like cloud companies have when we deleter a bucket or object e.g. type 'DELETE'.

e.g. "rm -rf *"

sounds like a new feat req issue to me :wink:

cantino commented 4 weeks ago

I believe this is fixed! Please re-open if not. @dineshdharme, feel free to make a feature request or PR for blacklisting rm -rf commands, I think that's a good idea (if hard to do comprehensively).