sailorproject / sailor

A Lua MVC Web Framework.
MIT License
921 stars 125 forks source link

Fix "attempt to call global 'FUNCTION'" #174

Closed jperon closed 5 years ago

jperon commented 5 years ago

On my installation with lua 5.1, I get attempt to call global 'require' (or 'pairs' and so on) without thix fix.

coveralls commented 5 years ago

Coverage Status

Coverage decreased (-0.01%) to 82.306% when pulling df9190783b6c3be1aa334d9b7d1f0d6e00324d3b on jperon:patch-4 into f4a14b901b5245766dba81a560701042c10d20ad on sailorproject:master.

jperon commented 5 years ago

The problem is I only have this bug when running sailor with Nginx on a docker image ; I can't reproduce it "directly" on my computer with Xavante. If you want to investigate on it, I have created an automated build on Docker Hub, so you just have to run :

docker run --name sailor --rm -v /PATH/TO/APP:/app -p PORT:80 jperon/sailor

To test my changes on Sailor itself, I add some flags so that my Sailor folder is linked to the container :

docker run --name sailor --rm -v /PATH/TO/APP:/app -v /PATH/TO/SAILOR/src/sailor:/usr/local/share/lua/5.1/sailor -v /PATH/TO/SAILOR/src/sailor.lua:/usr/local/share/lua/5.1/sailor.lua -v /PATH/TO/SAILOR/src/web_utils:/usr/local/share/lua/5.1/web_utils -p 8081:80 jperon/sailor

The bug appears on any page that contains lua code (server-side), for example :

<?lua
local tx = require "pl.tablex"
?>
Etiene commented 5 years ago

I don't have time to investigate this now. But since the current tests are passing without problems, I will merge it! Thanks for the fix!