nvim-tree.lua icon indicating copy to clipboard operation
nvim-tree.lua copied to clipboard

Error executing vim. schedule lua callback: ...cker/start/nvim-tree. lua/lua/nvim-tree/renderer/init.lua:397

Open an1ndra opened this issue 3 years ago • 14 comments

OS Pop os 21.10

Neovim version

NVIM v0.6.1
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by [email protected]

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/share/nvim"

Nvim-tree version master branch

Describe the bug Every time I try to open nvim-tree this error show. and no icon, files and folder show. Screenshot from 2022-02-02 21-47-25

To Reproduce Use any nvim-tree command example NvimTreeRefresh, NvimTreeOpen

Expected behavior Nvim Tree should be open without any error

an1ndra avatar Feb 02 '22 16:02 an1ndra

+1 I have exactly the same issue!

sebastianbock17 avatar Feb 03 '22 10:02 sebastianbock17

cannot reproduce this, do you have newlines in your filenames ?

kyazdani42 avatar Feb 03 '22 12:02 kyazdani42

The fastest method for reproduction is e.g. just installing lunarvim, I deleted all the configs (from .local/share and .config), and I get the error directly upon start now. Its strange since it only happened since this morning …

Error executing vim.schedule lua callback: ...cker/start/nvim-tree.lua/lua/nvim-tree/renderer/init.lua:397: String cannot contain newlines
stack traceback:
        [C]: in function 'nvim_buf_set_lines'
        ...cker/start/nvim-tree.lua/lua/nvim-tree/renderer/init.lua:397: in function 'draw'
        ...te/pack/packer/start/nvim-tree.lua/lua/nvim-tree/lib.lua:49: in function 'redraw'
        ...te/pack/packer/start/nvim-tree.lua/lua/nvim-tree/lib.lua:28: in function 'callback'
        ...ck/packer/start/nvim-tree.lua/lua/nvim-tree/git/init.lua:77: in function 'on_end'
        .../packer/start/nvim-tree.lua/lua/nvim-tree/git/runner.lua:68: in function 'on_finish'
        .../packer/start/nvim-tree.lua/lua/nvim-tree/git/runner.lua:77: in function 'cb'
        vim.lua:285: in function <vim.lua:285>

So in line 397 is the following:

  api.nvim_buf_set_lines(view.View.bufnr, 0, -1, false, lines)

The checkhealth does not even have nvim-tree mentioned and it all seems alright.

One strange thing though, is that I can not access any folder for my user (e.g. /home/test/)

But, I can activate nvim-tree and open folders that are on my usb stick - thats really strange.. I hope a solution can be found, I can (sort of) live with that in the moment, but now I can't navigate on my .config folder with nvim-tree …

@kyazdani42 The message comes without even opening a specific file, just running nvim / lvim in a folder which is in any home directory produces this error, regardless of the contents from files. When I start from a directory in a external harddrive, it works.

Another Edit and a hint:

When I use :Lexplore, then focus on lvim pane right, and when I then refocus the pane on the left from :Lexplore, the window becomes nvim-tree instead :Lexplore - but under one condition - it works only, if I navigated into a specific folder with :Lexplore. The default folder for :lexplore is just the /home/user directory.

So if I navigate into the ~/.config/nvim/ directory with :Lexplore, then focus the nvim buffer on the right, then refocus the :Lexplore buffer, it transforms into nvim-tree with its icons and functions. After this, I can close and also reopen the nvim-tree buffer again.

So with this workaround, nvim-tree still works for a session. So it has to do with setting a current working directory maybe? I hope someone else with better knowledge can reproduce, must be a bug somehow.

Any solutions found @meanindra ?

sebastianbock17 avatar Feb 03 '22 18:02 sebastianbock17

For me it's working again, don't really know what caused the issue. It worked since I deleted the compiled file from packer in plugin folder, running :PackerCompile, :PackerSync, and :Packer Update

It's strange because I had tried it before, but now it works again like a charm!

sebastianbock17 avatar Feb 04 '22 19:02 sebastianbock17

might be an issue with the lunarvim config maybe ? i'm not sure. Or maybe conflicting with another plugin.

kyazdani42 avatar Feb 05 '22 10:02 kyazdani42

@meanindra perhaps you could provide a reproducible test case:

Start with the minimal config as per the bug report template: https://github.com/kyazdani42/nvim-tree.lua/issues/new/choose

Add your nvim-tree config. If you still cannot reproduce, add your plugins and their configuration until you can reproduce.

Post that modified minimal config and we can attempt to reproduce that.

alex-courtis avatar Mar 26 '22 04:03 alex-courtis

I had the same problem and (after i reinstall neovim and nvim-tree) the issue didn't solve!

finally i figure out the problem. it's seem that i had one file the contain newline in it.

so in order to reproduce this issue all you need to do is create a file that contain a newline and the error thrown.

example:

touch file$'\n'

hope it's will help 😄

zamboney avatar May 17 '22 10:05 zamboney

is it even a good idea for a filename to contain newlines :smile: ? I guess we shouldn't crash though, but still it's a bit weird.

kyazdani42 avatar May 18 '22 11:05 kyazdani42

Closing due to inactivity.

alex-courtis avatar Sep 03 '22 03:09 alex-courtis

i have the same error but i have fixed by just commenting ignore_list at update_focued_file

i don't why it works but it does update_focused_file = { enable = true, update_cwd = true, --[[ ignore_list = { "/node_modules" }, ]] },

Oumar-1 avatar Mar 19 '23 03:03 Oumar-1

Hello, i m also experiencing this issue. I can confirm that crash is cause by newline in file name. In my case, file with newline in name was created by mistake and i am convinced that it should not lead to crash of nvim-tree.

Error executing Lua callback: .../share/nvim/lazy/lazy.nvim/lua/lazy/core/handler/cmd.lua:48: Vim:Error executing Lua callback: .../nvim/lazy/nvim-tree.lua/lua/nvim-tree/renderer/init.lua:23: 'replacement string' 
item contains newlines                                                                                                                                                                                               
stack traceback:                                                                                                                                                                                                     
        [C]: in function 'nvim_buf_set_lines'                                                                                                                                                                        
        .../nvim/lazy/nvim-tree.lua/lua/nvim-tree/renderer/init.lua:23: in function '_draw'                                                                                                                          
        .../nvim/lazy/nvim-tree.lua/lua/nvim-tree/renderer/init.lua:59: in function 'draw'                                                                                                                           
        ...ocal/share/nvim/lazy/nvim-tree.lua/lua/nvim-tree/lib.lua:195: in function 'open_view_and_draw'                                                                                                            
        ...ocal/share/nvim/lazy/nvim-tree.lua/lua/nvim-tree/lib.lua:259: in function 'open'                                                                                                                          
        ...m/lazy/nvim-tree.lua/lua/nvim-tree/actions/tree/open.lua:32: in function 'open'                                                                                                                           
        ...share/nvim/lazy/nvim-tree.lua/lua/nvim-tree/commands.lua:51: in function <...share/nvim/lazy/nvim-tree.lua/lua/nvim-tree/commands.lua:50>                                                                 
        [C]: in function 'cmd'                                                                                                                                                                                       
        .../share/nvim/lazy/lazy.nvim/lua/lazy/core/handler/cmd.lua:48: in function <.../share/nvim/lazy/lazy.nvim/lua/lazy/core/handler/cmd.lua:16>                                                                 
stack traceback:                                                                                                                                                                                                     
        [C]: in function 'cmd'                                                                                                                                                                                       
        .../share/nvim/lazy/lazy.nvim/lua/lazy/core/handler/cmd.lua:48: in function <.../share/nvim/lazy/lazy.nvim/lua/lazy/core/handler/cmd.lua:16> 
VIM v0.9.5
Build type: Release
LuaJIT 2.1.1702233742


nvim-tree: v1.3.0

Samgarr avatar Apr 22 '24 11:04 Samgarr

Replicated with touch foo$'\n'bar

alex-courtis avatar Apr 23 '24 00:04 alex-courtis

This should be resolved - displaying, opening and renaming files.

I'd be grateful if you tested a fix @Samgarr

cd /path/to/nvim-tree.lua
git pull
git checkout 925-handle-newlines-in-file-names

When you're finished testing:

git checkout master

alex-courtis avatar Apr 23 '24 02:04 alex-courtis

@Samgarr I'd be grateful for your testing this, as it's operating system dependent.

alex-courtis avatar Apr 28 '24 03:04 alex-courtis

Sorry for late response, i didn't notice the notification. I can confirm that the fix works for me.

Samgarr avatar May 01 '24 20:05 Samgarr