rocks.nvim icon indicating copy to clipboard operation
rocks.nvim copied to clipboard

Installation scripts fails to configure luarocks due to missing `--with-lua-include' flag

Open robin-carlier opened this issue 1 year ago • 4 comments

When trying to install rocks.nvim through the install script, the installer fails to configure luarocks with the following error message:

Configuring LuaRocks version dev...

Lua interpreter found: /bin/lua5.1
Checking if /bin/lua5.1 is Lua version 5.1... yes
lua.h for Lua 5.1 not found (tried //include/lua/5.1/lua.h //include/lua5.1/lua.h //include/lua-5.1/lua.h //include/lua51/lua.h //include/lua.h)

If the development files for Lua (headers and libraries)
are installed in your system, you may need to use the
--with-lua or --with-lua-include flags to specify their location.

If those files are not yet installed, you need to install
them using the appropriate method for your operating system.

Run ./configure --help for details on flags.

configure failed.

A fix is to download the installation script and to modify the configuration command (line 192 of installer.lua) to add the --with-lua-include flag with a path containing the required includes (for instance /usr/include did the trick on Debian testing with the package liblua5.1-0-dev installed).

It would be nice to modify the installation script in a way that allows the user to set this flag through an environment variable instead of having to download, edit and run it locally.

robin-carlier avatar Aug 01 '24 10:08 robin-carlier

Hey :wave:

thanks for reporting. I'll look into this. We've also thought of packaging a pre-built luarocks (perhaps bundled with Lua 5.1).

mrcjkb avatar Aug 02 '24 13:08 mrcjkb

We are shifting our focus to developing rocks and using it instead of luarocks.

  • #539

mrcjkb avatar Sep 18 '24 17:09 mrcjkb

For ones who are still struggling with this issue, setting LUA_DIR and LUA_DIR_SET will fix the issue:

LUA_DIR=/path/where/lua/is/installed
LUA_DIR_SET=yes

For example (when installed via nix):

LUA_DIR=/nix/store/8438aynxm813i6ksassvgq8bb40f8fln-lua-5.1.5-env
LUA_DIR_SET=yes

You can check proper LUA_DIR for your case by running luarocks config.

boltlessengineer avatar Jun 25 '25 16:06 boltlessengineer

For ones who are still struggling with this issue, setting LUA_DIR and LUA_DIR_SET will fix the issue:

LUA_DIR=/path/where/lua/is/installed
LUA_DIR_SET=yes

For example (when installed via nix):

LUA_DIR=/nix/store/8438aynxm813i6ksassvgq8bb40f8fln-lua-5.1.5-env
LUA_DIR_SET=yes

You can check proper LUA_DIR for your case by running luarocks config.

If you come from NixOS, you need these 2 packages: lua and luajitPackages.luarocks

Then as he said, run luarocks config, you'll see the correct path. Just add it to your /nix folder (or wherever you have your config) and that should work.

There might be an easier way to do this but this is the first thing that worked for me

gusvianadev avatar Aug 19 '25 18:08 gusvianadev