nikvdp/neomux

server socket not created

Closed this issue · 5 comments

crides commented

Hi, this seems like a great idea, however I'm having trouble getting the plugin to work. Whenever I start a new shell with :Neomux, the vw, e commands fail, with nvr logging:

[!] Can't connect to: /tmp/nvimsocket

    The server (nvim) and client (nvr) have to use the same address.

    Server:

        Expose $NVIM_LISTEN_ADDRESS to the environment before
        starting nvim:

        $ NVIM_LISTEN_ADDRESS=/tmp/nvimsocket nvim

        Use `:echo v:servername` to verify the address.

    Client:

        Expose $NVIM_LISTEN_ADDRESS to the environment before
        using nvr or use its --servername option. If neither
        is given, nvr assumes "/tmp/nvimsocket".

        $ NVIM_LISTEN_ADDRESS=/tmp/nvimsocket nvr file1 file2
        $ nvr --servername /tmp/nvimsocket file1 file2
        $ nvr --servername 127.0.0.1:6789 file1 file2

    nvr is now starting a server on its own by running $NVR_CMD or 'nvim'.

    Use -s to suppress this message.

[*] Starting new nvim process with address /tmp/nvimsocket

None of the nvim processes have a --listen argument, nor can I find anything related in the source. How is this supposed to be used?

nikvdp commented

Hey @crides, glad to hear from you! That's definitely unusual, normally neovim injects the NVIM_LISTEN_ADDRESS into the environment when it starts a terminal session, and the vw, e, etc. commands make use of that env var to learn how to connect to the host Neovim session. This generally happens automagically, but it may be that something in your shell or neovim environment is interfering with that process, possibly your shell's rc files or an autocmd or other neovim plugin.

One thing to check is to try running env | grep NVIM from inside a shell (I'd try both a shell started via neovim's standard:term command and with :Neomux to see if the results differ). In a working setup that should output something like this:

NVIM=/run/user/1000/nvim.8222.0
NVIM_LISTEN_ADDRESS=/run/user/1000/nvim.8222.0

I suspect your output will be missing the NVIM and/or NVIM_LISTEN_ADDRESS vars, which would result in the errrors you're seeing . One thing to try is to do something like :echo $NVIM_LISTEN_ADDRESS (or :let @"=$NVIM_LISTEN_ADDRESS to copy the value to the clipboard directly), and then set NVIM_LISTEN_ADDRESS inside the shell yourself (ie export NVIM_LISTEN_ADDRESSS=<your pasted value>). If vw and friends work after that then we know that the issue lies in transferring the NVIM_LISTEN_ADDRESS value into your shell, and the next step would be figuring out what's preventing it from getting set automatically.

crides commented

Thanks for the detailed reply! The problem is with my Mac at work, and I tried this on my Android today and it seems to work fine. Let me try again on Monday

crides commented

I had the time to test on other platforms (Arch, and Termux), and it turns out the problem lies around the nvr binary provided. Installing the neovim-remote python package works fine, but using the provided binary does not (on Arch and Mac of course). Running nvr produces the following error (on Arch specifically):

Traceback (most recent call last):
  File "site-packages/nvr/nvr.py", line 574, in <module>
  File "site-packages/nvr/nvr.py", line 381, in main
  File "site-packages/pkg_resources/__init__.py", line 892, in require
  File "site-packages/pkg_resources/__init__.py", line 778, in resolve
pkg_resources.DistributionNotFound: The 'neovim-remote' distribution was not found and is required by the application
[1650857] Failed to execute script nvr

I'm not sure of the origin of the error, but it may be easier to just let the user install the python package manually, unless there's some other problem that I can't foresee yet.

Otherwise, I think this is a useful plugin. I'll tweak the keybindings more (c-w conflicts with kill-word in readline/zsh (it's useful even if I use vim mode there) for a start), but I'll definitely try to use a nvim-only workflow instead of a tmux-based one (though, the daemon would still be very useful, for remoting purposes).

nikvdp commented

Glad to hear it! Yea, the provided nvr binaries are a convenience wrapper to spare the end users the job of python (v)env mgmt, but right now I only provide prebuilt binaries for linux (amd64) and macOS (x86, but generally runs fine on apple silicon via rosetta). Running on arch on android is a pro move! Glad to hear neomux is exploring new terrain and that you got it all working.

Fwiw, I actually still use tmux, I just use it with neomux :) I have a set of extra functions (I should probably add them to neomux come to think of it) that makes each neomux term a separate window in a shared tmux session which provides the nice benefit that if nvim crashes you can still reconnect to the terminals from your last session

nikvdp commented

closing this, feel free to reopen if you find any other issues