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] nightly nvim: DiffViewOpen fails to open #488

Closed
mikesmithgh opened this issue Apr 23, 2024 · 5 comments · Fixed by #489
Closed

[Bug] nightly nvim: DiffViewOpen fails to open #488

mikesmithgh opened this issue Apr 23, 2024 · 5 comments · Fixed by #489
Labels
bug Something isn't working

Comments

@mikesmithgh
Copy link
Contributor

Description

:DiffViewOpen fails with an error on Neovim nightly

Expected behavior

diff view opens successfully

Actual behavior

   Error  12:50:45 msg_show.lua_error Error executing luv callback:
...cal/share/nvim/lazy/diffview.nvim/lua/diffview/async.lua:187: The coroutine failed with this message: 
	context: cur_thread=main co_thread=<thread 0x0104b92f08> co_func=...share/nvim/lazy/diffview.nvim/lua/diffview/vcs/utils.lua:69
...cal/share/nvim/lazy/diffview.nvim/lua/diffview/async.lua:187: The coroutine failed with this message: 
	context: cur_thread=main co_thread=<thread 0x0104b95168> co_func=...azy/diffview.nvim/lua/diffview/vcs/adapters/git/init.lua:1689
...cal/share/nvim/lazy/diffview.nvim/lua/diffview/async.lua:187: The coroutine failed with this message: 
	context: cur_thread=main co_thread=<thread 0x0104b9ac48> co_func=...share/nvim/lazy/diffview.nvim/lua/diffview/multi_job.lua:178
...cal/share/nvim/lazy/diffview.nvim/lua/diffview/async.lua:187: The coroutine failed with this message: 
	context: cur_thread=main co_thread=<thread 0x0104b9b7d0> co_func=...share/nvim/lazy/diffview.nvim/lua/diffview/multi_job.lua:106
...cal/share/nvim/lazy/diffview.nvim/lua/diffview/async.lua:187: The coroutine failed with this message: 
	context: cur_thread=main co_thread=<thread 0x0104b9ece0> co_func=...local/share/nvim/lazy/diffview.nvim/lua/diffview/job.lua:466
vim/_editor.lua:0: E5560: Vimscript function must not be called in a lua loop callback
stack traceback:
	[C]: in function 'has'
	vim/_editor.lua: in function 'deprecate'
	vim/shared.lua: in function 'tbl_islist'
	...al/share/nvim/lazy/diffview.nvim/lua/diffview/logger.lua:177: in function 'dstring'
	...cal/share/nvim/lazy/diffview.nvim/lua/diffview/async.lua:291: in function 'await'
	...local/share/nvim/lazy/diffview.nvim/lua/diffview/job.lua:477: in function <...local/share/nvim/lazy/diffview.nvim/lua/diffview/job.lua:466>
	[C]: in function 'xpcall'
	...cal/share/nvim/lazy/diffview.nvim/lua/diffview/async.lua:361: in function <...cal/share/nvim/lazy/diffview.nvim/lua/diffview/async.lua:358>
stack traceback:
	[C]: in function 'error'
	...cal/share/nvim/lazy/diffview.nvim/lua/diffview/async.lua:369: in function <...cal/share/nvim/lazy/diffview.nvim/lua/diffview/async.lua:358>
stack traceback:
	[C]: in function 'error'
	...cal/share/nvim/lazy/diffview.nvim/lua/diffview/async.lua:187: in function 'raise'
	...cal/share/nvim/lazy/diffview.nvim/lua/diffview/async.lua:307: in function 'await'
	...share/nvim/lazy/diffview.nvim/lua/diffview/multi_job.lua:129: in function <...share/nvim/lazy/diffview.nvim/lua/diffview/multi_job.lua:106>
	[C]: in function 'xpcall'
	...cal/share/nvim/lazy/diffview.nvim/lua/diffview/async.lua:361: in function <...cal/share/nvim/lazy/diffview.nvim/lua/diffview/async.lua:358>
stack traceback:
	[C]: in function 'error'
	...cal/share/nvim/lazy/diffview.nvim/lua/diffview/async.lua:369: in function <...cal/share/nvim/lazy/diffview.nvim/lua/diffview/async.lua:358>
stack traceback:
	[C]: in function 'error'
	...cal/share/nvim/lazy/diffview.nvim/lua/diffview/async.lua:187: in function 'raise'
	...cal/share/nvim/lazy/diffview.nvim/lua/diffview/async.lua:307: in function 'await'
	...share/nvim/lazy/diffview.nvim/lua/diffview/multi_job.lua:184: in function <...share/nvim/lazy/diffview.nvim/lua/diffview/multi_job.lua:178>
	[C]: in function 'xpcall'
	...cal/share/nvim/lazy/diffview.nvim/lua/diffview/async.lua:361: in function <...cal/share/nvim/lazy/diffview.nvim/lua/diffview/async.lua:358>
stack traceback:
	[C]: in function 'error'
	...cal/share/nvim/lazy/diffview.nvim/lua/diffview/async.lua:369: in function <...cal/share/nvim/lazy/diffview.nvim/lua/diffview/async.lua:358>
stack traceback:
	[C]: in function 'error'
	...cal/share/nvim/lazy/diffview.nvim/lua/diffview/async.lua:187: in function 'raise'
	...cal/share/nvim/lazy/diffview.nvim/lua/diffview/async.lua:307: in function 'await'
	...azy/diffview.nvim/lua/diffview/vcs/adapters/git/init.lua:1739: in function <...azy/diffview.nvim/lua/diffview/vcs/adapters/git/init.lua:1689>
	[C]: in function 'xpcall'
	...cal/share/nvim/lazy/diffview.nvim/lua/diffview/async.lua:361: in function <...cal/share/nvim/lazy/diffview.nvim/lua/diffview/async.lua:358>
stack traceback:
	[C]: in function 'error'
	...cal/share/nvim/lazy/diffview.nvim/lua/diffview/async.lua:369: in function <...cal/share/nvim/lazy/diffview.nvim/lua/diffview/async.lua:358>
stack traceback:
	[C]: in function 'error'
	...cal/share/nvim/lazy/diffview.nvim/lua/diffview/async.lua:187: in function 'raise'
	...cal/share/nvim/lazy/diffview.nvim/lua/diffview/async.lua:307: in function 'await'
	...share/nvim/lazy/diffview.nvim/lua/diffview/vcs/utils.lua:76: in function <...share/nvim/lazy/diffview.nvim/lua/diffview/vcs/utils.lua:75>
	...share/nvim/lazy/diffview.nvim/lua/diffview/vcs/utils.lua:114: in function <...share/nvim/lazy/diffview.nvim/lua/diffview/vcs/utils.lua:69>
	[C]: in function 'xpcall'
	...cal/share/nvim/lazy/diffview.nvim/lua/diffview/async.lua:361: in function <...cal/share/nvim/lazy/diffview.nvim/lua/diffview/async.lua:358>
stack traceback:
	[C]: in function 'error'
	...cal/share/nvim/lazy/diffview.nvim/lua/diffview/async.lua:369: in function <...cal/share/nvim/lazy/diffview.nvim/lua/diffview/async.lua:358>
stack traceback:
	[C]: in function 'error'
	...cal/share/nvim/lazy/diffview.nvim/lua/diffview/async.lua:187: in function 'raise'
	...cal/share/nvim/lazy/diffview.nvim/lua/diffview/async.lua:215: in function 'step'
	...cal/share/nvim/lazy/diffview.nvim/lua/diffview/async.lua:247: in function 'notify_all'
	...cal/share/nvim/lazy/diffview.nvim/lua/diffview/async.lua:213: in function 'step'
	...cal/share/nvim/lazy/diffview.nvim/lua/diffview/async.lua:247: in function 'notify_all'
	...cal/share/nvim/lazy/diffview.nvim/lua/diffview/async.lua:213: in function 'step'
	...cal/share/nvim/lazy/diffview.nvim/lua/diffview/async.lua:247: in function 'notify_all'
	...cal/share/nvim/lazy/diffview.nvim/lua/diffview/async.lua:213: in function 'step'
	...cal/share/nvim/lazy/diffview.nvim/lua/diffview/async.lua:247: in function 'notify_all'
	...cal/share/nvim/lazy/diffview.nvim/lua/diffview/async.lua:213: in function 'step'
	...cal/share/nvim/lazy/diffview.nvim/lua/diffview/async.lua:247: in function 'notify_all'
	...cal/share/nvim/lazy/diffview.nvim/lua/diffview/async.lua:222: in function 'step'
	...cal/share/nvim/lazy/diffview.nvim/lua/diffview/async.lua:399: in function 'callback'
	...local/share/nvim/lazy/diffview.nvim/lua/diffview/job.lua:451: in function 'listener'
	...local/share/nvim/lazy/diffview.nvim/lua/diffview/job.lua:352: in function <...local/share/nvim/lazy/diffview.nvim/lua/diffview/job.lua:308>

Steps to reproduce

  1. nvim --clean -u mini.lua
  2. :DiffViewOpen

Health check

Output of :checkhealth diffview
──────────────────────────────────────────────────────────────────────────────                                                                                 
diffview: require("diffview.health").check()                                                                                                                   
                                                                                                                                                               
Checking plugin dependencies                                                                                                                                   
- OK nvim-web-devicons installed.                                                                                                                              
                                                                                                                                                               
Checking VCS tools                                                                                                                                             
- The plugin requires at least one of the supported VCS tools to be valid.                                                                                     
- OK Git found.                                                                                                                                                
- OK Git is up-to-date. (2.44.0)                                                                                                                               
- WARNING Configured hg_cmd is not executable: 'hg'             

Log info

Relevant info from :DiffviewLog
[INFO  2024-04-23 12:52:39.627 -0400] ...diffview.nvim/plugins/diffview.nvim/lua/diffview/lib.lua:24: [command call] :DiffviewOpen 
[ERROR 2024-04-23 12:52:39.686 -0400] ...diffview.nvim/plugins/diffview.nvim/lua/diffview/job.lua:329: Job exited with a non-zero exit code: 128
[ERROR 2024-04-23 12:52:39.686 -0400] ...ins/diffview.nvim/lua/diffview/vcs/adapters/git/init.lua:173: [job-info] Exit code: 128
[ERROR 2024-04-23 12:52:39.686 -0400] ...ins/diffview.nvim/lua/diffview/vcs/adapters/git/init.lua:173:      [cmd] git 'rev-parse' '--path-format=absolute' '--show-toplevel'
[ERROR 2024-04-23 12:52:39.686 -0400] ...ins/diffview.nvim/lua/diffview/vcs/adapters/git/init.lua:173:      [cwd] /Users/mike/tmp
[ERROR 2024-04-23 12:52:39.686 -0400] ...ins/diffview.nvim/lua/diffview/vcs/adapters/git/init.lua:173:   [stderr] fatal: not a git repository (or any of the parent directories): .git
[ERROR 2024-04-23 12:52:39.687 -0400] ...gins/diffview.nvim/lua/diffview/vcs/adapters/hg/init.lua:53: [HgAdapter] Configured `hg_cmd` is not executable: 'hg'
[ERROR 2024-04-23 12:52:39.687 -0400] ...ffview.nvim/plugins/diffview.nvim/lua/diffview/utils.lua:83: Not a repo (or any parent), or no supported VCS adapter!
[INFO  2024-04-23 12:52:57.622 -0400] ...diffview.nvim/plugins/diffview.nvim/lua/diffview/lib.lua:24: [command call] :DiffviewOpen 
[INFO  2024-04-23 12:54:24.782 -0400] ...diffview.nvim/plugins/diffview.nvim/lua/diffview/lib.lua:24: [command call] :DiffviewOpen 
[ERROR 2024-04-23 12:54:48.702 -0400] ...gins/diffview.nvim/lua/diffview/vcs/adapters/hg/init.lua:53: [HgAdapter] Configured `hg_cmd` is not executable: 'hg'
[INFO  2024-04-23 12:55:22.183 -0400] ...diffview.nvim/plugins/diffview.nvim/lua/diffview/lib.lua:24: [command call] :DiffviewOpen 

Neovim version

NVIM v0.10.0-dev-2992+g052498ed4
Build type: RelWithDebInfo
LuaJIT 2.1.1713484068
Run "nvim -V1 -v" for more info

Operating system and version

Darwin 23.4.0 arm64

Minimal config

-- #######################################
-- ### USAGE: nvim --clean -u mini.lua ###
-- #######################################

local root = vim.fn.stdpath("run") .. "/nvim/diffview.nvim"
vim.fn.mkdir(root, "p")

-- set stdpaths to use root
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", "https://github.com/folke/lazy.nvim.git", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  {
    "sindrets/diffview.nvim",
    dependencies = { "nvim-tree/nvim-web-devicons" },
    config = function()
      require("diffview").setup({
        -- ##############################################################################
        -- ### ADD DIFFVIEW.NVIM CONFIG THAT IS _NECESSARY_ FOR REPRODUCING THE ISSUE ###
        -- ##############################################################################
      })
    end,
  },
  -- ##################################################################
  -- ### ADD PLUGINS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE ###
  -- ##################################################################
}
require("lazy").setup(plugins, { root = root .. "/plugins" })
require("lazy").sync({ show = false, wait = true })

vim.opt.termguicolors = true
vim.cmd("colorscheme " .. (vim.fn.has("nvim-0.8") == 1 and "habamax" or "slate"))

-- ############################################################################
-- ### ADD INIT.LUA SETTINGS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE ###
-- ############################################################################
@mikesmithgh mikesmithgh added the bug Something isn't working label Apr 23, 2024
@mikesmithgh
Copy link
Contributor Author

It works successfully on commit:

NVIM v0.10.0-dev-2982+gea1c9f60e
Build type: RelWithDebInfo
LuaJIT 2.1.1713484068
Run "nvim -V1 -v" for more info

@echasnovski
Copy link

vim.tbl_islist() is soft deprecated on Nightly in favor of vim.islist(). So using something like local islist = vim.fn.has('nvim-0.10') == 1 and vim.islist or vim.tbl_islist in the code base should be enough to fix this.

The reason this happened seems to indeed be because neovim/neovim#28470 introduced the speed optimization to vim.deprecate() by using vim.fn.has() to check version instead of vim.version(). Without it, vim.tbl_islist() is much slower resulting in a very hard to debug performance sink in some plugins.

Although ideally using vim.tbl_islist() should have no side effects on 0.10, the E5560: Vimscript function must not be called in a lua loop callback is currently indeed one of them. Although this potentially can be resolved by taking another optimization route (see this comment), I'd personally suggest moving to vim.islist() right away in this case.

mikesmithgh added a commit to mikesmithgh/diffview.nvim that referenced this issue Apr 24, 2024
mikesmithgh added a commit to mikesmithgh/diffview.nvim that referenced this issue Apr 24, 2024
mikesmithgh added a commit to mikesmithgh/diffview.nvim that referenced this issue Apr 24, 2024
@mikesmithgh
Copy link
Contributor Author

@echasnovski thanks for the info! I've opened the PR #489 to fix this 👍

@mikesmithgh
Copy link
Contributor Author

FYI #489 (comment)

It looks like this error no longer occurs using deprecated functions on nvim nightly.

@echasnovski
Copy link

It looks like this error no longer occurs using deprecated functions on nvim nightly.

Yes, because vim.fn.has() was made compatible with fast events specifically to resolve this kind of issues.

sindrets pushed a commit to mikesmithgh/diffview.nvim that referenced this issue May 18, 2024
sindrets pushed a commit to mikesmithgh/diffview.nvim that referenced this issue May 18, 2024
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.

2 participants