neovim-gtk icon indicating copy to clipboard operation
neovim-gtk copied to clipboard

Fails to start if neovim runs on a different machine without neovim-gtk runtime files

Open bk2204 opened this issue 2 years ago • 10 comments

Describe the bug

I have a situation where I'd like to run neovim-gtk on my local laptop while running neovim itself on a remote machine. (Essentially, this would be to work in GitHub Codespaces without needing to forward X11 to my local machine.) When I do so, if the remote system lacks neovim-gtk's runtime files, it silently fails to start up and the GUI either just exits or times out.

It would be nice if it were possible to do this, since Neovim technically only requires standard input and output to run the embedded protocol. I can confirm, as a workaround, that copying the runtime files solves the problem.

(Now you also know why I filed #16: so I don't have to use a wrapper script here.)

Reproduction steps:

  • Find a remote system that doesn't have neovim-gtk on it. Pretend this system can be accessed by the SSH alias remote.
  • Build neovim-gtk on your local system. Ensure it's in PATH.
  • Add the script mentioned below into PATH as ssh-nvim.
  • Run REMOTE_HOST=remote nvim-gtk --nvim-bin-path ssh-nvim
  • Note that it fails to connect to Neovim.
  • Copy the runtime file into an appropriate plugin directory on the remote system.
  • Run the command again.
  • Note that it starts up properly.

Technical information (please complete the following information):

  • OS: Linux
  • Neovim version: Debian v0.4.4 on the remote side
  • Neovim-Gtk build version: b5d5e90a958ec267b139f12051a92fc979ee5c5f from Git

ssh-nvim:

#!/bin/sh

exec ssh "$REMOTE_HOST" env -u TERM nvim $(git rev-parse --sq-quote "$@")

bk2204 avatar Mar 12 '22 11:03 bk2204

Interesting that this works for you. I tried something similar in #16 and didn't have success, and I don't still with your script wrapper here:

[2022-03-12T12:24:36Z ERROR nvim_gtk::shell] Error reading message
[2022-03-12T12:24:36Z ERROR nvim_gtk::error] Can't initialize nvim: DecodeError(InvalidMessage(NotAnArray(Integer(PosInt(27)))), "nvim_set_client_info")

(NeovimGtk:1046520): Gtk-WARNING **: 06:24:36.288: Child name 'Error' not found in GtkStack

I wonder if it's because you're using a relatively old version of neovim? I get this error with neovim v0.6.1 on both machines.

jacobmischka avatar Mar 12 '22 12:03 jacobmischka

I can also run it on my local machine (running Debian sid) as well, where I have neovim 0.6.1, but then of course I have the runtime files.

bk2204 avatar Mar 12 '22 12:03 bk2204

Interesting. I cannot.

$ RUST_BACKTRACE=1 REMOTE_HOST=localhost nvim-gtk --nvim-bin-path ssh-nvim --no-fork
[2022-03-12T12:47:25Z ERROR nvim_gtk::shell] Error reading message
[2022-03-12T12:47:25Z ERROR nvim_gtk::error] Can't initialize nvim: DecodeError(InvalidMessage(NotAnArray(Integer(PosInt(27)))), "nvim_set_client_info")

I've tried commenting out the set_client_info call just to see if that's causing the problem specifically (I think that's fine?), and still nothing.

Where are you putting these plugin files? ~/.local/share/nvim/site/plugin doesn't seem to work for me, nor does overriding it:

$ NVIM_GTK_RUNTIME_PATH=/home/mischka/projects/neovim-gtk/runtime/ RUST_BACKTRACE=1 REMOTE_HOST=localhost cargo run -- --nvim-bin-path ssh-nvim --no-fork
   Compiling nvim-gtk v0.4.1 (/home/mischka/projects/neovim-gtk)
    Finished dev [unoptimized + debuginfo] target(s) in 7.35s
     Running `target/debug/nvim-gtk --nvim-bin-path ssh-nvim --no-fork`
[2022-03-12T13:06:28Z ERROR nvim_gtk::shell] Error reading message
thread 'tokio-runtime-worker' panicked at 'Cannot drop a runtime in a context where blocking is not allowed. This happens when a runtime is dropped from within an asynchronous context.', /home/mischka/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.16.1/src/runtime/blocking/shutdown.rs:51:21
stack backtrace:

It seems like my issues are unrelated to the runtime, commenting out attempting to load them entirely (which doesn't seem like it should make loading fail, seems like it would just remove some GUI functionality) doesn't work either.

My issue seems to be related to the PosInt(27) error reported by nvim-rs, though sadly I have no idea what that means.

[2022-03-12T13:08:38Z ERROR nvim_gtk::shell] DecodeError(InvalidMessage(NotAnArray(Integer(PosInt(27)))), None)

Removing my init.vim has no effect either.

jacobmischka avatar Mar 12 '22 12:03 jacobmischka

I think the easiest solution for this would be for us to just embed the runtime file in neovim-gtk itself, since simply sending the vimscript in our runtime file through RPC calls should be the same as loading it as a runtime file (at least iirc)

Lyude avatar Mar 12 '22 19:03 Lyude

Yeah, I think that should be equivalent and not too difficult.

bk2204 avatar Mar 13 '22 23:03 bk2204

Mind trying the commit I just pushed to see if it fixes your issue?

Lyude avatar Apr 10 '22 23:04 Lyude

I will try tomorrow when I have a suitable environment set up.

bk2204 avatar Apr 11 '22 00:04 bk2204

Hmmm, that doesn't appear to work for me on Neovim 0.4.4. I get, "Invalid method: nvim_exec".

bk2204 avatar Apr 11 '22 18:04 bk2204

Hmmm, that doesn't appear to work for me on Neovim 0.4.4. I get, "Invalid method: nvim_exec".

Are you able to use a newer version of neovim? To be honest, 0.4.4 is a bit out of date at this point (I don't tend to test with anything but the latest neovim anyhow).

Also - to be honest, any solution other then nvim_exec is going to be kind of hacky - since we use nvim_exec() specifically so that s: scope variables

Lyude avatar Apr 12 '22 04:04 Lyude

Unfortunately not. The environment I'm working in is a GitHub Codespace with Debian stretch, and while I expect to upgrade to Ubuntu focal sometime soon, for now, I'm stuck on that version of Neovim. I wish we were more prompt about upgrading our infrastructure, but until that occurs, I'll need to continue to use a version which supports that version of Neovim.

bk2204 avatar Apr 12 '22 21:04 bk2204