lf icon indicating copy to clipboard operation
lf copied to clipboard

Dialing to send server error

Open AmaruCoder opened this issue 1 year ago • 12 comments

When using the lf file manager in Alacritty, I keep receiving the message: dialing to send server: dial unix (a file name ending in sock) followed by connect: no such file or directory (see below).

I have tried lf with iTerm without getting this error.

To make things interesting, after I open lf in iTerm, lf stops giving the error message in Alacritty. Is this a bug or reflects a setting I am not aware of?

lf-in-alacritty

System

OS: MacOS Ventura 13.4.1 Alacritty version: 0.12.2 LF version: r31

AmaruCoder avatar May 10 '24 16:05 AmaruCoder

That looks like the socket used for remote commands. Check that the file exists and the server is running. You can also perform a basic test using the following command:

lf -remote 'send echo hello world'

joelim-work avatar May 12 '24 06:05 joelim-work

Thank you. When I run lf -remote 'send echo hello world', I get the same error message (see below). When I navigate to the folder involved, there is no lf.{user}.sock file. However, when I run lf in iTerm, there is no error, and there is a lf.{user}.sock file.

lf-no-such-file

So it seems that lf doesn't start the server under Alacritty. Is it there a way to fix that?

AmaruCoder avatar May 12 '24 22:05 AmaruCoder

There must be something wrong with your settings for Alacritty then, if remote commands work on iTerm.

The socket path is defined in the following code, which depends on XDG_RUNTIME_DIR: https://github.com/gokcehan/lf/blob/12e99fdb641565e3122ab62dce0b77e836aa69a4/os.go#L123-L128

joelim-work avatar May 13 '24 00:05 joelim-work

Also it might be possible for some reason the server itself doesn't start automatically on Alacritty? In that case you can try starting the server manually using lf -server.

joelim-work avatar May 13 '24 00:05 joelim-work

Thank you for the detailed response. I tried starting the server in Alacritty, using lf - server, but it didn't resolve the issue. I also tried to define XDG_RUNTIME_DIR without better luck. It seems, then, that the problem is that, somehow, the server doesn't get started when lf runs in Alacritty.

Again, if I run lf in iTerm and then in Alacritty, everything works.

AmaruCoder avatar May 14 '24 00:05 AmaruCoder

You have added an extra space, the command is lf -server, not lf - server.

Otherwise I'm not sure what the issue can be then. I tried using Alacritty and couldn't reproduce your issue. The server should either start and print hi! then continue running, or terminate with some error (e.g. socket already in use).

joelim-work avatar May 14 '24 01:05 joelim-work

I posted in the Alacritty Issues page, but they state that it is a problem with lf. Any suggestions to go from here?

AmaruCoder avatar May 14 '24 04:05 AmaruCoder

I didn't think it was an issue with Alacritty to begin with in the first place. However since I don't have any issues with the server starting up using Alacritty, it's practically impossible for me to investigate.

Unless you're willing to clone the repo and debug the following code yourself:

https://github.com/gokcehan/lf/blob/12e99fdb641565e3122ab62dce0b77e836aa69a4/main.go#L335-L337

https://github.com/gokcehan/lf/blob/12e99fdb641565e3122ab62dce0b77e836aa69a4/main.go#L159-L179

joelim-work avatar May 14 '24 06:05 joelim-work

Also if you're not interested in any of this server stuff, you can also try using lf -single instead of lf, which runs just the file manager itself without the server.

joelim-work avatar May 14 '24 06:05 joelim-work

Thank you for the detail reply. lf -single works fine. Of course, multiple windows are not an option for file operations. Regarding the code, unfortunately I haven't learned Go yet. I think that I will stick to iTerm for the time being. Thank you, again.

AmaruCoder avatar May 15 '24 22:05 AmaruCoder

I don't know if this helps.

I have tested under MacOs 13.4.1, Terminal, iTerm, and Alacritty, and all of them have the same issue discussed above.

iTerm worked because I had a shortcut to start lf in the form: lf /{bookmarks folder}.

I tried the same shortcut under Terminal and Alacritty, and both also work fine. My {bookmarks folder} is the path to a folder with symlinks to the folders I use most often.

I have made an alias to run lf that way, and that solves the issue. The alias is alias mylf='lf /{bookmarks folder}, where {bookmark folder} points to a folder within my home folder.

Why this works? It's still a mystery to me.

AmaruCoder avatar May 17 '24 22:05 AmaruCoder

So you're saying that running lf by itself doesn't cause the server to start, but running lf /some/path does? Have you tried starting lf directly on the command line without any kind of aliases, shortcuts or any other configuration at all?

Also have you tried enabling logging with the -log option?

I still can't reproduce this issue, but I'm guessing it might have something to do with the value of os.Args[0] in the line cmd := detachedCommand(os.Args[0], "-server"), though I could be completely wrong.

P.S. Another approach might be to use strace to log system calls made by lf. Assuming the server is created properly, it should fork a child process for the server and make an exec call with the appropriate arguments (requires the --follow-forks option to see this).

joelim-work avatar May 18 '24 02:05 joelim-work

I solved the issue. I downloaded Kitty, just to try another terminal, and after trying to run lf, I got the message lf not in $PATH. Which seemed strange, because I had installed lf under my user folder, which is in $PATH.

So I moved lf to /usr/local/bin, which appears earlier on my $PATH, and restarted the terminal. Now lf works everywhere!

Thank you for your help and patience. I really appreciate it. And, by the way, I wanted to troubleshoot this issue because I believe that lf is the best file manager out there.

AmaruCoder avatar May 18 '24 22:05 AmaruCoder

No worries, glad you solved your issue. :+1:

It's good that you have the patience to try out different things (e.g. installing another terminal) to figure out the root cause. Others might have given up, assumed it was a bug in lf, and moved onto a different file manager.

joelim-work avatar May 19 '24 03:05 joelim-work