-
Notifications
You must be signed in to change notification settings - Fork 41
Open
Description
We found a bug when running LuaRocks 3.12.2 using Lua 5.1 via compat53 (see luarocks/luarocks#1831).
They rely on file:write() behavior from Lua >= 5.2 to return the fd if no error occurs:
local fd, err = io.open(path, 'w')
if not fd then return nil, err end
fd, err = f:write(data)
if not fd then return nil, err end
fd:close()
return trueThere is already a patch in this repo, however it's not applied if we use native Lua 5.1 with no LuaJIT:
lua-compat-5.3/compat53/file_mt.lua
Lines 59 to 68 in dfd83b4
| if not is_luajit52 then | |
| local file_write = file_meta.__index.write | |
| file_meta.__index.write = function(self, ...) | |
| local ret, err = file_write(self, ...) | |
| if ret then | |
| return self | |
| end | |
| return ret, err | |
| end | |
| end |
A dirty workarround we found is to just call this function on the metatable, if Lua version is 5.1:
diff --git a/src/compat53/module.lua b/src/compat53/module.lua
index 52b1dd63..b6a69af3 100644
--- a/src/compat53/module.lua
+++ b/src/compat53/module.lua
@@ -824,6 +824,7 @@ if lua_version < "5.3" then
end
return lines_iterator, st
end
+ require'compat53.file_mt'.update_file_meta(debug.getmetatable(io.stdin), false)
end -- not luajit
if is_luajit thenThis only seems to affect module.lua, as init.lua always calls the update function.
Metadata
Metadata
Assignees
Labels
No labels