且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用 Luarocks 为 Lua5.2 和 5.1 安装库?

更新时间:2023-02-21 09:35:48

根据您对 ~/.luarocks/share/lua/5.2/ 的引用,您似乎正在运行 Unix 系统(Linux 或 Mac).您可以为 Lua 5.1 和 Lua 5.2 安装两次最新版本的 LuaRocks,如下所示:

Based on your reference to ~/.luarocks/share/lua/5.2/, you seem to be running a Unix system (Linux or Mac). You can install the latest version of LuaRocks twice, for both Lua 5.1 and Lua 5.2 like this:

./configure --lua-version=5.1 --versioned-rocks-dir
make build
sudo make install

然后是 5.2:

./configure --lua-version=5.2 --versioned-rocks-dir
make build
sudo make install

这将为您提供 /usr/local/bin/luarocks-5.1/usr/local/bin/luarocks-5.2.如果您在/usr/local/中安装了 Lua 5.1 和 5.2,并且它们中的每一个都将使用自己的 ~/.luarocks/lib/luarocks/rocks-5.x/ 条目作为用户树(和 /usr/local/lib/luarocks/rocks-5.x 用于系统树),并将模块安装到 /usr/share/lua/5.x/的正确位置~/.luarocks/share/lua/5.x/(对于 lib 也是如此).

This will get you /usr/local/bin/luarocks-5.1 and /usr/local/bin/luarocks-5.2. If you installed Lua 5.1 and 5.2 in /usr/local/, and each of them will use its own ~/.luarocks/lib/luarocks/rocks-5.x/ entry for the user tree (and /usr/local/lib/luarocks/rocks-5.x for the system tree), and install modules to the right location at /usr/share/lua/5.x/ and ~/.luarocks/share/lua/5.x/ (and likewise for lib) appropriately.