wbthomason / packer.nvim

A use-package inspired plugin manager for Neovim. Uses native packages, supports Luarocks dependencies, written in Lua, allows for expressive config
MIT License
7.75k stars 261 forks source link

Error executing lua vim/shared.lua:0: s: expected string, got table #1043

Closed Allaman closed 1 year ago

Allaman commented 1 year ago

Steps to reproduce

Running :PackerSync

Actual behaviour

E5108: Error executing lua vim/shared.lua:0: s: expected string, got table
stack traceback:
        [C]: in function 'error'
        vim/shared.lua: in function 'validate'
        vim/shared.lua: in function 'gsplit'
        vim/shared.lua: in function 'split'
        ...e/nvim/site/pack/packer/start/packer.nvim/lua/packer.lua:286: in function 'manage'
        ...e/nvim/site/pack/packer/start/packer.nvim/lua/packer.lua:339: in function 'manage_all_plugins'
        ...e/nvim/site/pack/packer/start/packer.nvim/lua/packer.lua:551: in function 'sync'
        [string ":lua"]:1: in main chunk

After rerunning PackerSync packer wants to delete half of my plugins which I do not confirm. Nevertheless, after starting a new nvim instance I get a "virgin" Neovim although all my plugins folders are still there.

Running PackerCompiledoes not help

Deleting packer_compiled.lua does not help

Reverting my local config to my latest main branch (which is working for sure) results in the same error

Expected behaviour

No errors :)

packer files

Plugin specification file(s) [config](https://github.com/Allaman/nvim)
packer log file no content
packer compiled file ``` -- Automatically generated packer.nvim plugin loader code if vim.api.nvim_call_function('has', {'nvim-0.5'}) ~= 1 then vim.api.nvim_command('echohl WarningMsg | echom "Invalid Neovim version for packer.nvim! | echohl None"') return end vim.api.nvim_command('packadd packer.nvim') local no_errors, error_msg = pcall(function() _G._packer = _G._packer or {} _G._packer.inside_compile = true local time local profile_info local should_profile = false if should_profile then local hrtime = vim.loop.hrtime profile_info = {} time = function(chunk, start) if start then profile_info[chunk] = hrtime() else profile_info[chunk] = (hrtime() - profile_info[chunk]) / 1e6 end end else time = function(chunk, start) end end local function save_profiles(threshold) local sorted_times = {} for chunk_name, time_taken in pairs(profile_info) do sorted_times[#sorted_times + 1] = {chunk_name, time_taken} end table.sort(sorted_times, function(a, b) return a[2] > b[2] end) local results = {} for i, elem in ipairs(sorted_times) do if not threshold or threshold and elem[2] > threshold then results[i] = elem[1] .. ' took ' .. elem[2] .. 'ms' end end _G._packer.profile_output = results end time([[Luarocks path setup]], true) local package_path_str = "/Users/michael/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?.lua;/Users/michael/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?/init.lua;/Users/michael/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?.lua;/Users/michael/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?/init.lua" local install_cpath_pattern = "/Users/michael/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/lua/5.1/?.so" if not string.find(package.path, package_path_str, 1, true) then package.path = package.path .. ';' .. package_path_str end if not string.find(package.cpath, install_cpath_pattern, 1, true) then package.cpath = package.cpath .. ';' .. install_cpath_pattern end time([[Luarocks path setup]], false) time([[try_loadstring definition]], true) local function try_loadstring(s, component, name) local success, result = pcall(loadstring(s), name, _G.packer_plugins[name]) if not success then vim.schedule(function() vim.api.nvim_notify('packer.nvim: Error running ' .. component .. ' for ' .. name .. ': ' .. result, vim.log.levels.ERROR, {}) end) end return result end time([[try_loadstring definition]], false) time([[Defining packer_plugins]], true) _G.packer_plugins = { LuaSnip = { config = { 'require("config/luasnip")' }, loaded = true, path = "/Users/michael/.local/share/nvim/site/pack/packer/start/LuaSnip", url = "https://github.com/L3MON4D3/LuaSnip" }, ["Navigator.nvim"] = { config = { 'require("config/navigator")' }, loaded = true, path = "/Users/michael/.local/share/nvim/site/pack/packer/start/Navigator.nvim", url = "https://github.com/numToStr/Navigator.nvim" }, ["cmp-buffer"] = { loaded = true, path = "/Users/michael/.local/share/nvim/site/pack/packer/start/cmp-buffer", url = "https://github.com/hrsh7th/cmp-buffer" }, ["cmp-calc"] = { loaded = true, path = "/Users/michael/.local/share/nvim/site/pack/packer/start/cmp-calc", url = "https://github.com/hrsh7th/cmp-calc" }, ["cmp-cmdline"] = { loaded = true, path = "/Users/michael/.local/share/nvim/site/pack/packer/start/cmp-cmdline", url = "https://github.com/hrsh7th/cmp-cmdline" }, ["cmp-nvim-lsp"] = { loaded = true, path = "/Users/michael/.local/share/nvim/site/pack/packer/start/cmp-nvim-lsp", url = "https://github.com/hrsh7th/cmp-nvim-lsp" }, ["cmp-nvim-lsp-signature-help"] = { loaded = true, path = "/Users/michael/.local/share/nvim/site/pack/packer/start/cmp-nvim-lsp-signature-help", url = "https://github.com/hrsh7th/cmp-nvim-lsp-signature-help" }, ["cmp-path"] = { loaded = true, path = "/Users/michael/.local/share/nvim/site/pack/packer/start/cmp-path", url = "https://github.com/hrsh7th/cmp-path" }, ["cmp-rg"] = { loaded = true, path = "/Users/michael/.local/share/nvim/site/pack/packer/start/cmp-rg", url = "https://github.com/lukas-reineke/cmp-rg" }, ["cmp-spell"] = { loaded = true, path = "/Users/michael/.local/share/nvim/site/pack/packer/start/cmp-spell", url = "https://github.com/f3fora/cmp-spell" }, cmp_luasnip = { loaded = true, path = "/Users/michael/.local/share/nvim/site/pack/packer/start/cmp_luasnip", url = "https://github.com/saadparwaiz1/cmp_luasnip" }, ["diffview.nvim"] = { commands = { "DiffviewOpen", "DiffviewClose", "DiffviewToggleFiles", "DiffviewFocusFiles" }, config = { 'require("config/diffview")' }, loaded = false, needs_bufread = false, only_cond = false, path = "/Users/michael/.local/share/nvim/site/pack/packer/opt/diffview.nvim", url = "https://github.com/sindrets/diffview.nvim" }, ["friendly-snippets"] = { loaded = true, path = "/Users/michael/.local/share/nvim/site/pack/packer/start/friendly-snippets", url = "https://github.com/rafamadriz/friendly-snippets" }, ["git-blame.nvim"] = { config = { 'require("config/git-blame")' }, loaded = true, path = "/Users/michael/.local/share/nvim/site/pack/packer/start/git-blame.nvim", url = "https://github.com/f-person/git-blame.nvim" }, ["gitsigns.nvim"] = { config = { 'require("config/gitsigns")' }, loaded = true, path = "/Users/michael/.local/share/nvim/site/pack/packer/start/gitsigns.nvim", url = "https://github.com/lewis6991/gitsigns.nvim" }, ["lualine.nvim"] = { config = { 'require("config/lualine")' }, loaded = true, path = "/Users/michael/.local/share/nvim/site/pack/packer/start/lualine.nvim", url = "https://github.com/nvim-lualine/lualine.nvim" }, ["neo-tree.nvim"] = { config = { 'require("config/neotree")' }, loaded = true, path = "/Users/michael/.local/share/nvim/site/pack/packer/start/neo-tree.nvim", url = "https://github.com/nvim-neo-tree/neo-tree.nvim" }, neogit = { commands = { "Neogit" }, config = { 'require("config/neogit")' }, loaded = false, needs_bufread = true, only_cond = false, path = "/Users/michael/.local/share/nvim/site/pack/packer/opt/neogit", url = "https://github.com/TimUntersberger/neogit" }, ["nui.nvim"] = { loaded = true, path = "/Users/michael/.local/share/nvim/site/pack/packer/start/nui.nvim", url = "https://github.com/MunifTanjim/nui.nvim" }, ["nvim-autopairs"] = { config = { 'require("config/nvim-autopairs")' }, loaded = true, path = "/Users/michael/.local/share/nvim/site/pack/packer/start/nvim-autopairs", url = "https://github.com/windwp/nvim-autopairs" }, ["nvim-bqf"] = { loaded = true, path = "/Users/michael/.local/share/nvim/site/pack/packer/start/nvim-bqf", url = "https://github.com/kevinhwang91/nvim-bqf" }, ["nvim-cmp"] = { config = { 'require("config/cmp")' }, loaded = true, path = "/Users/michael/.local/share/nvim/site/pack/packer/start/nvim-cmp", url = "https://github.com/hrsh7th/nvim-cmp" }, ["nvim-treesitter"] = { config = { 'require("config/treesitter")' }, loaded = true, path = "/Users/michael/.local/share/nvim/site/pack/packer/start/nvim-treesitter", url = "https://github.com/nvim-treesitter/nvim-treesitter" }, ["nvim-treesitter-endwise"] = { loaded = true, path = "/Users/michael/.local/share/nvim/site/pack/packer/start/nvim-treesitter-endwise", url = "https://github.com/RRethy/nvim-treesitter-endwise" }, ["nvim-treesitter-textobjects"] = { loaded = true, path = "/Users/michael/.local/share/nvim/site/pack/packer/start/nvim-treesitter-textobjects", url = "https://github.com/nvim-treesitter/nvim-treesitter-textobjects" }, ["nvim-ts-rainbow"] = { loaded = true, path = "/Users/michael/.local/share/nvim/site/pack/packer/start/nvim-ts-rainbow", url = "https://github.com/p00f/nvim-ts-rainbow" }, ["nvim-web-devicons"] = { loaded = true, path = "/Users/michael/.local/share/nvim/site/pack/packer/start/nvim-web-devicons", url = "https://github.com/kyazdani42/nvim-web-devicons" }, ["nvim-window-picker"] = { config = { 'require("config/nvim-window-picker")' }, loaded = true, path = "/Users/michael/.local/share/nvim/site/pack/packer/start/nvim-window-picker", url = "https://github.com/s1n7ax/nvim-window-picker" }, ["packer.nvim"] = { loaded = true, path = "/Users/michael/.local/share/nvim/site/pack/packer/start/packer.nvim", url = "https://github.com/wbthomason/packer.nvim" }, ["plenary.nvim"] = { loaded = true, path = "/Users/michael/.local/share/nvim/site/pack/packer/start/plenary.nvim", url = "https://github.com/nvim-lua/plenary.nvim" }, ["popup.nvim"] = { loaded = true, path = "/Users/michael/.local/share/nvim/site/pack/packer/start/popup.nvim", url = "https://github.com/nvim-lua/popup.nvim" }, ["telescope-file-browser.nvim"] = { loaded = true, path = "/Users/michael/.local/share/nvim/site/pack/packer/start/telescope-file-browser.nvim", url = "https://github.com/nvim-telescope/telescope-file-browser.nvim" }, ["telescope-fzf-native.nvim"] = { loaded = true, path = "/Users/michael/.local/share/nvim/site/pack/packer/start/telescope-fzf-native.nvim", url = "https://github.com/nvim-telescope/telescope-fzf-native.nvim" }, ["telescope-heading.nvim"] = { loaded = true, path = "/Users/michael/.local/share/nvim/site/pack/packer/start/telescope-heading.nvim", url = "https://github.com/crispgm/telescope-heading.nvim" }, ["telescope-packer.nvim"] = { loaded = true, path = "/Users/michael/.local/share/nvim/site/pack/packer/start/telescope-packer.nvim", url = "https://github.com/nvim-telescope/telescope-packer.nvim" }, ["telescope-symbols.nvim"] = { loaded = true, path = "/Users/michael/.local/share/nvim/site/pack/packer/start/telescope-symbols.nvim", url = "https://github.com/nvim-telescope/telescope-symbols.nvim" }, ["telescope-ui-select.nvim"] = { loaded = true, path = "/Users/michael/.local/share/nvim/site/pack/packer/start/telescope-ui-select.nvim", url = "https://github.com/nvim-telescope/telescope-ui-select.nvim" }, ["telescope-zoxide"] = { loaded = true, path = "/Users/michael/.local/share/nvim/site/pack/packer/start/telescope-zoxide", url = "https://github.com/jvgrootveld/telescope-zoxide" }, ["telescope.nvim"] = { config = { 'require("config/telescope")' }, loaded = true, path = "/Users/michael/.local/share/nvim/site/pack/packer/start/telescope.nvim", url = "https://github.com/nvim-telescope/telescope.nvim" }, ["vim-fugitive"] = { loaded = true, path = "/Users/michael/.local/share/nvim/site/pack/packer/start/vim-fugitive", url = "https://github.com/tpope/vim-fugitive" } } time([[Defining packer_plugins]], false) -- Config for: lualine.nvim time([[Config for lualine.nvim]], true) require("config/lualine") time([[Config for lualine.nvim]], false) -- Config for: telescope.nvim time([[Config for telescope.nvim]], true) require("config/telescope") time([[Config for telescope.nvim]], false) -- Config for: git-blame.nvim time([[Config for git-blame.nvim]], true) require("config/git-blame") time([[Config for git-blame.nvim]], false) -- Config for: gitsigns.nvim time([[Config for gitsigns.nvim]], true) require("config/gitsigns") time([[Config for gitsigns.nvim]], false) -- Config for: nvim-treesitter time([[Config for nvim-treesitter]], true) require("config/treesitter") time([[Config for nvim-treesitter]], false) -- Config for: LuaSnip time([[Config for LuaSnip]], true) require("config/luasnip") time([[Config for LuaSnip]], false) -- Config for: nvim-autopairs time([[Config for nvim-autopairs]], true) require("config/nvim-autopairs") time([[Config for nvim-autopairs]], false) -- Config for: Navigator.nvim time([[Config for Navigator.nvim]], true) require("config/navigator") time([[Config for Navigator.nvim]], false) -- Config for: neo-tree.nvim time([[Config for neo-tree.nvim]], true) require("config/neotree") time([[Config for neo-tree.nvim]], false) -- Config for: nvim-cmp time([[Config for nvim-cmp]], true) require("config/cmp") time([[Config for nvim-cmp]], false) -- Config for: nvim-window-picker time([[Config for nvim-window-picker]], true) require("config/nvim-window-picker") time([[Config for nvim-window-picker]], false) -- Command lazy-loads time([[Defining lazy-load commands]], true) pcall(vim.cmd, [[command -nargs=* -range -bang -complete=file DiffviewOpen lua require("packer.load")({'diffview.nvim'}, { cmd = "DiffviewOpen", l1 = , l2 = , bang = , args = , mods = "" }, _G.packer_plugins)]]) pcall(vim.cmd, [[command -nargs=* -range -bang -complete=file DiffviewClose lua require("packer.load")({'diffview.nvim'}, { cmd = "DiffviewClose", l1 = , l2 = , bang = , args = , mods = "" }, _G.packer_plugins)]]) pcall(vim.cmd, [[command -nargs=* -range -bang -complete=file DiffviewToggleFiles lua require("packer.load")({'diffview.nvim'}, { cmd = "DiffviewToggleFiles", l1 = , l2 = , bang = , args = , mods = "" }, _G.packer_plugins)]]) pcall(vim.cmd, [[command -nargs=* -range -bang -complete=file DiffviewFocusFiles lua require("packer.load")({'diffview.nvim'}, { cmd = "DiffviewFocusFiles", l1 = , l2 = , bang = , args = , mods = "" }, _G.packer_plugins)]]) pcall(vim.cmd, [[command -nargs=* -range -bang -complete=file Neogit lua require("packer.load")({'neogit'}, { cmd = "Neogit", l1 = , l2 = , bang = , args = , mods = "" }, _G.packer_plugins)]]) time([[Defining lazy-load commands]], false) _G._packer.inside_compile = false if _G._packer.needs_bufread == true then vim.cmd("doautocmd BufRead") end _G._packer.needs_bufread = false if should_profile then save_profiles() end end) if not no_errors then error_msg = error_msg:gsub('"', '\\"') vim.api.nvim_command('echohl ErrorMsg | echom "Error in packer_compiled: '..error_msg..'" | echom "Please check your config for correctness" | echohl None') end ```

Thanks!

Allaman commented 1 year ago

Update:

Going back (and pinning) Packer to commit hash b32b982d52664a0a6c5a43a5f9934f001d722d4e does solve the issue

akinsho commented 1 year ago

@Allaman can you please post the specific block of code that didn't work rather than your config repo. It's much harder to help debug things if we have to go through a whole config to find the offending line ourselves

Allaman commented 1 year ago

@akinsho unfortunately it's not easy for me to limit this error to a specific code block or produce a minimal (not) working example. As mentioned my config on my main branch used to work and as I figured out in the meantime pinning Packer to an earlier commit hash does work. So IMHO my config should be fine as the last commits do not indicate any major changes...?

Allaman commented 1 year ago

@akinsho Update: I could figure out that until this commit packer works as expected and then breaks with this commit

emretuna commented 1 year ago

Same issue here, any ideas how to roll back to previous version?

akinsho commented 1 year ago

@Allaman I understand what commit likely caused it, what I'm saying is that there is a specific element in the setup that interacts badly with the new change. We'd have a chance of fixing it and also keeping the new change if we knew what part of your config was breaking.

The point I'm making goes beyond this issue and is that more generally when opening an issue you should provide the maintainers as clear an indication as possible about what specific thing is causing the breakage rather than linking to a separate repository in this case I'd have to go into your repo find where and how you use packer and then check every plugin spec myself.

It is very helpful to provide a minimal config that causes an issue

@emretuna you can just set packer itself to a specific commit by specifying a commit until someone has time to deal with the issue. It would be easier to deal with a clear reproduction

Allaman commented 1 year ago

@akinsho

... provide the maintainers as clear an indication as possible about what specific thing is causing ...

The breaking commit hash is not clear?

It is very helpful to provide a minimal config that causes an issue

As mentioned it is hard for me to build a minimal example because I have no hint about what to look for. I don't even understand the change introduced in the breaking commit!

That being sad, the last couple of hours I copied various settings from my packer config (everything Packer related is in one file) to a Neovim installation by source in a Debian Docker container. I picked some random plugins from the plugins that Packer would wrongly delete (cp. the screenshot) as well as plugins that seem to be "ok"

image

Unfortunately, I could not reproduce the error. The last couple of days I spent 10 hours of troubleshooting Neovim (not just with this issue) and my "budget for tinkering around" is used up. I need to get things done again.

I am sorry that I can not provide more input

akinsho commented 1 year ago

@Allaman thanks for looking into it, apologies I wasn't clear enough with what I meant. What I was getting at is that, presumably, this change is only brought about when plugins are specified in a certain way, for example if you had a bunch of plugins specified as.

use 'plugin1/thing'
use 'plugin2/thing'

This would not reproduce. Presumably having plugins using the requires key is the issue, but probably using the requires key in some specific layout is what is causing this specific issue.

I imagine it's not just any use of the requires key, but a specific usage somewhere in your config. The reason I asked for a minimal reproduction rather than a commit is that this change isn't global to all of packer or all its functionality, only a very specific part of packer was changed. So it isn't something that will be affecting all users maybe.

When debugging your config, you might try and remove certain plugins and see if any specific plugin is producing this issue. Since it was @wbthomason's change, I'll wait to see if he'd like to investigate further or revert the change.

wbthomason commented 1 year ago

Thanks for this report! I found the error in your config, @Allaman @emretuna (it looks like both of your configs are related?)

Specifically, you have a bug here: https://github.com/emretuna/.dotfiles/blob/main/nvim/.config/nvim/lua/plugins.lua#L142

The config key is nested in your requires table. Unless I'm forgetting about an undocumented change to packer, we don't allow this (the only reason would be config sharing for multiple plugin specs, and afair that idea was never implemented).

The referenced commit exposed this bug by fixing an omitted case in how packer detects if a requirement is a single specification, a list of specifications, etc.

I'm going to close this issue for now - moving the config key fixes the error for me, using @Allaman's config. Please feel free to reopen if you're having additional problems.

Allaman commented 1 year ago

Thanks @wbthomason. That's it! I guess I wouldn't found this bug in ages πŸ™ˆ

emretuna commented 1 year ago

https://github.com/emretuna/.dotfiles/blob/main/nvim/.config/nvim/lua/plugins.lua#L142

Thanks for the solution @wbthomason. Yes I've used some configs from @Allaman repo.(He has awesome config by the way, thanks for it 🎊 )

wbthomason commented 1 year ago

Yeah, not gonna lie, I made some changes to my own config after looking through yours just now