Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: lazy.sync { plugins = ... }: attempt to index field '_' (a nil value) #145

Closed
3 tasks done
LostNeophyte opened this issue Dec 24, 2022 · 1 comment · Fixed by #129
Closed
3 tasks done

bug: lazy.sync { plugins = ... }: attempt to index field '_' (a nil value) #145

LostNeophyte opened this issue Dec 24, 2022 · 1 comment · Fixed by #129
Labels
bug Something isn't working

Comments

@LostNeophyte
Copy link

Did you check docs and existing issues?

  • I have read all the lazy docs
  • I have searched the existing issues of lazy
  • I have searched the exsiting issues of the plugin I have a problem with

Neovim version (nvim -v)

NVIM v0.9.0-dev+519-g2d8bbe468

Operating system/version

Fedora 36

Describe the bug

In readme it says that
require("lazy").sync(opts?) and
require("lazy").install(opts?) and
require("lazy").update(opts?) and
require("lazy").clean(opts?)

take opts as an argument and that opts can have a plugins key,
which is "a list of plugin names to run the operation on",
but if I pass { plugins = {"lazy.nvim"} } to any of these functions,
it results in the error below or attempt to index field '_' (a nil value) if I add vim.schedule to lazy/core/util.lua/notify()

Error executing luv callback:                                                                                                                                                                                                                   
vim/_editor.lua:0: E5560: nvim_err_writeln must not be called in a lua loop callback                                                                                                                                                            
stack traceback:                                                                                                                                                                                                                                
        [C]: in function 'nvim_err_writeln'                                                                                                                                                                                                     
        vim/_editor.lua: in function 'notify'                                                                                                                                                                                                   
        .../lazy.nvim/lua/lazy/core/util.lua:207: in function 'notify'                                                                                                                                                   
        .../lazy.nvim/lua/lazy/core/util.lua:221: in function 'error'                                                                                                                                                    
        .../lazy.nvim/lua/lazy/manage/runner.lua:50: in function '_resume'                                                                                                                                                   
        .../lazy.nvim/lua/lazy/manage/runner.lua:63: in function 'resume'                                                                                                                                                    
        .../lazy.nvim/lua/lazy/manage/runner.lua:87: in function <.../lazy.nvim/lua/lazy/manage/runner.lua:86>

Steps To Reproduce

  1. diff --git a/lua/lazy/core/util.lua b/lua/lazy/core/util.lua
    index 1c0facb..c601b07 100644
    --- a/lua/lazy/core/util.lua
    +++ b/lua/lazy/core/util.lua
    @@ -204,6 +204,7 @@ function M.notify(msg, level)
           "\n"
         )
       end
    +  vim.schedule(function()
       vim.notify(msg, level, {
         on_open = function(win)
           vim.wo[win].conceallevel = 3
    @@ -214,6 +215,7 @@ function M.notify(msg, level)
         end,
         title = "lazy.nvim",
       })
    +  end)
     end
     
     ---@param msg string|string[]
  2. nvim -u repro.lua

    :lua require("lazy").sync { plugins = {"lazy.nvim"} }
    -- Could not resume a task
    -- lazy.nvim/lua/lazy/manage/task/git.lua:86: attempt to index field '_' (a nil value)
    :lua require("lazy").clean { plugins = {"lazy.nvim"} }
    -- Could not resume a task
    -- lazy.nvim/lua/lazy/manage/task/fs.lua:9: attempt to index field '_' (a nil value)
    :lua require("lazy").install { plugins = {"lazy.nvim"} }
    -- Could not resume a task
    -- lazy.nvim/lua/lazy/manage/task/git.lua:52: attempt to index field '_' (a nil value)
    :lua require("lazy").update { plugins = {"lazy.nvim"} }
    -- Could not resume a task
    -- lazy.nvim/lua/lazy/manage/task/git.lua:86: attempt to index field '_' (a nil value)

Expected Behavior

require("lazy").sync { plugins = {"lazy.nvim"} }: update plugin if needed
require("lazy").clean { plugins = {"lazy.nvim"} }: do nothing, since plugin is use
require("lazy").install { plugins = {"lazy.nvim"} }: do nothing, since plugin is installed
require("lazy").update { plugins = {"lazy.nvim"} }: update if needed

Repro

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({
    "git",
    "clone",
    "--filter=blob:none",
    "--single-branch",
    "https://github.com/folke/lazy.nvim.git",
    lazypath,
  })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  -- add any other pugins here
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here
@LostNeophyte LostNeophyte added the bug Something isn't working label Dec 24, 2022
@folke folke closed this as completed in 74d8b8e Dec 24, 2022
@LostNeophyte
Copy link
Author

All good now, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant