mcfly icon indicating copy to clipboard operation
mcfly copied to clipboard

Doesn't work with WSL

Open markusjevringgoeuro opened this issue 5 years ago • 20 comments

Similarly to https://github.com/cantino/mcfly/issues/22 I can open up the display, and choose my command, but in the end, all it tried to execute is mcfly search, no matter what I type or select.

[~]
$ #mcfly:
[~]
$  mcfly search
[~]
$
$ cat /etc/issue.net
Ubuntu 18.04.1 LTS

markusjevringgoeuro avatar Dec 07 '18 15:12 markusjevringgoeuro

Yea, I've never tested it on Windows, I'm not surprised it has issue there.

cantino avatar Dec 09 '18 18:12 cantino

Why, though? As far as the app knows, it's ubuntu linux. There's no way the app can tell the difference.

markusjevringgoeuro avatar Dec 10 '18 08:12 markusjevringgoeuro

Maybe line endings or file slash formats?

cantino avatar Dec 11 '18 19:12 cantino

That doesn't seem likely, as other linux executables and scripts work perfectly fine in WSL.

markusjevringgoeuro avatar Dec 12 '18 08:12 markusjevringgoeuro

Upon more thought, I suspect that the problem is WSL or your terminal not supporting TIOCSTI. https://github.com/Microsoft/WSL/issues/1863

Maybe a fix could be pulled from https://github.com/dvorka/hstr/issues/186. I don't use WSL, so someone else will need to work on this.

cantino avatar Dec 15 '18 20:12 cantino

still wainting for this to get fixed, i hop someone could fix this, wanne use hyperion on wsl :)

IIIdefconIII avatar Apr 23 '19 21:04 IIIdefconIII

Just FYI because you mentioned https://github.com/dvorka/hstr/issues/186: hstr now works on WSL with Ubuntu out of the box, without the TIOCSTI workaround from that Github issue.

jmiserez avatar Jun 12 '19 17:06 jmiserez

@jmiserez I can now see the dialog, which is cool, but selecting a command still just makes it print "mcfly search"

markusjevringgoeuro avatar Jun 13 '19 12:06 markusjevringgoeuro

Doesn't work on Windows because the 'termion' package from Rust does not support Windows, and cannot build on that. I'm using MSYS2.

https://gitlab.redox-os.org/redox-os/termion/issues/167

Perhaps an alternative package can be used for Windows for this functionality?

Tatsh avatar Oct 01 '19 14:10 Tatsh

Try to modify the end of the mcfly.bash:

# if [[ $- =~ .i. ]]; then # if set -o | grep "vi " | grep -q on; then # bind "'\C-r': '\e0i#mcfly: \e\C-j mcfly search\C-j'" # else # bind "'\C-r': '\C-amcfly: \e# mcfly search\C-j'" # fi # fi bind "'\C-r': '\e0i#mcfly: \e\C-j mcfly search\C-j'"

goddade avatar May 27 '20 13:05 goddade

mcfly works just fine for me on WSL1 but I just upgraded to WSL2 (since it is now in stable if you have the latest Win 10 version 2004). I still have my legacy WSL1 distro where mcfly works great but also installed a new Ubuntu on WSL2 and there I get this error when starting WSL and after every command:

McFly: Importing shell history for the first time. This may take a minute or two...thread 'main' panicked at 'McFly error: Please ensure HISTFILE is set for your shell (environment variable not found)', src/shell_history.rs:39:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

If I do export RUST_BACKTRACE=1 I get:

McFly: Importing shell history for the first time. This may take a minute or two...thread 'main' panicked at 'McFly error: Please ensure HISTFILE is set for your shell (environment variable not found)', src/shell_history.rs:39:9
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/libunwind.rs:86
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print_fmt
             at src/libstd/sys_common/backtrace.rs:78
   3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
             at src/libstd/sys_common/backtrace.rs:59
   4: core::fmt::write
             at src/libcore/fmt/mod.rs:1069
   5: std::io::Write::write_fmt
             at src/libstd/io/mod.rs:1504
   6: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:62
   7: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:49
   8: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:198
   9: std::panicking::default_hook
             at src/libstd/panicking.rs:218
  10: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:511
  11: std::panicking::begin_panic
  12: mcfly::shell_history::history_file_path::{{closure}}
  13: mcfly::main
  14: std::rt::lang_start_internal::{{closure}}::{{closure}}
             at src/libstd/rt.rs:52
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

And with export RUST_BACKTRACE=full I get:

McFly: Importing shell history for the first time. This may take a minute or two...thread 'main' panicked at 'McFly error: Please ensure HISTFILE is set for your shell (environment variable not found)', src/shell_history.rs:39:9
stack backtrace:
   0:     0x5637d5462c15 - backtrace::backtrace::libunwind::trace::hc1c4a1d8ad423b97
                               at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/libunwind.rs:86
   1:     0x5637d5462c15 - backtrace::backtrace::trace_unsynchronized::h82274781060cb056
                               at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/mod.rs:66
   2:     0x5637d5462c15 - std::sys_common::backtrace::_print_fmt::h2a45d89b653a4da8
                               at src/libstd/sys_common/backtrace.rs:78
   3:     0x5637d5462c15 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h41a0a93ab85e6aa1
                               at src/libstd/sys_common/backtrace.rs:59
   4:     0x5637d53a09bc - core::fmt::write::hdaea18585065a96d
                               at src/libcore/fmt/mod.rs:1069
   5:     0x5637d5462234 - std::io::Write::write_fmt::h0cea70c809005252
                               at src/libstd/io/mod.rs:1504
   6:     0x5637d5461a25 - std::sys_common::backtrace::_print::hd95f9978cc145ca4
                               at src/libstd/sys_common/backtrace.rs:62
   7:     0x5637d5461a25 - std::sys_common::backtrace::print::hfb25ca2291be47d0
                               at src/libstd/sys_common/backtrace.rs:49
   8:     0x5637d5461a25 - std::panicking::default_hook::{{closure}}::h44f76cee5dc8591c
                               at src/libstd/panicking.rs:198
   9:     0x5637d5460fc1 - std::panicking::default_hook::h198e1a712910f1e6
                               at src/libstd/panicking.rs:218
  10:     0x5637d5460fc1 - std::panicking::rust_panic_with_hook::hc0b4730bb8013f9d
                               at src/libstd/panicking.rs:511
  11:     0x5637d53da569 - std::panicking::begin_panic::hcc7de77bb21c0fde
  12:     0x5637d53b6c2a - mcfly::shell_history::history_file_path::{{closure}}::h89d1f2665841784d
  13:     0x5637d53382fb - mcfly::main::h268b3fa377db8d6e
  14:     0x5637d546cc83 - std::rt::lang_start_internal::{{closure}}::{{closure}}::hea6d2692b0d00d17
                               at src/libstd/rt.rs:52
  15:     0x5637d546cc83 - std::sys_common::backtrace::__rust_begin_short_backtrace::h18a6e82be258e24e
                               at src/libstd/sys_common/backtrace.rs:130
  16:     0x5637d53399e2 - main
  17:     0x7f6aa82920b3 - __libc_start_main
  18:     0x5637d533054e - _start
  19:                0x0 - <unknown>

This is actually on the zsh branch version of mcfly, but it's the same error regardless of if I run bash or zsh with mcfly.

Haprog avatar Jun 14 '20 13:06 Haprog

I'm not sure why it's complaining about HISTFILE though since in both cases if I'm on bash or zsh echo $HISTFILE correctly returns the history file and permissions look good too (same as on my WSL1 where everything works).

I'm not sure if Rust version can affect it. On WSL1 I have rustc 1.43.1 (8d69840ab 2020-05-04) and on WSL2 rustc 1.44.0 (49cae5576 2020-06-01)

Haprog avatar Jun 14 '20 13:06 Haprog

If I comment out mcfly.bash / mcfly.zsh from my .bashrc / .zshrc and manually run mcfly search then I get:

thread 'main' panicked at 'McFly error: Please ensure that MCFLY_SESSION_ID contains a random session ID (environment variable not found)', src/settings.rs:187:43
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Haprog avatar Jun 14 '20 13:06 Haprog

Did anybody find a solution to this? I get the same error message above when I install McFly via Brew. I just upgraded to Mint 20.1 from 18.3 where it worked perfeclty. I miss it.

Yellow1144 avatar Jan 18 '21 20:01 Yellow1144

@Haprog what happens if you run MCFLY_SESSION_ID=abc123 mcfly search?

cantino avatar Jan 21 '21 18:01 cantino

Thank you for the reply. The command yields this:

thread 'main' panicked at 'McFly error: Please ensure that MCFLY_HISTORY is set (environment variable not found)', src/settings.rs:224:25 note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

Looks like something didn't happen during my Brew or McFly installations that should have.

Is the solution to this simply to export an environment variable pointing to ~./.mcfly/history.db or might this be an indicator that there are other problems with this installation?

Running: MCFLY_SESSION_ID=abc123 MCFLY_HISTORY=/home/user/.mcfly/history.db mcfly search

produced:

thread 'main' panicked at 'McFly error: Query Map to work (nul byte found in provided data at position: 1)', src/history/history.rs:376:35

Yellow1144 avatar Jan 21 '21 21:01 Yellow1144

MCFLY_HISTORY should point to a temporary bash history file. This is all setup by mcfly.bash, which should be sourced on shell startup. Is that not happening for you?

cantino avatar Jan 22 '21 00:01 cantino

Some other bash history file or ~/.bash_history

Nope, doesn't look like it

Yellow1144 avatar Jan 22 '21 01:01 Yellow1144

Ok. I ran the command you gave me above and added to it: MCFLY_HISTORY=/home/user/.bash_history And it worked. I exported that same variable and just tried to run mcfly search and got this:

thread 'main' panicked at 'McFly error: Please ensure that MCFLY_SESSION_ID contains a random session ID (environment variable not found)', src/settings.rs:216:43

Is a SESSION_ID variable the one more thing I might need or might there be others? How do I generate that?

Yellow1144 avatar Jan 22 '21 01:01 Yellow1144

All of these should be generated by the mcfly.bash script that you added to your shell startup script.

cantino avatar Jan 27 '21 03:01 cantino