rnso
rnso

Reputation: 24535

Module installed by Luarocks not found

I am working on Debian Stable Linux. I installed luafilesystem module by command:

luarocks --local install luafilesystem

However, it is not found when any of following is used in lua source files:

require ("lfs")
require ("luafilesystem")

(Although these files run properly when ran from within ZeroBraneStudio IDE).

From a suggestion on the web, I ran following command also:

luarocks --local install luarocks

But it does not help. I checked with luarocks-admin command, which showed:

CONFIGURATION
    Lua version: 5.1
    Configuration files:
        System: /etc/luarocks/config.lua (ok)
        User  : /home/abcd/.luarocks/config-5.1.lua (not found)

    Rocks trees in use: 
        /home/abcd/.luarocks
        /usr/local

Currently, I only have these 2 modules installed:

$ luarocks list

Installed rocks:
----------------

luafilesystem
   1.7.0-2 (installed) - /home/abcd/.luarocks/lib/luarocks/rocks

luarocks
   2.4.3-1 (installed) - /home/abcd/.luarocks/lib/luarocks/rocks

Should I copy /etc/luarocks/config.lua to /home/abcd/.luarocks for this? Thanks for your help.

Upvotes: 13

Views: 7294

Answers (2)

Yago Crispim
Yago Crispim

Reputation: 31

Eval works fine when executing the code from the terminal, but it doesn't work when executing it using the vscode debugger.

To get around this problem, I did the following.

local LUA_PATH = 'my LUA_PATH from "$ luarocks path"'
local LUA_CPATH = 'my LUA_CPATH from "$ luarocks path"'

package.path = package.path .. ';' .. LUA_PATH
package.cpath = package.cpath .. ';' .. LUA_CPATH

With this change, I can run the code using the debugger.

Upvotes: 3

tarleb
tarleb

Reputation: 22544

The LUA_PATH and LUA_CPATH environment variables control the paths searched by lua when looking for packages. These are probably not set correctly. Include the paths used by luarocks in these variables by running

eval "$(luarocks path)"

and you should be all set.

Upvotes: 11

Related Questions