lunarmodules / luafilesystem

LuaFileSystem is a Lua library developed to complement the set of functions related to file systems offered by the standard Lua distribution.
https://lunarmodules.github.io/luafilesystem/
MIT License
914 stars 292 forks source link

Use of _G is discouraged #127

Open ktalebian opened 5 years ago

ktalebian commented 5 years ago

This library is using a global variable declaration, which is discouraged. I'm using the penlight library which uses this as a dependency, and this is polluting logs with

2019/07/16 13:36:26 [warn] 6089#19728145: *2 [lua] _G write guard:12: writing a global lua variable ('lfs') which may lead to race conditions between concurrent requests, so prefer the use of 'local' variables

More information can be found on https://github.com/openresty/lua-nginx-module/issues/1558

hishamhm commented 5 years ago

Yes, we are aware. But this is kept around for backwards compatibility. A gazillion scripts out there depend on lfs and assume that it sets the global so we can't remove it. When we release LuaFileSystem 2.0 (no ETA at this point), we will remove the global.