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

Neovim 0.7 crashes with "vim/_init_packages.lua: cannot load incompatible bytecode" #99630

Closed
2 tasks done
madis opened this issue Apr 19, 2022 · 22 comments
Closed
2 tasks done
Labels
bug Reproducible Homebrew/homebrew-core bug outdated PR was locked due to age stale No recent activity

Comments

@madis
Copy link

madis commented Apr 19, 2022

brew gist-logs <formula> link OR brew config AND brew doctor output

## Brew config

HOMEBREW_VERSION: 3.4.7
ORIGIN: https://github.com/Homebrew/brew
HEAD: 09e766f83c8a420cce9e2210c46a24ec3864a094
Last commit: 27 hours ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: 7a35c5eb9f9e81bbfd92654b8b9b7cc810511f05
Core tap last commit: 3 hours ago
Core tap branch: master
HOMEBREW_PREFIX: /home/linuxbrew/.linuxbrew
HOMEBREW_CASK_OPTS: []
HOMEBREW_CORE_GIT_REMOTE: https://github.com/Homebrew/homebrew-core
HOMEBREW_DISPLAY: :1
HOMEBREW_MAKE_JOBS: 8
Homebrew Ruby: 2.6.8 => /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/vendor/portable-ruby/2.6.8/bin/ruby
CPU: octa-core 64-bit skylake
Clang: N/A
Git: 2.25.1 => /bin/git
Curl: 7.68.0 => /bin/curl
Kernel: Linux 5.13.0-37-generic x86_64 GNU/Linux
OS: Ubuntu 20.04.4 LTS (focal)
Host glibc: 2.31
/usr/bin/gcc: 9.4.0
/usr/bin/ruby: N/A
glibc: N/A
gcc@5: N/A
xorg: N/A

Brew doctor

Your system is ready to brew.

Verification

  • I ran brew update and am still able to reproduce my issue.
  • I have resolved all warnings from brew doctor and that did not fix my problem.

What were you trying to do (and why)?

Installing Neovim (both official latest and HEAD) via homebrew on Linux

What happened (include all command output)?

Installation ran normally. When starting Neovim, the following error is printed

$ /home/linuxbrew/.linuxbrew/bin/nvim --clean
vim/_init_packages.lua: cannot load incompatible bytecode
stack traceback:
	[C]: at 0x004f11c0
	[C]: at 0x7f3213850880
E970: Failed to initialize builtin lua modules

What did you expect to happen?

Expected Neovim to start normally (without crashing).

Googled a bit and these threads / commits may be useful (although didn't help in my case)

After installing neovim from https://github.com/neovim/neovim/releases/tag/v0.7.0 nvim-linux64.tar.gz, it started normally. So maybe it's more of a homebrew (/linux) issue?

Step-by-step reproduction instructions (by running brew commands)

  1. brew install neovim
  2. /home/linuxbrew/.linuxbrew/bin/nvim --clean
  • to run it without any extra config, i.e. factory defaults

System:
Terminal: GNOME Terminal 3.36.2 using VTE 0.60.3 +BIDI +GNUTLS +ICU +SYSTEMD
OS: 20.04.4 LTS (Focal Fossa) x86-64
$SHELL: xterm-256color

@clason
Copy link
Contributor

clason commented Apr 19, 2022

This is due to Neovim linking against PUC Lua 5.4 at runtime instead of the recommended LuaJIT (as it does on macOS, so this is purely a linuxbrew issue). In particular, Lua 5.4 is not compatible with 5.1, which Neovim targets, and should never be used.

Can you show the output of brew list?

@clason
Copy link
Contributor

clason commented Apr 19, 2022

@carlocab

@carlocab
Copy link
Member

Odd. @madis what is the output of brew linkage neovim?

@madis
Copy link
Author

madis commented Apr 19, 2022

Odd. @madis what is the output of brew linkage neovim?

Warning: linkage is a developer command, so
Homebrew's developer mode has been automatically turned on.
To turn developer mode off, run brew developer off

System libraries:
  /lib/x86_64-linux-gnu/libc.so.6
  /lib/x86_64-linux-gnu/libm.so.6
  /lib/x86_64-linux-gnu/libpthread.so.0
  /lib/x86_64-linux-gnu/libutil.so.1
Homebrew libraries:
  /home/linuxbrew/.linuxbrew/lib/libtermkey.so.1 (libtermkey)
  /home/linuxbrew/.linuxbrew/lib/libuv.so.1 (libuv)
  /home/linuxbrew/.linuxbrew/lib/libluajit-5.1.so.2 (luajit)
  /home/linuxbrew/.linuxbrew/lib/libluv.so.1 (luv)
  /home/linuxbrew/.linuxbrew/lib/libmsgpackc.so.2 (msgpack)
  /home/linuxbrew/.linuxbrew/lib/libtree-sitter.so.0 (tree-sitter)
  /home/linuxbrew/.linuxbrew/lib/libunibilium.so.4 (unibilium)
Undeclared dependencies with linkage:
  luajit
Dependencies with no linkage:
  libnsl

@clason
Copy link
Contributor

clason commented Apr 19, 2022

Can you try nvim -u NONE --version (which should skip bundled plugins as well)?

Also, what's the LuaJIT version here? Shouldn't Neovim link again against luajit-openresty?

@carlocab
Copy link
Member

This looks like your problem:

Undeclared dependencies with linkage:

  luajit

You've modified your local neovim.rb which seems to have broken your build.

Can you try installing from the bottle?

@madis
Copy link
Author

madis commented Apr 19, 2022

Can you try nvim -u NONE --version (which should skip bundled plugins as well)?

Same result

$ /home/linuxbrew/.linuxbrew/bin/nvim -u NONE --version
vim/_init_packages.lua: cannot load incompatible bytecode
stack traceback:
	[C]: at 0x004f11c0
	[C]: at 0x7fa06be58880
E970: Failed to initialize builtin lua modules

Also, what's the LuaJIT version here? Shouldn't Neovim link again against luajit-openresty?

Unfortunately I don't know how to answer that.

@madis
Copy link
Author

madis commented Apr 19, 2022

This looks like your problem:

Undeclared dependencies with linkage:

  luajit

You've modified your local neovim.rb which seems to have broken your build.

I'm not sure how you deduced that I've modified my local neovim.rb. Maybe it's a side effect of something else. I've never edited the local neovim.rb (brew formula I assume)

Can you try installing from the bottle?
I'm not completely sure if I did it right. Followed the instructions from https://github.com/mapbox/homebrew/blob/master/share/doc/homebrew/Bottles.md#bottle-usage

Ran:

$ brew install --build-bottle neovim
$ brew bottle neovim
$ brew uninstall neovim
$ brew reinstall ./neovim--0.7.0.x86_64_linux.bottle.1.tar.gz

$ /home/linuxbrew/.linuxbrew/bin/nvim
vim/_init_packages.lua: cannot load incompatible bytecode
stack traceback:
	[C]: at 0x004f11c0
	[C]: at 0x7f708bc3a880
E970: Failed to initialize builtin lua modules

@madis
Copy link
Author

madis commented Apr 19, 2022

Someone from neovim/neovim devs posted the following (maybe useful for solving this?)

Cannot reproduce this (at least on macOS). Neovim should not be built against PUC Lua, and certainly not Lua 5.4 (which is incompatible with Lua 5.1, which Neovim targets). Please open an issue at linuxbrew.

(You can try temporarily uninstalling -- or unlinking -- lua and then reinstalling neovim.)

neovim/neovim#18169 (comment)

@gromgit
Copy link
Member

gromgit commented Apr 19, 2022

brew install --build-bottle neovim

This builds a brand-new bottle on your system, which would potentially pick up locally-installed stuff like luajit that aren't linked in a "clean" build. That's almost certainly the root of your problem.

You want to do this instead:

brew install --force-bottle neovim

or better yet:

brew rm neovim
brew autoremove
brew install neovim

then brew linkage neovim should print:

$ brew linkage neovim
System libraries:
  /lib/x86_64-linux-gnu/libc.so.6
  /lib/x86_64-linux-gnu/libm.so.6
  /lib/x86_64-linux-gnu/libpthread.so.0
  /lib/x86_64-linux-gnu/libutil.so.1
Homebrew libraries:
  /home/linuxbrew/.linuxbrew/lib/libtermkey.so.1 (libtermkey)
  /home/linuxbrew/.linuxbrew/lib/libuv.so.1 (libuv)
  /home/linuxbrew/.linuxbrew/opt/luajit-openresty/lib/libluajit-5.1.so.2 (luajit-openresty)
  /home/linuxbrew/.linuxbrew/lib/libluv.so.1 (luv)
  /home/linuxbrew/.linuxbrew/lib/libmsgpackc.so.2 (msgpack)
  /home/linuxbrew/.linuxbrew/lib/libtree-sitter.so.0 (tree-sitter)
  /home/linuxbrew/.linuxbrew/lib/libunibilium.so.4 (unibilium)
Dependencies with no linkage:
  libnsl

@carlocab
Copy link
Member

I'm not sure how you deduced that I've modified my local neovim.rb. Maybe it's a side effect of something else. I've never edited the local neovim.rb (brew formula I assume)

That was my conclusion based on the output of brew linkage. Editing the local formula is the likeliest explanation for the output you're getting.

Ran:


$ brew install --build-bottle neovim

$ brew bottle neovim

$ brew uninstall neovim

$ brew reinstall ./neovim--0.7.0.x86_64_linux.bottle.1.tar.gz



$ /home/linuxbrew/.linuxbrew/bin/nvim

vim/_init_packages.lua: cannot load incompatible bytecode

stack traceback:

	[C]: at 0x004f11c0

	[C]: at 0x7f708bc3a880

E970: Failed to initialize builtin lua modules

No, I don't mean building your own bottle locally. Doing a source build on your machine seems to be what's causing your problem, so building your own bottle won't get around it (as that still involves a source build on your machine). I just meant a plain brew install neovim.

@carlocab
Copy link
Member

One other possibility is that nvim is mistakenly picking up your

/home/linuxbrew/.linuxbrew/lib/libluajit-5.1.so.2

when it should be using

/home/linuxbrew/.linuxbrew/opt/luajit-openresty/lib/libluajit-5.1.so.2

Can you try doing

brew unlink luajit && brew reinstall neovim

?

@carlocab
Copy link
Member

carlocab commented Apr 19, 2022

Yes, I think this is your problem:

linuxbrew@8527cd738e0c:~$ objdump -p $(which nvim) | grep RPATH | sed 's/ RPATH \+//' | tr ':' '\n'
 /home/linuxbrew/.linuxbrew/Cellar/neovim/0.7.0/lib
/home/linuxbrew/.linuxbrew/lib
/home/linuxbrew/.linuxbrew/opt/ncurses/lib
/home/linuxbrew/.linuxbrew/opt/readline/lib
/home/linuxbrew/.linuxbrew/opt/zlib/lib
/home/linuxbrew/.linuxbrew/opt/libxml2/lib
/home/linuxbrew/.linuxbrew/opt/gettext/lib
/home/linuxbrew/.linuxbrew/opt/unibilium/lib
/home/linuxbrew/.linuxbrew/opt/libtermkey/lib
/home/linuxbrew/.linuxbrew/opt/libuv/lib
/home/linuxbrew/.linuxbrew/opt/luajit-openresty/lib
/home/linuxbrew/.linuxbrew/opt/msgpack/lib
/home/linuxbrew/.linuxbrew/opt/tree-sitter/lib
/home/linuxbrew/.linuxbrew/opt/openssl@1.1/lib
/home/linuxbrew/.linuxbrew/opt/bison/lib
/home/linuxbrew/.linuxbrew/opt/krb5/lib
/home/linuxbrew/.linuxbrew/opt/libtirpc/lib
/home/linuxbrew/.linuxbrew/opt/libnsl/lib

Here we see that

/home/linuxbrew/.linuxbrew/lib

comes before

/home/linuxbrew/.linuxbrew/opt/luajit-openresty/lib

in nvim's RPATH, when it should be the other way around.

This needs fixing in brew. In the meantime you can try unlinking luajit to work around the problem. Another hacky workaround is to do

mkdir -p "$(brew --prefix neovim)/lib"
ln -s "$(brew --prefix luajit-openresty)/lib/libluajit-5.1.so.2" "$(brew --prefix neovim)/lib"

if you don't want to do brew unlink luajit.

CC @Homebrew/linux

@cho-m
Copy link
Member

cho-m commented Apr 19, 2022

in nvim's RPATH, when it should be the other way around.

This needs fixing in brew.

We've been seeing similar linkage issues in Homebrew CI for a while (particularly with libpq dependents when postgresql is also installed, though still functional here).

May be indirectly fixed for new users (not sure about existing) if we decide to swap luajit symlinks #99580

@madis
Copy link
Author

madis commented Apr 20, 2022

You want to do this instead:

brew install --force-bottle neovim

Unfortunately same result (crash due to incompatible bytecode)

or better yet:

brew rm neovim
brew autoremove
brew install neovim

Same as above (crash)

brew linkage (after the latter install method) prints the following:

$ brew linkage neovim
System libraries:
  /lib/x86_64-linux-gnu/libc.so.6
  /lib/x86_64-linux-gnu/libm.so.6
  /lib/x86_64-linux-gnu/libpthread.so.0
  /lib/x86_64-linux-gnu/libutil.so.1
Homebrew libraries:
  /home/linuxbrew/.linuxbrew/lib/libtermkey.so.1 (libtermkey)
  /home/linuxbrew/.linuxbrew/lib/libuv.so.1 (libuv)
  /home/linuxbrew/.linuxbrew/lib/libluajit-5.1.so.2 (luajit)
  /home/linuxbrew/.linuxbrew/lib/libluv.so.1 (luv)
  /home/linuxbrew/.linuxbrew/lib/libmsgpackc.so.2 (msgpack)
  /home/linuxbrew/.linuxbrew/lib/libtree-sitter.so.0 (tree-sitter)
  /home/linuxbrew/.linuxbrew/lib/libunibilium.so.4 (unibilium)
Undeclared dependencies with linkage:
  luajit
Dependencies with no linkage:
  libnsl

@madis
Copy link
Author

madis commented Apr 20, 2022

removed earlier text

This needs fixing in brew. In the meantime you can try unlinking luajit to work around the problem. Another hacky workaround is to do

mkdir -p "$(brew --prefix neovim)/lib"
ln -s "$(brew --prefix luajit-openresty)/lib/libluajit-5.1.so.2" "$(brew --prefix neovim)/lib"

☝️ this (the 2 commands) made Neovim (installed via homebrew) start successfully 🥳

Also may be worth mentioning, that downloading the Neovim compiled binary (nvim-linux64.tar.gz in my case) from their Github releases page (https://github.com/neovim/neovim/releases/tag/v0.7.0) works also without issues.

if you don't want to do brew unlink luajit.

CC @Homebrew/linux

@carlocab
Copy link
Member

Also may be worth mentioning, that downloading the Neovim compiled binary (nvim-linux64.tar.gz in my case) from their Github releases page (https://github.com/neovim/neovim/releases/tag/v0.7.0) works also without issues.

This is because the GitHub release is a statically linked executable. It's nice to do to make something portable but generally frowned upon by package managers (primarily for security reasons).

@ghost
Copy link

ghost commented Apr 20, 2022

I have the same problem on arch linux.

@gromgit
Copy link
Member

gromgit commented Apr 20, 2022

Yes, this issue affects all Linux Homebrew users who have both neovim and luajit installed. See #99630 (comment) for a couple of workarounds, as the official solution is being worked on.

@danielnachun
Copy link
Member

The root cause of this problem is probably the ordering of the array here: https://github.com/Homebrew/brew/blob/fa4f239cd6e7b96de54825d779ca2a8ac3ff7ec2/Library/Homebrew/extend/os/linux/extend/ENV/super.rb#L40-L46

  def determine_rpath_paths(formula)
    PATH.new(
      *formula&.lib,
      "#{HOMEBREW_PREFIX}/lib",
      PATH.new(run_time_deps.map { |dep| dep.opt_lib.to_s }).existing,
    )
  end

should probably be changed to

  def determine_rpath_paths(formula)
    PATH.new(
      *formula&.lib,
      PATH.new(run_time_deps.map { |dep| dep.opt_lib.to_s }).existing,
      "#{HOMEBREW_PREFIX}/lib",
    )
  end

This would make sure that the opt directories for the dependencies always pre-empt whatever is in HOMEBREW_PREFIX/lib.

Interestingly I wonder if after we make this change, we should start to audit for linkage through HOMEBREW_PREFIX/lib rather than opt directories. Technically we should only be linking to brewed GCC 5 (soon to be 7) through HOMEBREW_PREFIX/lib, and that is only on platforms whose host GCC is too old. In CI, all brewed dependencies should be linked through their opt directories, not HOMEBREW_PREFIX/lib. I believe that would resolve the other linkage issues @cho-m mentioned with libpq and postgresql and probably others.

@github-actions
Copy link
Contributor

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@github-actions github-actions bot added the stale No recent activity label May 12, 2022
@hardfau1t
Copy link

Just for reference, i was getting the same issue and i was using neovim on aws-arch instsance, turns out by using luajit from community/luajit solved, instead of ec2/luajit

@github-actions github-actions bot added the outdated PR was locked due to age label Jul 16, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Reproducible Homebrew/homebrew-core bug outdated PR was locked due to age stale No recent activity
Projects
None yet
Development

No branches or pull requests

7 participants