From 8851903434314cb8842917c831f42182d582d851 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Thu, 22 Feb 2018 01:22:19 +0100 Subject: [PATCH 1/2] cmake/LuaHelpers.cmake: check_lua_module: display errors This helps to figure out what the problem is, e.g. in my case I have lua51-mpack installed to be used with luajit, but it is broken (missing libmpack). With this patch you get: -- Checking Lua interpreter /usr/bin/luajit /usr/bin/luajit: error loading module 'mpack' from file '/usr/lib/lua/5.1/mpack.so': libmpack.so.0: cannot open shared object file: No such file or directory stack traceback: [C]: at 0x55fcf0166fb0 [C]: in function 'require' (command line):1: in main chunk [C]: at 0x55fcf01188a0 -- [/usr/bin/luajit] The 'mpack' lua package is required for building Neovim -- Checking Lua interpreter /usr/bin/lua5.1 /usr/bin/lua5.1: error loading module 'mpack' from file '/usr/lib/lua/5.1/mpack.so': libmpack.so.0: cannot open shared object file: No such file or directory stack traceback: [C]: ? [C]: in function 'require' (command line):1: in main chunk [C]: ? -- [/usr/bin/lua5.1] The 'mpack' lua package is required for building Neovim -- Checking Lua interpreter /usr/bin/lua5.2 /usr/bin/lua5.2: (command line):1: module 'mpack' not found: no field package.preload['mpack'] no file '/usr/share/lua/5.2/mpack.lua' no file '/usr/share/lua/5.2/mpack/init.lua' no file '/usr/lib/lua/5.2/mpack.lua' no file '/usr/lib/lua/5.2/mpack/init.lua' no file './mpack.lua' no file '/usr/lib/lua/5.2/mpack.so' no file '/usr/lib/lua/5.2/loadall.so' no file './mpack.so' stack traceback: [C]: in function 'require' (command line):1: in main chunk [C]: in ? -- [/usr/bin/lua5.2] The 'mpack' lua package is required for building Neovim -- Checking Lua interpreter /usr/bin/lua /usr/bin/lua: (command line):1: module 'mpack' not found: no field package.preload['mpack'] no file '/usr/share/lua/5.3/mpack.lua' no file '/usr/share/lua/5.3/mpack/init.lua' no file '/usr/lib/lua/5.3/mpack.lua' no file '/usr/lib/lua/5.3/mpack/init.lua' no file './mpack.lua' no file './mpack/init.lua' no file '/usr/lib/lua/5.3/mpack.so' no file '/usr/lib/lua/5.3/loadall.so' no file './mpack.so' stack traceback: [C]: in function 'require' (command line):1: in main chunk [C]: in ? -- [/usr/bin/lua] The 'mpack' lua package is required for building Neovim CMake Error at CMakeLists.txt:459 (message): A suitable Lua interpreter was not found. While this makes it more verbose for the expected error case ("module 'mpack' not found"), the behavior before this patch hides too much. This is the old output: -- Checking Lua interpreter /usr/bin/luajit -- [/usr/bin/luajit] The 'mpack' lua package is required for building Neovim -- Checking Lua interpreter /usr/bin/lua5.1 -- [/usr/bin/lua5.1] The 'mpack' lua package is required for building Neovim -- Checking Lua interpreter /usr/bin/lua5.2 -- [/usr/bin/lua5.2] The 'mpack' lua package is required for building Neovim -- Checking Lua interpreter /usr/bin/lua -- [/usr/bin/lua] The 'mpack' lua package is required for building Neovim CMake Error at CMakeLists.txt:459 (message): A suitable Lua interpreter was not found. This is for when the whole configuration runs (i.e. after `make distclean`), afterwards only one Lua interpreter gets checked only. --- cmake/LuaHelpers.cmake | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cmake/LuaHelpers.cmake b/cmake/LuaHelpers.cmake index 32f7e46a57..a401ff75df 100644 --- a/cmake/LuaHelpers.cmake +++ b/cmake/LuaHelpers.cmake @@ -5,8 +5,7 @@ # Check if a module is available in Lua function(check_lua_module LUA_PRG_PATH MODULE RESULT_VAR) execute_process(COMMAND ${LUA_PRG_PATH} -e "require('${MODULE}')" - RESULT_VARIABLE module_missing - ERROR_QUIET) + RESULT_VARIABLE module_missing) if(module_missing) set(${RESULT_VAR} False PARENT_SCOPE) else() From ef0a07c073665c0868294fcc73b1344aca62b133 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Thu, 22 Feb 2018 01:22:26 +0100 Subject: [PATCH 2/2] cmake/LuaHelpers.cmake: check_lua_module: use 'lua -l' It only shortens the traceback a bit for when a module is not found though, only removing the "(command line):1: in main chunk" (with lua5.2). --- cmake/LuaHelpers.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/LuaHelpers.cmake b/cmake/LuaHelpers.cmake index a401ff75df..3cba47412b 100644 --- a/cmake/LuaHelpers.cmake +++ b/cmake/LuaHelpers.cmake @@ -4,7 +4,7 @@ # Check if a module is available in Lua function(check_lua_module LUA_PRG_PATH MODULE RESULT_VAR) - execute_process(COMMAND ${LUA_PRG_PATH} -e "require('${MODULE}')" + execute_process(COMMAND ${LUA_PRG_PATH} -l "${MODULE}" -e "" RESULT_VARIABLE module_missing) if(module_missing) set(${RESULT_VAR} False PARENT_SCOPE)