Open bacTlink opened 8 years ago
Not sure but I think nginx create its own environment to each request. and do not set any variables to _G.
So require
does not defined in _G
and xlsxwriter.strict
complain about it.
Solution just do not use any global variables in code or turn off strict.
Both ways require small source change.
P.S. xlsxwriter require ZipWriter module which require some libraries which it not install automatically
Solution just do not use any global variables in code or turn off strict.
@moteus There shouldn't be any global variables in the code. That is why the strict is there in the first place.
@bacTlink Can you remove the require "xlsxwriter.strict"
line from all the xlsxwriter/*.lua files and see if that makes OpenResty happy?
If so, is there a way to if()
it out when running under OpenResty or some other way of using it that is compatible with OpenResty.
Anyway, let me know and I'll push a fix.
P.S. xlsxwriter require ZipWriter module which require some libraries which it not install automatically
@moteus The OP had already installed the dependencies via luarocks but ran into issue #13 and couldn't install xlsxwriter.lua.
Thanks for the feedback from everyone.
@moteus There shouldn't be any global variables in the code. That is why the strict is there in the first place.
But they are exists :).
require
- https://github.com/jmcnamara/xlsxwriter.lua/blob/master/xlsxwriter/workbook.lua#L8
setmetatable
- https://github.com/jmcnamara/xlsxwriter.lua/blob/master/xlsxwriter/workbook.lua#L23
assert
- https://github.com/jmcnamara/xlsxwriter.lua/blob/master/xlsxwriter/workbook.lua#L27
@moteus The OP had already installed the dependencies via luarocks but ran into issue #13 and couldn't install xlsxwriter.lua.
Problem that luarocks does not install all deps for ZipWriter.
There no way specify that this deps needs e.g. only for Lua 5.1 or for Lua <5.3.
Also there exists 2 zlib binding wich provide same binary name zlib.so
/zlib.dll
So to load any of them need call require "zlib"
. So if system already
has insalled e.g. lua-zlib
and I install lzlib
then existed code may stop working.
So ZipWriter did not install any deps and user have to install them by hand. It sad but
I do not see any other way.
@jmcnamara Can you remove the require "xlsxwriter.strict" line from all the xlsxwriter/*.lua files and see if that makes OpenResty happy?
I remove it and OpenResty seems returning the correct result.
@jmcnamara If so, is there a way to if() it out when running under OpenResty or some other way of using it that is compatible with OpenResty.
I don't know any way to do this. Can Lua check whether a module is loaded? In OpenResty "ngx" is always loaded.
I use the following command to install xlsxwriter:
It installed successfully, but when I tried to use it, nginx report failure.
I find this in the /nginx/error.log:
It seems something wrong with /workbook.lua. I wonder how to fix it.
Thanks in advance.