lewis6991 / pckr.nvim

Spiritual successor of https://github.com/wbthomason/packer.nvim
MIT License
250 stars 13 forks source link

Error: attempt to yield across C -call boundary #17

Open juru1234 opened 7 months ago

juru1234 commented 7 months ago

Steps to reproduce

Use pckr.nvim Quickstart example with one Plugin.

Actual behaviour

Error when calling require('pckr').add{} in init.lua

Error detected while processing /home/julian/.config/nvim/init.lua:
E5113: Error while calling lua chunk: ...an/.local/share/nvim/pckr/pckr.nvim/lua/pckr/actions.lua:337: attempt to yield across C
-call boundary
stack traceback:
        [C]: in function 'main'
        ...an/.local/share/nvim/pckr/pckr.nvim/lua/pckr/actions.lua:337: in function 'sync'
        ...an/.local/share/nvim/pckr/pckr.nvim/lua/pckr/actions.lua:373: in function 'install'
        /home/julian/.local/share/nvim/pckr/pckr.nvim/lua/pckr.lua:55: in function 'add'
        /home/julian/.config/nvim/init.lua:19: in main chunk

Expected behaviour

Should work.

lewis6991 commented 7 months ago

Unable to reproduce with this init.lua:

local function bootstrap_pckr()
  local pckr_path = vim.fn.stdpath("data") .. "/pckr/pckr.nvim"

  if not vim.loop.fs_stat(pckr_path) then
    vim.fn.system({
      'git',
      'clone',
      "--filter=blob:none",
      'https://github.com/lewis6991/pckr.nvim',
      pckr_path
    })
  end

  vim.opt.rtp:prepend(pckr_path)
end

bootstrap_pckr()

require('pckr').add{'tpope/vim-commentary'}
nvim --clean -u init.lua
lewis6991 commented 7 months ago

...an/.local/share/nvim/pckr/pckr.nvim/lua/pckr/actions.lua:337

This line is essentially doing:

vim.schedule(function()
   coroutine.yield()
end)

With should work in a Neovim built with LuaJIT, see https://luajit.org/extensions.html#resumable

I expect there is something weird going on with your Neovim build, specifically LuaJIT. Did you build from source or via a distribution package? If the latter, then that's likely the cause of the problem.

juru1234 commented 7 months ago

Thanks for the fast answer. Yes, I'm using the neovim distribution package of Fedora 39 on x86. Then this might be an issue with Fedora's package...

juru1234 commented 7 months ago

But why is lazy.nvim and other luajit stuff working with the Fedora package?

lewis6991 commented 7 months ago

I don't think lazy.nvim calls coroutine.yield inside a vim.schedule callback.

If you use nvim-treesitter (when it updates to 1.0) or gitsigns.nvim you'll get the same issue since they use similar async handling code.

adigitoleo commented 4 months ago

For what it's worth, I got the same error but only with neovim 0.10 on an alpine/edge runner, log here.

If I ssh into the runner I can see:

build:~/quark.nvim$ nvim -V1 -v
NVIM v0.10.0
Build type: MinSizeRel
LuaJIT 2.1.1710398010

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

Am I to understand that the alpine build restricts some features? It seems that it was built with LuaJIT support.

lewis6991 commented 4 months ago

I would guess it is not built with LuaJIT.

adigitoleo commented 4 months ago

OK, yeah, works on the archlinux runner. Weird that alpine one declares luajit support without providing it but whatever. Should we add a check for luajit then? See :h lua-luajit, it says there is a lua global jit that we can check.

lewis6991 commented 4 months ago

Sure.

I wonder if this can be made to work with PUC Lua. We'd need async.lua to work properly.

But yeah, otherwise luajit is required.