mikavilpas / yazi.nvim

A Neovim Plugin for the yazi terminal file manager
MIT License
214 stars 7 forks source link

Error when launching yazi #130

Open benjamin-voisin opened 1 week ago

benjamin-voisin commented 1 week ago

I'm using neovim v0.10.0 and Yazi v0.2.5 on arch. I copied the install script on the Readme for Lazy. When I try to launch yazi (with - or cw), the floating window appears but shows this error :

error: unexpected argument '>' found

Usage: yazi [OPTIONS] [ENTRY]

For more information, try '--help'.

[Process exited 2]
mikavilpas commented 1 week ago

Hi! Maybe the shell redirection isn't working correctly for you 🤔

Could you try setting log_level = vim.log.levels.DEBUG like in my config here (except don't comment it out like I have.

You can find the location of the log file by issuing :checkhealth yazi:

image

For me it prints out this:

[2024-06-24 19:09:56] DEBUG Opening yazi with the command: (yazi '/Users/mikavilpas/git/yazi.nvim' --local-events "rename,delete,trash,move,cd" --chooser-file "/var/folders/23/y7gf7hz129l56_83w_g49jl80000gn/T/nvim.mikavilpas/oL4In8/0" > "/var/folders/23/y7gf7hz129l56_83w_g49jl80000gn/T/nvim.mikavilpas/oL4In8/1")

Having done all this, do you get any errors if you run the yazi command in your shell? Any idea if anything could be wrong with that?

benjamin-voisin commented 1 week ago

I get this :

[2024-06-24 17:17:07] DEBUG Opening yazi with the command: (yazi '/home/binj/Documents/file.txt' --local-events "rename,delete,trash,move,cd" --chooser-file "/tmp/nvim.binj/S177ju/0" > "/tmp/nvim.binj/S177ju/1")

And it doesn't launch in my shell. I'm quite sure that this is because I use nushell (and the > operator is not as in bash). The command without the redirection :

yazi '/home/binj/Documents/file.txt' --local-events "rename,delete,trash,move,cd" --chooser-file "/tmp/nvim.binj/S177ju/0"

works in my shell without issues

mikavilpas commented 1 week ago

Okay, sounds like good progress. How have you set your neovim to use nushell?

What does nushell use for redirecting output to a file?

benjamin-voisin commented 1 week ago

Nushell is my default shell for my whole user, so nvim uses it. After some tries, here is the working command to reproduce the same comportment:

yazi '/home/binj/Documents/file.txt' --local-events "rename,delete,trash,move,cd" --chooser-file "/tmp/nvim.binj/S177ju/0" out> "/tmp/nvim.binj/S177ju/1"

(It's juste out> instead of >)

I'm looking at ways to easily know which shell we are using, but I don't find anything very satisfying. Something like echo $SHELL but ofc in nushell it's echo $env.SHELL...

mikavilpas commented 1 week ago

I don't know how well supported nushell is is neovim. I googled around for a bit and sadly found almost no results.

There is :shellredir

                        *'shellredir'* *'srr'*
'shellredir' 'srr'  string  (default ">", ">&" or ">%s 2>&1")
            global
    String to be used to put the output of a filter command in a temporary
    file.  See also |:!|.  See |option-backslash| about including spaces
    and backslashes.
    The name of the temporary file can be represented by "%s" if necessary
    (the file name is appended automatically if no %s appears in the value
    of this option).
    The default is ">".  For Unix, if the 'shell' option is "csh" or
    "tcsh" during initializations, the default becomes ">&".  If the
    'shell' option is "sh", "ksh", "mksh", "pdksh", "zsh", "zsh-beta",
    "bash" or "fish", the default becomes ">%s 2>&1".  This means that
    stderr is also included.  For Win32, the Unix checks are done and
    additionally "cmd" is checked for, which makes the default ">%s 2>&1".
    Also, the same names with ".exe" appended are checked for.
    The initialization of this option is done after reading the vimrc
    and the other initializations, so that when the 'shell' option is set
    there, the 'shellredir' option changes automatically unless it was
    explicitly set before.
    In the future pipes may be used for filtering and this option will
    become obsolete (at least for Unix).
    This option cannot be set from a |modeline| or in the |sandbox|, for
    security reasons.

But this looks pretty confusing. In yazi's case both output streams (stdout and stderr) are needed separately, and this option seems to mix them into one in some cases. I don't feel comfortable using it as it doesn't give a guarantee of not breaking for some users.

It might be a good idea to change your neovim to use a traditional shell by default, and enable nushell for specific use cases that you care about. I don't know how this can be done.