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

PackerInstall causing Neovim to crash #496

Closed
mhanberg opened this issue Jul 20, 2021 · 18 comments
Closed

PackerInstall causing Neovim to crash #496

mhanberg opened this issue Jul 20, 2021 · 18 comments
Labels

Comments

@mhanberg
Copy link

- `nvim --version`:
NVIM v0.6.0-dev
Build type: Release
LuaJIT 2.1.0-beta3
Compilation: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -O2 -DNDEBUG -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/Users/mitchell/.asdf/downloads/neovim/ref-master/build/config -I/Users/mitchell/.asdf/downloads/neovim/ref-master/src -I/Users/mitchell/.asdf/downloads/neovim/ref-master/.deps/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/usr/include -I/opt/homebrew/opt/gettext/include -I/Users/mitchell/.asdf/downloads/neovim/ref-master/build/src/nvim/auto -I/Users/mitchell/.asdf/downloads/neovim/ref-master/build/include
Compiled by [email protected]

Features: +acl +iconv +tui
See ":help feature-compile"

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

Run :checkhealth for more info

  • git --version: git version 2.32.0
  • Operating system/version: macOS 11.4 (M1 MacBook Air)
  • Terminal name/version: Alacritty 0.8.0, tmux 3.2a

Steps to reproduce

  • Run :PackerInstall

Actual behaviour

  • Crashses nvim

Expected behaviour

  • Installs plugins

packer files

Plugin specification file(s)

local install_path = vim.fn.stdpath("data") .. "/site/pack/packer/opt/packer.nvim"

if vim.fn.empty(vim.fn.glob(install_path)) > 0 then
vim.cmd("!git clone https://github.com/wbthomason/packer.nvim " .. install_path)
end

vim.cmd [[packadd packer.nvim]]

local startup = require("packer").startup

startup(
function(use, use_rocks)
use {"wbthomason/packer.nvim", opt = true}
use "tjdevries/nlua.nvim"
use "norcalli/nvim.lua"
use "tpope/vim-repeat"
use "bakpakin/fennel.vim"
use "sainnhe/vim-color-forest-night"
use "christoomey/vim-tmux-runner"
use {"rrethy/vim-hexokinase", run = "make hexokinase"}
use "alvan/vim-closetag"
use "junegunn/goyo.vim"
use "AndrewRadev/splitjoin.vim"
use "tpope/vim-vinegar"
use "tpope/vim-commentary"
use "tpope/vim-dispatch"
use "vim-ruby/vim-ruby"
use "tpope/vim-rsi"
use "elixir-editors/vim-elixir"
-- use "tpope/vim-endwise"
use "tpope/vim-fugitive"
use "junegunn/gv.vim"
use "airblade/vim-gitgutter"
use "tpope/vim-rails"
use "tpope/vim-sensible"
use "vim-test/vim-test"
use "christoomey/vim-tmux-navigator"
use "tpope/vim-liquid"
use "pangloss/vim-javascript"
use "isRuslan/vim-es6"
-- use "mxw/vim-jsx"
-- use "jiangmiao/auto-pairs"
use "tpope/vim-surround"
use "tpope/vim-eunuch"
use "tpope/vim-projectionist"
use "avakhov/vim-yaml"
use "chr4/nginx.vim"
use "mattn/emmet-vim"
use "tpope/vim-markdown"
use "matze/vim-move"
-- use "Yggdroot/indentLine"
use {"lukas-reineke/indent-blankline.nvim"}
use {
"junegunn/fzf",
run = function()
vim.fn"fzf#install"
end
}
use "junegunn/fzf.vim"
use "farmergreg/vim-lastplace"
use {"mg979/vim-visual-multi", branch = "master"}
use "ekalinin/Dockerfile.vim"
use "kana/vim-textobj-user"
use "amiralies/vim-textobj-elixir"
use "stsewd/fzf-checkout.vim"
use "reedes/vim-wordy"

use "neovim/nvim-lspconfig"
use "hrsh7th/nvim-compe"
use "hrsh7th/vim-vsnip"
use "hrsh7th/vim-vsnip-integ"

use "kabouzeid/nvim-lspinstall"

use "nvim-lua/popup.nvim"
use "nvim-lua/plenary.nvim"
use "nvim-lua/telescope.nvim"
use "APZelos/blamer.nvim"
use "hashivim/vim-terraform"
use "pwntester/octo.nvim"
-- use {
--   "ojroques/nvim-lspfuzzy",
--   requires = {
--     {"junegunn/fzf"},
--     {"junegunn/fzf.vim"} -- to enable preview (optional)
--   }
-- }
use {
  "glacambre/firenvim",
  run = function()
    vim.fn["firenvim#install"](0)
  end
}

use "powerman/vim-plugin-AnsiEsc"
use {
  "nvim-treesitter/nvim-treesitter",
  run = function()
    vim.cmd [[TSUpdate]]
  end
}

use "voldikss/vim-floaterm"
use "kassio/neoterm"

use {
  "npxbr/glow.nvim",
  run = function()
    vim.cmd [[GlowInstall]]
  end
}

use "glepnir/lspsaga.nvim"
use "rktjmp/lush.nvim"

use "mjlbach/neovim-ui"

-- use "~/Development/thicc-forest"

use {"ojroques/nvim-hardline"}

use {"tjdevries/astronauta.nvim"}
use {
  "megalithic/zk.nvim",
  requires = {{"vijaymarupudi/nvim-fzf"}}
}

use {"Olical/conjure"}
use {"wlangstroth/vim-racket"}
use {
  "jpalardy/vim-slime",
  run = function()
    vim.cmd [[let g:slime_target = "neovim"]]
  end
}

use_rocks {"underscore"}

end
)

require("packer.luarocks").setup_paths()

_ = require("underscore")

packer log file

[DEBUG Mon Jul 19 23:45:15 2021 8.1090564144396e+14] .../pack/packer/opt/packer.nvim/lua/packer/plugin_utils.lua:176: Updating FS state
[DEBUG Mon Jul 19 23:45:37 2021 8.1092691669521e+14] ...are/nvim/site/pack/packer/opt/packer.nvim/lua/packer.lua:361: packer.install: requiring modules
[DEBUG Mon Jul 19 23:45:37 2021 8.1092692060854e+14] ...are/nvim/site/pack/packer/opt/packer.nvim/lua/packer.lua:308: Processing plugin specs
[DEBUG Mon Jul 19 23:45:37 2021 8.1092693084992e+14] .../pack/packer/opt/packer.nvim/lua/packer/plugin_utils.lua:176: Updating FS state
[DEBUG Mon Jul 19 23:46:16 2021 8.1096661268867e+14] ...are/nvim/site/pack/packer/opt/packer.nvim/lua/packer.lua:361: packer.install: requiring modules
[DEBUG Mon Jul 19 23:46:16 2021 8.1096661706792e+14] ...are/nvim/site/pack/packer/opt/packer.nvim/lua/packer.lua:308: Processing plugin specs
[DEBUG Mon Jul 19 23:46:16 2021 8.1096662748558e+14] .../pack/packer/opt/packer.nvim/lua/packer/plugin_utils.lua:176: Updating FS state
[DEBUG Mon Jul 19 23:56:48 2021 8.1159809896225e+14] ...are/nvim/site/pack/packer/opt/packer.nvim/lua/packer.lua:361: packer.install: requiring modules
[DEBUG Mon Jul 19 23:56:48 2021 8.1159810271333e+14] ...are/nvim/site/pack/packer/opt/packer.nvim/lua/packer.lua:308: Processing plugin specs
[DEBUG Mon Jul 19 23:56:48 2021 8.1159811022954e+14] .../pack/packer/opt/packer.nvim/lua/packer/plugin_utils.lua:176: Updating FS state

packer compiled file I don't think it got this far to compile one ¯\_(ツ)_/¯
Screen.Recording.2021-07-19.at.11.46.07.PM.mov
@mhanberg mhanberg added the bug label Jul 20, 2021
@akinsho
Copy link
Collaborator

akinsho commented Jul 20, 2021

@mhanberg that seems like a nasty issue. I think if nvim is crashing that almost certainly means theres also an upstream neovim issue since even if packer is misbehaving neovim ought not to crash. Regarding this issue I tried running PackerInstall and don't see any issues. I think it's likely related to your specific setup somehow.

Could you try whittling down the config file you provided to just the minimal amount of things required to trigger this error so we can verify it isn't related to a plugin.

Also could you try this with 0.5 stable, just to see if there's been a change introduced on nightly nvim that might account for this.

@mhanberg
Copy link
Author

@akinsho looks like it works on the stable branch (without editing my config).

I tried it again on master with only this as my config

local install_path = vim.fn.stdpath("data") .. "/site/pack/packer/opt/packer.nvim"

if vim.fn.empty(vim.fn.glob(install_path)) > 0 then
  vim.cmd("!git clone https://github.com/wbthomason/packer.nvim " .. install_path)
end

vim.cmd [[packadd packer.nvim]]

local startup = require("packer").startup

startup(
  function(use, use_rocks)
    use "tjdevries/nlua.nvim"
  end
)

and it still crashed.

@Thermatix
Copy link

Based on the error from the video above, it looks similar to an issue I kept having (I'm not sure if it is the same issue). What I think is happening is, Packer accepts the use config but because it's not yet installed thus it doesn't exist therefore when you try to load the plugin, CRASH.

I'm not sure how it would do this but perhaps packer could create a tmp mock that only returns a setup function that does nothing else until the actual plugin can be installed?

I created some global functions that allows you to ignore errors caused by not yet installed plugins (it will still message about it, just not crash out) because I was getting annoyed that one exception would stop the rest of my config from loading

function _G.config_error (err)
    print("Backtrace:", debug.traceback(err))
end

function _G.load_config (config) 
    local _, required = xpcall(require, config_error, config)
    return required
end

function _G.setup_config (setup_module, config)
    local setup = load_config(setup_module).setup
    if type(setup) == 'function' then 
        return setup(config)
    else
        print("No setup function for:", setup_module)
    end
end

Then you would use it like this:

    -- inside of packers setup function
    use {
        'nvim-treesitter/nvim-treesitter',
        requires = 'RRethy/nvim-treesitter-textsubjects',
        run = ':TSUpdate',
        config = function () load_config('plugins.language.tree_sitter') end,
    }

-- inside of `plugins/language/tree_sitter.lua`
return load_config('nvim-treesitter.configs', {
  -- config  tree_sitter like normal
}

The advantage is that exceptions(plugin file not found, mistake in config file, etc) won't halt the loading of the plugin or config ensuring that all your (working config) still loads but that you still get messages about exceptions for you to fix.

@akinsho
Copy link
Collaborator

akinsho commented Jul 21, 2021

Sorry haven't had time to get back to this or look into it, also not going to have much time soon tbh. It seems to me that since the bug is reproducible by switching versions it is most likely related to a change in nvim, might still mean a fix is required on this side due to some api change in 0.6-dev but still don't think whatever packer is doing should be crashing nvim and that that is an upstream issue.

@wbthomason
Copy link
Owner

Given you're on a M1 Mac, I'm wondering if this is somehow a Luarocks issue?

@pjantrania
Copy link

I am running into this issue on an intel mac (, under both nightly and stable neovim. This is my first time setting up packer, so it very well could be my mistake, but wanted to provide another example in case it helps isolate anything. I've also attached the osx crash log in case that adds anything!
nvim_2021-07-31-011327_purnam-mbp.crash.txt

nvim --version

NVIM v0.5.0
Build type: Debug
LuaJIT 2.1.0-beta3
Compilation: /Library/Developer/CommandLineTools/usr/bin/cc -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=1 -I/Users/purnam/code/neovim/build/config -I/Users/purnam/code/neovim/src -I/Users/purnam/code/neovim/.deps/usr/include -I/opt/local/include -I/Users/purnam/code/neovim/build/src/nvim/auto -I/Users/purnam/code/neovim/build/include
Compiled by purnam@purnam-mbp

Features: +acl +iconv +tui
See ":help feature-compile"

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

Run :checkhealth for more info

packer_init.lua

local execute = vim.api.nvim_command
local fn = vim.fn
local install_path = fn.stdpath('data')..'/site/pack/packer/start/packer.nvim'

if fn.empty(fn.glob(install_path)) > 0 then
  execute('!git clone https://github.com/wbthomason/packer.nvim.git '..install_path)
  execute 'packadd packer.nvim'
end

Packer = require'packer'

return Packer

plugins.lua

Packer = require'packer_init'

Packer.startup(function()

    local use = Packer.use

    use { 'wbthomason/packer.nvim' }
    use 'nvim-lua/plenary.nvim'
    use 'folke/lua-dev.nvim'
    use {'nvim-treesitter/nvim-treesitter', run = ':TSUpdate'}
  end
)

@wbthomason
Copy link
Owner

Hi @pjantrania! Thanks for the report - it looks like Neovim is crashing in the middle of a libuv spawn call, which could implicate libuv, git, or maybe the command TSUpdate runs.

Would you mind

  1. Trying without the run key for treesitter, and, if you still see crashes
  2. Setting log = {level = 'debug'} in your config, running again, and sharing your packer log file (at ~/.cache/nvim/packer.nvim.log by default)

Thanks, and sorry for the hassle.

@clason
Copy link

clason commented Jul 31, 2021

I suspect you have luv installed via homebrew, which neovim's build scripts picks up (although they shouldn't -- any cmake expert's help appreciated!) but is an incompatible version.

Try brew remove luv and then make distclean and make CMAKE_BUILD_TYPE=Release (note that you have a Debug build, which you almost never want).

@wbthomason
Copy link
Owner

If @clason is right, we should add a notice of this to the README.

@pjantrania
Copy link

whoa--following @clason's steps, :PackerInstall succeeds now (without changing the TreeSitter configuration). thanks Wil and Christian for your help!

@wbthomason
Copy link
Owner

Great, glad things are working now! Thanks for the macOS assist, @clason! I'll add a note about this to the README.

@wbthomason
Copy link
Owner

@mhanberg: I suspect this may have been the issue for you too, and your dependency got fixed when you went from nightly -> stable. As such, I'm going to close this issue, but feel free to reopen if you don't think it's solved.

rsurasin added a commit to rsurasin/configurations that referenced this issue Nov 12, 2021
…r conflict with brew installation of Neovim: wbthomason/packer.nvim#496. Added Neovim dependencies to Brewfile.
@gennaro-tedesco
Copy link

Apologies to comment on a closed issue: is my understanding correct then that currently in order to use packer on Mac one must necessarily build Neovim from source (to avoid the luv dependencies)?

@clason
Copy link

clason commented Oct 11, 2022

No, that is not correct.

@gennaro-tedesco
Copy link

What is then the recommendation to avoid the luv dependency (which does explicitly re-install even if removed). I see your initial suggestion that does indeed specify to build manually, or am I wrong?

@clason
Copy link

clason commented Oct 11, 2022

You cannot avoid the luv dependency; it is necessary for building Neovim (it won't work without).

My comment was about a very specific situation:

  1. you build Neovim from source on macOS
  2. you have luv installed via homebrew

None of which seem to apply to you. Are you observing an actual problem, or is this just idle speculation?

@gennaro-tedesco
Copy link

gennaro-tedesco commented Oct 11, 2022

I am trying to set-up packer on a macOS but, even using the reproducible examples both in this thread and in the documentation (README), I am getting the error :not an editor command: PackerSync/Install/Update. Checking all the paths I see that packer is correctly installed in the specified location: I followed the bootstrapping example too (to just have a minimal configuration to reproduce) but I cannot find out why packer commands seem not to be recognised.

As such, I thought the only option left would be that somehow the installation on macOS is faulty (as mentioned in the README).

  1. you have luv installed via homebrew

I notice that installing nvim via homebrew does explicitly pour luv too (so wouldn't that count?).

@clason
Copy link

clason commented Oct 11, 2022

I notice that installing nvim via homebrew does explicitly pour luv too (so wouldn't that count?).

No, because homebrew's Neovim is set up to use homebrew's luv (as opposed to the build from source, which isn't).

Your issue is unrelated to this thread. (Make sure you're not lazy-loading packer, and that you restart Neovim after every change to the config.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants