Skip to content
This repository has been archived by the owner on Aug 12, 2023. It is now read-only.

bad argument #1 to 'unpack' (table expected , got string) #919

Closed
3 tasks done
shaeinst opened this issue Jun 17, 2022 · 6 comments
Closed
3 tasks done

bad argument #1 to 'unpack' (table expected , got string) #919

shaeinst opened this issue Jun 17, 2022 · 6 comments
Labels
bug Something isn't working

Comments

@shaeinst
Copy link
Contributor

FAQ

  • I have checked the FAQ and it didn't resolve my problem.

Issues

  • I have checked existing issues and there are no issues with the same problem.

Neovim Version

NVIM v0.8.0-dev+436-g279bc71f3-dirty

Operating System

Linux IL 5.18.3-arch1-1 #1 SMP PREEMPT_DYNAMIC Thu, 09 Jun 2022 16:14:10 +0000 x86_64 GNU/Linux

Minimal config

local builtins = require("null-ls.builtins")
local formatting = builtins.formatting
local sources = {
	formatting.lua_format.with({
			command = "lua-format",
			args = { "--indent-width", "1", "--tab-width", "4", "--use-tab", "--chop-down-table", },
		})
}
require("null-ls").setup({
	sources = sources
})

Steps to reproduce

E5108: Error executing lua ...te/pack/packer/start/null-ls.nvim/lua/null-ls/client.lua:39: bad argument #1 to 'unpack' (table expected
, got string)

as you can clearly see, this line complaining about string and table. That's why unpack causing error because it got string instead of table.
i tried with removing unpack from that line and every thing worked fine as expected.

Expected behavior

formatting with null-ls should work on latest neovim v0.8 as it working with v0.7

Actual behavior

formatting with null-ls should does not work with latest neovim v0.8 but it works fine with v0.7

Debug log

E5108: Error executing lua ...te/pack/packer/start/null-ls.nvim/lua/null-ls/client.lua:39: bad argument #1 to 'unpack' (table expected
, got string)
stack traceback:
        [C]: in function 'unpack'
        ...te/pack/packer/start/null-ls.nvim/lua/null-ls/client.lua:39: in function 'capability_is_disabled'
        ...te/pack/packer/start/null-ls.nvim/lua/null-ls/client.lua:50: in function <...te/pack/packer/start/null-ls.nvim/lua/null-ls/
client.lua:48>
        vim/shared.lua: in function 'tbl_filter'
        /usr/local/share/nvim/runtime/lua/vim/lsp/buf.lua:124: in function 'select_client'
        /usr/local/share/nvim/runtime/lua/vim/lsp/buf.lua:156: in function 'formatting'
[TRACE Fri 17 Jun 2022 09:30:10 AM +0545] ...te/pack/packer/start/null-ls.nvim/lua/null-ls/client.lua:106: starting null-ls client
[TRACE Fri 17 Jun 2022 09:30:10 AM +0545] .../site/pack/packer/start/null-ls.nvim/lua/null-ls/rpc.lua:121: received LSP request for method initialize
[DEBUG Fri 17 Jun 2022 09:30:10 AM +0545] ...te/pack/packer/start/null-ls.nvim/lua/null-ls/client.lua:161: unable to notify client for method textDocument/didOpen (client not active): {
  textDocument = {
    uri = "file:///home/uselay/codeDNA/ws/lab/Experiment/lua.lua"
  }
}
[TRACE Fri 17 Jun 2022 09:30:10 AM +0545] .../site/pack/packer/start/null-ls.nvim/lua/null-ls/rpc.lua:146: received LSP notification for method initialized
[TRACE Fri 17 Jun 2022 09:30:10 AM +0545] .../site/pack/packer/start/null-ls.nvim/lua/null-ls/rpc.lua:146: received LSP notification for method textDocument/didOpen
[TRACE Fri 17 Jun 2022 09:30:10 AM +0545] ...ack/packer/start/null-ls.nvim/lua/null-ls/generators.lua:21: running generators for method NULL_LS_DIAGNOSTICS_ON_OPEN
[DEBUG Fri 17 Jun 2022 09:30:10 AM +0545] ...ack/packer/start/null-ls.nvim/lua/null-ls/generators.lua:24: no generators available

Help

No

Implementation help

No response

Requirements

  • I have read and followed the instructions above and understand that my issue will be closed if I did not provide the required information.
@shaeinst shaeinst added the bug Something isn't working label Jun 17, 2022
@griffenliu
Copy link

I have the same problem.

@jose-elias-alvarez
Copy link
Owner

jose-elias-alvarez commented Jun 18, 2022

I can't replicate this. Your issue is almost definitely outdated runtime files - looking at the error trace, it points at this line followed by this line, neither one of which actually corresponds to the referenced function. You can verify by running :lua print(vim.inspect(vim.lsp._request_name_to_capability)). If this prints a table with string values (not table values) your runtime files don't correspond to the version of Neovim you're using.

If that's the case, all I can suggest is to clean out your runtime files, rebuild from source (or use whatever method you used in the first place), and make sure you don't have any other versions of Neovim installed.

@shaeinst
Copy link
Contributor Author

output of :lua print(vim.inspect(vim.lsp._request_name_to_capability))

{
  ["codeLens/resolve"] = "code_lens_resolve",
  ["textDocument/codeAction"] = "code_action",
  ["textDocument/codeLens"] = "code_lens",
  ["textDocument/completion"] = "completion",
  ["textDocument/declaration"] = "declaration",
  ["textDocument/definition"] = "goto_definition",
  ["textDocument/documentHighlight"] = "document_highlight",
  ["textDocument/documentSymbol"] = "document_symbol",
  ["textDocument/formatting"] = "document_formatting",
  ["textDocument/hover"] = "hover",
  ["textDocument/implementation"] = "implementation",
  ["textDocument/prepareCallHierarchy"] = "call_hierarchy",
  ["textDocument/prepareRename"] = "rename",
  ["textDocument/rangeFormatting"] = "document_range_formatting",
  ["textDocument/references"] = "find_references",
  ["textDocument/rename"] = "rename",
  ["textDocument/signatureHelp"] = "signature_help",
  ["textDocument/typeDefinition"] = "type_definition",
  ["workspace/executeCommand"] = "execute_command",
  ["workspace/symbol"] = "workspace_symbol"
}

let me try with clean neovim

@shaeinst
Copy link
Contributor Author

@jose-elias-alvarez you're correct. My runtime files were corrupted. But, i tried by uninstalling and reinstalling neovim, i was still getting that error. after deleting ~/.local/share/nvim and reinstalling, it get fixed.
Thanks.

@shaeinst
Copy link
Contributor Author

and now i understand why, because i have installed nevim-0.7 using My distoro's package manager (pacman) and that's why ~/.local/share/nvim belonged to neovim-0.7. so, whenever i ran nevim-0.8, it's was using nevim-0.7's runtime files.

@PriceHiller
Copy link

Thank you @shaeinst. You just got me out of ~3 hours of debugging on my latest update. As a note for anyone who can't read (like me lol) you need to wipe out ~/.local/share/nvim then install the version of Neovim you're looking for. If you have a packer_compiled make sure you nuke that too.

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

No branches or pull requests

4 participants