Lua Rocks Install

LuaRocks

LuaRocks is the package manager for Lua modules.

安装

$ wget https://luarocks.org/releases/luarocks-3.3.1.tar.gz

$ tar zxvf luarocks-3.3.1.tar.gz

$ cd luarocks-3.3.1

# ./configure -h
$ ./configure --prefix=/usr/local/luarocks --rocks-tree=/usr/local

# $ sudo make bootstrap
$ make
$ sudo make install

# 
$ /usr/local/luarocks/bin/luarocks config
...

# 创建链接
$ ln -s /usr/local/luarocks/bin/luarocks /usr/local/bin/luarocks
$ ln -s /usr/local/luarocks/bin/luarocks-admin /usr/local/bin/luarocks-admin

使用

# 不要在 luarocks-3.3.1 的 编译目录执行以下操作
$ cd ~

$ sudo luarocks install luautf8 

$ luarocks list

Rocks installed for Lua 5.3
---------------------------

luautf8
   0.1.3-1 (installed) - /opt/package/luarocks-3.3.1/./lua_modules/lib/luarocks/rocks-5.3

# 查看信息
$ luarocks show luautf8

# lua-utf8.so
$ ll /usr/local/lib/lua/5.3/

# 尝试 require
$ lua
> lutf8 = require('lua-utf8')

卸载

$ sudo rm -rf /opt/package/luarocks-3.3.1
$ sudo rm -rf /usr/local/luarocks
$ sudo rm -rf /usr/local/bin/luarocks*

Read More