tt rocks: prefers an interpreter from the luarocks configuration
The luarocks config:
$ cat /etc/luarocks/config-5.1.lua
-- LuaRocks configuration
rocks_trees = {
{ name = "user", root = home .. "/.luarocks" };
{ name = "system", root = "/usr" };
}
variables = {
LUA_DIR = "/usr";
LUA_INCDIR = "/usr/include/lua5.1";
LUA_BINDIR = "/usr/bin";
LUA_VERSION = "5.1";
LUA = "/usr/bin/lua5.1";
}
The installed tarantool (it does not depend on the tarantool version or installation path, just for an example):
$ tarantool --version
Tarantool 2.11.2-0-g1bac2d257
$ whereis tarantool
tarantool: /usr/local/bin/tarantool /usr/local/lib/tarantool
tt rocks configuration output:
$ tt rocks
...
Configuration:
Lua:
Version : 5.1
LUA : /usr/bin/lua5.1 (ok)
LUA_INCDIR : /usr/include/lua5.1 (ok)
LUA_LIBDIR : (ok)
Configuration files:
System : /etc/luarocks/config-5.1.lua (ok)
User : /home/tarantool/src/tt/.rocks/config-5.1.lua (not found)
Rocks trees in use:
/home/tarantool/.luarocks ("user")
/usr ("system")
It may lead to various problems, but I got a problem with the luatest installation:
$ tt rocks install luatest
...
$ .rocks/bin/luatest --version
/usr/bin/lua5.1: ...ocks/share/tarantool/rocks/luatest/scm-1/bin/luatest:3: module 'tarantool' not found:
no field package.preload['tarantool']
no file '/home/ozi/src/tt/.rocks/share/tarantool/tarantool.lua'
no file '/home/ozi/src/tt/.rocks/share/tarantool/tarantool/init.lua'
no file './tarantool.lua'
no file '/usr/share/lua/5.1/tarantool.lua'
no file '/usr/share/lua/5.1/tarantool/init.lua'
no file '/usr/lib/lua/5.1/tarantool.lua'
no file '/usr/lib/lua/5.1/tarantool/init.lua'
no file '/home/ozi/src/tt/.rocks/lib/tarantool/tarantool.so'
no file './tarantool.so'
no file '/usr/lib/lua/5.1/tarantool.so'
no file '/usr/lib/lua/5.1/loadall.so'
stack traceback:
[C]: in function 'require'
...ocks/share/tarantool/rocks/luatest/scm-1/bin/luatest:3: in main chunk
[C]: ?
$ cat .rocks/bin/luatest
#!/bin/sh
LUAROCKS_SYSCONFDIR='/etc/luarocks' exec '/usr/bin/lua5.1' -e 'package.path="/home/ozi/src/tt/.rocks/share/tarantool/?.lua;/home/ozi/src/tt/.rocks/share/tarantool/?/init.lua;"..package.path;package.cpath="/home/ozi/src/tt/.rocks/lib/tarantool/?.so;"..package.cpath;local k,l,_=pcall(require,"luarocks.loader") _=k and l.add_context("luatest","scm-1")' '/home/ozi/src/tt/.rocks/share/tarantool/rocks/luatest/scm-1/bin/luatest' "$@"
The expected behavior could be archived without the luarocks config:
$ sudo rm /etc/luarocks/config-5.1.lua
$ tt rocks
...
Configuration:
Lua:
Version : 5.1
LUA : /usr/local/bin/tarantool (ok)
LUA_INCDIR : /usr/local/include/tarantool (ok)
LUA_LIBDIR : (ok)
Configuration files:
System : /etc/luarocks/config-5.1.lua (not found)
User : /home/tarantool/src/tt/.rocks/config-5.1.lua (not found)
Rocks trees in use:
/home/tarantool/src/tt/.rocks ("user")
/usr/local ("system")
$ rm -rf .rocks/
$ tt rocks install luatest
$ .rocks/bin/luatest --help
Tarantool version is 2.11.2-0-g1bac2d257
...
$ cat .rocks/bin/luatest
#!/bin/sh
LUAROCKS_SYSCONFDIR='/etc/luarocks' exec '/usr/local/bin/tarantool' -e 'package.path="/home/ozi/src/tt/.rocks/share/tarantool/?.lua;/home/ozi/src/tt/.rocks/share/tarantool/?/init.lua;"..package.path;package.cpath="/home/ozi/src/tt/.rocks/lib/tarantool/?.so;"..package.cpath;local k,l,_=pcall(require,"luarocks.loader") _=k and l.add_context("luatest","scm-1")' '/home/ozi/src/tt/.rocks/share/tarantool/rocks/luatest/scm-1/bin/luatest' "$@"
A possible solution is to ignore luarocks configuration files and disable other auto-detect stuff in the luarocks. The tt rocks should use interpreter passed by tt only. It works for me:
https://github.com/tarantool/luarocks/commit/2f506ac1b51e2129f3197969abf4e468ae7d01c7
I would like to work on this issue. Could you please assign it to me? @oleg-jukovec