From 1918b15dd470a4292838168ef557601c4e5275ca Mon Sep 17 00:00:00 2001 From: Alexander Turenko Date: Sun, 16 Jun 2019 17:04:49 +0300 Subject: [PATCH] Detect tarantool as the Lua interpreter This change eliminates the following warning when tarantool is the only Lua interpreter installed on the system: > Warning: Could not find a Lua interpreter for version 5.1 in your > PATH. Modules may not install with the correct configurations. You may > want to specify to the path prefix to your build of Lua 5.1 using > --lua-dir --- src/luarocks/util.lua | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/luarocks/util.lua b/src/luarocks/util.lua index d044b170b..d061942ca 100644 --- a/src/luarocks/util.lua +++ b/src/luarocks/util.lua @@ -438,7 +438,14 @@ do if not util.exists(lua_exe) then return nil end - local lv, err = util.popen_read(Q(lua_exe) .. ' -e "io.write(_VERSION:sub(5))"') + + local cmd = 'io.write(_VERSION:sub(5))' + -- Tarantool falls into the interactive mode if no script is + -- given even when -e option is passed. + if lua_exe:find('tarantool') then + cmd = cmd .. ' os.exit()' + end + local lv, err = util.popen_read(Q(lua_exe) .. (' -e "%s"'):format(cmd)) if lv == "" then return nil end @@ -457,7 +464,12 @@ do local ljv if cfg.lua_version == "5.1" then - ljv = util.popen_read(Q(cfg.variables["LUA_BINDIR"] .. "/" .. cfg.lua_interpreter) .. ' -e "io.write(tostring(jit and jit.version:gsub([[^%S+ ]], [[]])))"') + local cmd = 'io.write(tostring(jit and jit.version:sub(8)))' + -- Exit from the iteractive mode. See the comment above. + if lua_exe:find('tarantool') then + cmd = cmd .. ' os.exit()' + end + ljv = util.popen_read(Q(lua_exe) .. (' -e "%s"'):format(cmd)) if ljv == "nil" then ljv = nil end @@ -494,6 +506,7 @@ do end if luaver == "5.1" or not luaver then table.insert(names, "luajit" .. exe_suffix) + table.insert(names, "tarantool") end table.insert(names, "lua" .. exe_suffix)