From d62622aa2502cf9d100723ad9232fd72b7e75b9b Mon Sep 17 00:00:00 2001 From: mpeterv Date: Sat, 19 Dec 2015 19:30:29 +0300 Subject: Improve error handling in builtin backend Show error message from fs.copy when failed to install a file. Nice for Lua module files, since their existence is not checked beforehand. Also remove extra 'local ok, err' declarations. --- src/luarocks/build/builtin.lua | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/luarocks/build/builtin.lua b/src/luarocks/build/builtin.lua index ffdc9450..afd05954 100644 --- a/src/luarocks/build/builtin.lua +++ b/src/luarocks/build/builtin.lua @@ -174,7 +174,7 @@ function builtin.run(rockspec) --TODO EXEWRAPPER end - local ok = true + local ok, err local built_modules = {} local luadir = path.lua_dir(rockspec.name, rockspec.version) local libdir = path.lib_dir(rockspec.name, rockspec.version) @@ -236,11 +236,10 @@ function builtin.run(rockspec) end table.insert(objects, object) end - if not ok then break end local module_name = name:match("([^.]*)$").."."..util.matchquote(cfg.lib_extension) if moddir ~= "" then module_name = dir.path(moddir, module_name) - local ok, err = fs.make_dir(moddir) + ok, err = fs.make_dir(moddir) if not ok then return nil, err end end built_modules[module_name] = dir.path(libdir, module_name) @@ -252,13 +251,13 @@ function builtin.run(rockspec) end for name, dest in pairs(built_modules) do fs.make_dir(dir.dir_name(dest)) - ok = fs.copy(name, dest) + ok, err = fs.copy(name, dest) if not ok then - return nil, "Failed installing "..name.." in "..dest + return nil, "Failed installing "..name.." in "..dest..": "..err end end if fs.is_dir("lua") then - local ok, err = fs.copy_contents("lua", luadir) + ok, err = fs.copy_contents("lua", luadir) if not ok then return nil, "Failed copying contents of 'lua' directory: "..err end -- cgit v1.2.3-55-g6feb