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

Specify Lua version to install in testing docs #17

Open
clorl opened this issue Aug 9, 2024 · 3 comments
Open

Specify Lua version to install in testing docs #17

clorl opened this issue Aug 9, 2024 · 3 comments

Comments

@clorl
Copy link

clorl commented Aug 9, 2024

Spent a whole lot of time banging my head on why testing errored. This is because you need to install Lua 5.1 system-wide even if in the end you use nlua to make neovim your interpreter. This is because when luarocks installs some rocks, it may compile some of them to shared objects against the lua version you have installed globally on your system. This means that if you have luarocks + lua > 5.1 on your system, buster can't even run.

The error I got was on pl/path.lua where it couldn't require luafilesystem, even though the .so file was present. lfs.so failed because it was using undefined symbols that aren't available in Lua 5.1.

@aaronik
Copy link
Contributor

aaronik commented Aug 10, 2024

I have lua 5.4.6 and get this trying to run the tests with luarocks test --local

E5113: Error while calling lua chunk: ...uarocks/lib/luarocks/rocks-5.4/busted/2.2.0-1/bin/busted:3: module 'busted.runner' not found:
	no field package.preload['busted.runner']
	no file './busted/runner.lua'
	no file '/opt/homebrew/share/luajit-2.1/busted/runner.lua'
	no file '/usr/local/share/lua/5.1/busted/runner.lua'
	no file '/usr/local/share/lua/5.1/busted/runner/init.lua'
	no file '/opt/homebrew/share/lua/5.1/busted/runner.lua'
	no file '/opt/homebrew/share/lua/5.1/busted/runner/init.lua'
	no file './busted/runner.so'
	no file '/usr/local/lib/lua/5.1/busted/runner.so'
	no file '/opt/homebrew/lib/lua/5.1/busted/runner.so'
	no file '/usr/local/lib/lua/5.1/loadall.so'
	no file './busted.so'
	no file '/usr/local/lib/lua/5.1/busted.so'
	no file '/opt/homebrew/lib/lua/5.1/busted.so'
	no file '/usr/local/lib/lua/5.1/loadall.so'
stack traceback:
	[C]: in function 'require'
	...uarocks/lib/luarocks/rocks-5.4/busted/2.2.0-1/bin/busted:3: in function 'fn'
	/Users/aaron/.luarocks/bin/nlua:79: in main chunk

@clorl do you think this is related to the same thing?

@clorl
Copy link
Author

clorl commented Aug 12, 2024

Yes, this is the exact same error. So first busted.runner isn't found because you have to set the LUA_PATH and LUA_CPATH. Add this to your .bashrc, .zshrc or wherever.

eval "$(luarocks path)"

This will automatically set those variables. Ofc you can just run them, but you will have to do it everytime you want to run luarocks test.

Now rerun the test command, you should get a different error.
The next step is to uninstall lua and luarocks and clean all the lua related files. This is because luarocks really badly handles the case where there are multiple lua versions and may still compile shared objects against the wrong one. (Related issue)

Here are example commands for Debian which is what I use, you have to change them to fit your package manager. Here is a simple command to find related lua files.

# This should list lua related files in /usr/share lib and include
# It removes errors
find /usr/{share,lib,include} -name "*lua*" 2>/dev/null

I'd advise against directly piping this into rm, you may have programs who have an embedded lua version, make sure you only delete the ones installed by lua package.
For safety, since you're deleting files as root, I advise you do something like this

sudo -s # Become root
alias rm='rm -i' # Always ask for confirmation
# Then do your thing

Once it's done, install the following packages (names may vary depending on your distro)

  • lua5.1
  • luajit
  • liblua5.1-0
  • luarocks

And now your tests should work fine!

Note: I don't know if manually deleting lua related files is necessary or safe. I'm pretty sure it is, especially the /usr/include file which is the one luarocks shared objects use. Maybe using apt purge to uninstall the packages would have deleted those, I don't know

@aaronik
Copy link
Contributor

aaronik commented Aug 12, 2024

@clorl this is profoundly helpful - I'd given up on getting this to work. Thank you so much!

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

No branches or pull requests

2 participants