Search code examples
lualuarocksluafilesystem

Trouble installing luasocket/lfs using luarocks


I installed luarocks and now I am trying to use it to install luasocket.

My command is

luarocks install luasocket-2.0.2-3.win32-x86.rock

and the response I get is

C:\Program Files (x86)\LuaRocks\lua\luarocks\command_line.lua:186: bad argument #1 to 'require' (string expected, got table)

The line of code in command_line.lua giving trouble is

if commands[command] then
    local cmd = require(commands[command])

and putting trace writes in the code reveals that commands[command] is indeed a table, of length zero.

This sort of fundamental runtime error is way beyond anything a Lua novice can be expected to fix. Any suggestions?

Edit

Turns out it's not just luasocket. I get the same problem with

luarocks install luafilesystem

Solution

  • Turns out that this is caused by having an old LuaRocks 2.0.10 installation that I wasn't aware of. It was put there by a failed attempt to install LuaDist-Batteries.

    Solution here: https://github.com/luarocks/luarocks/issues/714 .