A LuaRocks-aware package loader.
Requiring this module loads a package loader into the environment which is aware of the system's LuaRocks configuration, and can process the manifest file to scan for dependencies, identify multiple copies of installed modules and load the correct version for each dependency.
Lua modules are loaded using the
package.path
and package.cpath
variables, which can be configured using environment variables
such as LUA_PATH_5_4
, LUA_CPATH_5_4
, LUA_PATH
or
LUA_CPATH
.
-
If your operating system (such as a Linux distribution) configured these environment variables for you, and your LuaRocks is also configured to install package to the same locations, you don't need luarocks-loader.
-
If you use the LuaRocks CLI to set up your environment variables, for example with
eval $(luarocks path)
in your.bashrc
file, you don't need luarocks-loader. This is the preferred method if your operating system packages did not configure your paths for you.
If you need to install different modules with conflicting dependency trees, or if you want your script to detect your LuaRocks configuration without requiring environment variables to be set up, then luarocks-loader may be of help.
luarocks install luarocks-loader
require("luarocks.loader")
-- subsequent require calls will be LuaRocks-aware
But wait! If I need luarocks-loader to find my LuaRocks-installed modules, and luarocks-loader is installed with LuaRocks, then how do I get out of this chicken-and-egg situation?
Install luarocks-loader under the same prefix as your Lua installation, so
that Lua's default package.path
is sufficient to find it. You can check your
Lua's package.path
with lua -e 'print(package.path)'
and you can install
luarocks-loader to a specific prefix with luarocks install luarocks-loader --tree=<prefix>
(note that you may need to use sudo
to get the necessary
permissions on Unix.)
MIT License, same as Lua.