Skip to content

Commit

Permalink
Detect tarantool as the Lua interpreter
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Totktonada authored and 0x501D committed Sep 14, 2023
1 parent da4d743 commit 1918b15
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/luarocks/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 1918b15

Please sign in to comment.