> I think remove the `lua` dir is better, this dir is useless. We can continue to use the `lua` directory in the source code. Delete the `lua` directory only when installing apisix via luarocks.
On Sun, Mar 22, 2020 at 10:42 PM Ming Wen <[email protected]> wrote: > I think remove the `lua` dir is better, this dir is useless. > > Thanks, > Ming Wen, Apache APISIX & Apache SkyWalking > Twitter: _WenMing > > > YuanSheng Wang <[email protected]> 于2020年3月22日周日 下午8:51写道: > > > On Thu, Mar 19, 2020 at 11:42 PM Ming Wen <[email protected]> wrote: > > > > > I don't think so, if this is a bug, you should fix it directly instead > of > > > going around > > > > > > > > we can remove the folder `lua` when do install by luarocks. > > > > This is how this bug is fixed. > > > > > > > YuanSheng Wang <[email protected]>于2020年3月19日 周四下午1:00写道: > > > > > > > we can remove the folder `lua` when do install. > > > > > > > > and we can keep the folder `lua` in the source. > > > > > > > > > > > > On Fri, Mar 6, 2020 at 2:58 PM Ming Wen <[email protected]> wrote: > > > > > > > > > Hi, yuansheng: > > > > > I start a ubuntu VM in EC2, fully simulated this bug, and I finally > > > > > understand what you mean. > > > > > > > > > > Let me briefly summarize so that others can better understand the > > > > problem: > > > > > > > > > > 1. luarocks has its own default search path. This path is related > to > > > the > > > > > version of Lua on the machine. > > > > > For example, when lua 5.3 is used, then `/usr/share/lua/5.3/` will > be > > > the > > > > > default search path of luarocks. > > > > > > > > > > 2. The APISIX code path has one more layer of `lua`, which is > > > > `lua/apisix`. > > > > > > > > > > So if we wan to be automatically searched by luarocks: > > > > > `/usr/share/lua/5.3/apisix/init.lua` when `require "apisix.init"`, > > > > > we must keep the code layer is `apisix/*.lua`, not the > > > > `lua/apisix/*.lua`. > > > > > > > > > > Thanks, > > > > > Ming Wen, Apache APISIX > > > > > Twitter: _WenMing > > > > > > > > > > > > > > > Ming Wen <[email protected]> 于2020年3月6日周五 下午1:59写道: > > > > > > > > > > > ok, I see, this PR is WIP > > > > > > > > > > > > Thanks, > > > > > > Ming Wen, Apache APISIX > > > > > > Twitter: _WenMing > > > > > > > > > > > > > > > > > > YuanSheng Wang <[email protected]> 于2020年3月6日周五 下午1:01写道: > > > > > > > > > > > >> On Fri, Mar 6, 2020 at 12:30 PM Ming Wen <[email protected]> > > > wrote: > > > > > >> > > > > > > >> > > I think this PR should have resolved this issue. > > > > > >> > The luarocks install APISIX to `/usr/share/lua/5.3/****`, > which > > is > > > > not > > > > > >> in > > > > > >> > your search paths. > > > > > >> > > > > > >> My goal is to run APISIX without any hard-coded path, that is > why > > I > > > > > >> removed the `lua` folder. > > > > > >> > > > > > >> > > > > > > >> > > All hard-coded paths are likely to be wrong. > > > > > >> > but now hard-coded `Lua 5.1` in your PR. > > > > > >> > > > > > >> I have deleted `/usr/share/lua/5.1 / ?. lua` and we will delete > > more > > > > > >> hard-coded paths later. > > > > > >> > > > > > >> > > > > > > >> > Thanks, > > > > > >> > Ming Wen, Apache APISIX > > > > > >> > Twitter: _WenMing > > > > > >> > > > > > > >> > > > > > > >> > YuanSheng Wang <[email protected]> 于2020年3月6日周五 下午12:00写道: > > > > > >> > > > > > > >> > > On Fri, Mar 6, 2020 at 11:41 AM Ming Wen < > [email protected]> > > > > > wrote: > > > > > >> > > > > > > > > >> > > > back to your first email: > > > > > >> > > > > I found that the luarocks will install the APISIX to > > > > > >> > > > `/usr/share/lua/5.3/****`. > > > > > >> > > > > > > > > >> > > > the new search path[1] can not reslove this issue, right? > > > > > >> > > > > > > > >> > > I think this PR should have resolved this issue. > > > > > >> > > > > > > > >> > > At present we all use Lua 5.1 in CI, so we can't see the bug > > > using > > > > > >> Lua 5.3. > > > > > >> > > We can run test cases in Luarocks 3 + Lua 5.2 or 5.3. > > > > > >> > > > > > > > >> > > All hard-coded paths are likely to be wrong. We should use > > > search > > > > > >> > > paths provided by standard Lua whenever possible. > > > > > >> > > > > > > > >> > > > > > > > >> > > > > > > > > >> > > > [1] > > > > > >> > > > > > > > > >> > > > > > > > >> > > > > > > > > > > > > > > > https://github.com/apache/incubator-apisix/pull/1157/files#diff-400bb4a8f273a5c5afddae64632f0a8b > > > > > >> > > > > > > > > >> > > > Thanks, > > > > > >> > > > Ming Wen, Apache APISIX > > > > > >> > > > Twitter: _WenMing > > > > > >> > > > > > > > > >> > > > > > > > > >> > > > YuanSheng Wang <[email protected]> 于2020年3月6日周五 > 上午11:36写道: > > > > > >> > > > > > > > > >> > > > > On Fri, Mar 6, 2020 at 11:32 AM Ming Wen < > > > [email protected]> > > > > > >> wrote: > > > > > >> > > > > > > > > > > >> > > > > > > So we can see a lot of hard-coded paths, such as: > > > > > >> > > > > > `/usr/share/lua/5.1/apisix/lua / ?. lua`. > > > > > >> > > > > > > If we remove the `lua` directory, then the hack path > > > above > > > > > is > > > > > >> no > > > > > >> > > longer > > > > > >> > > > > > needed. > > > > > >> > > > > > > > > > > >> > > > > > So after this PR, the global Lua's search paths are? > > > > > >> > > > > > > > > > >> > > > > Here [1] is the new Lua search path for test case. > > > > > >> > > > > > > > > > >> > > > > I'll update the `bin/apisix` later. > > > > > >> > > > > > > > > > >> > > > > [1] > > > > > >> > > > > > > > > > >> > > > > > > > >> > > > > > > > > > > > > > > > https://github.com/apache/incubator-apisix/pull/1157/files#diff-400bb4a8f273a5c5afddae64632f0a8b > > > > > >> > > > > > > > > > >> > > > > > > > > > > >> > > > > > Thanks, > > > > > >> > > > > > Ming Wen, Apache APISIX > > > > > >> > > > > > Twitter: _WenMing > > > > > >> > > > > > > > > > > >> > > > > > > > > > > >> > > > > > YuanSheng Wang <[email protected]> 于2020年3月6日周五 > > > 上午11:12写道: > > > > > >> > > > > > > > > > > >> > > > > > > On Fri, Mar 6, 2020 at 11:00 AM Ming Wen < > > > > > [email protected]> > > > > > >> > > wrote: > > > > > >> > > > > > > > > > > > >> > > > > > > > Hi, yuansheng, > > > > > >> > > > > > > > I am afraid not get your point, can you explain > > more? > > > > > >> > > > > > > > > > > > > >> > > > > > > > > > > > >> > > > > > > In the APISIX project, we put all the source code in > > the > > > > > `lua` > > > > > >> > > > > directory > > > > > >> > > > > > > now > > > > > >> > > > > > > . > > > > > >> > > > > > > > > > > > >> > > > > > > In order for OpenResty to load it, we need to add > the > > > > `lua` > > > > > >> > > directory > > > > > >> > > > > to > > > > > >> > > > > > > Lua's global search path. > > > > > >> > > > > > > So we can see a lot of hard-coded paths, such as: > > > > > >> > > > > > > `/usr/share/lua/5.1/apisix/lua / ?. lua`. > > > > > >> > > > > > > > > > > > >> > > > > > > If we remove the `lua` directory, then the hack path > > > above > > > > > is > > > > > >> no > > > > > >> > > longer > > > > > >> > > > > > > needed. > > > > > >> > > > > > > > > > > > >> > > > > > > So this is the PR result you see. > > > > > >> > > > > > > > > > > > >> > > > > > > > > > > > >> > > > > > > > > > > > > >> > > > > > > > I reviewed your PR and there still has the version > > of > > > > > >> Lua[1], > > > > > >> > > > > > > > the most important change is `lua/apisix.lua → > > > > > >> apisix/init.lua`, > > > > > >> > > > > right? > > > > > >> > > > > > > > > > > > > >> > > > > > > > [1] > > > > > >> > > > > > > > > > > > > >> > > > > > > > > > > > > >> > > > > > > > > > > > >> > > > > > > > > > >> > > > > > > > >> > > > > > > > > > > > > > > > https://github.com/apache/incubator-apisix/pull/1157/files#diff-400bb4a8f273a5c5afddae64632f0a8bR60 > > > > > >> > > > > > > > > > > > > >> > > > > > > > Thanks, > > > > > >> > > > > > > > Ming Wen, Apache APISIX > > > > > >> > > > > > > > Twitter: _WenMing > > > > > >> > > > > > > > > > > > > >> > > > > > > > > > > > > >> > > > > > > > YuanSheng Wang <[email protected]> 于2020年2月24日周一 > > > > > >> 下午11:14写道: > > > > > >> > > > > > > > > > > > > >> > > > > > > > > Hi: > > > > > >> > > > > > > > > > > > > > >> > > > > > > > > I am using Luarocks 3 now. > > > > > >> > > > > > > > > > > > > > >> > > > > > > > > I make a try to install Apache APISIX by > Luarocks > > > > `sudo > > > > > >> > > luarocks > > > > > >> > > > > > > install > > > > > >> > > > > > > > > apisix`, and it is successful. > > > > > >> > > > > > > > > > > > > > >> > > > > > > > > I got an error message when I try to run the > > Apache > > > > > APISIX > > > > > >> > > server. > > > > > >> > > > > Here > > > > > >> > > > > > > > is > > > > > >> > > > > > > > > the error message: > > > > > >> > > > > > > > > > > > > > >> > > > > > > > > nginx: [error] init_by_lua error: init_by_lua:3: > > > > module > > > > > >> > > 'apisix' > > > > > >> > > > > not > > > > > >> > > > > > > > found: > > > > > >> > > > > > > > > no field package.preload['apisix'] > > > > > >> > > > > > > > > no file > > > > > >> '/usr/local/apisix//deps/share/lua/5.1/apisix.lua' > > > > > >> > > > > > > > > no file > > '/usr/share/lua/5.1/apisix/lua/apisix.lua' > > > > > >> > > > > > > > > no file > > > > > '/usr/local/share/lua/5.1/apisix/lua/apisix.lua' > > > > > >> > > > > > > > > > > > > > >> > > > > > > > > I found that the luarocks will install the > APISIX > > to > > > > > >> > > > > > > > > `/usr/share/lua/5.3/****`. > > > > > >> > > > > > > > > > > > > > >> > > > > > > > > I think we should rename the folder lua[1] to > > > apisix, > > > > > >> then we > > > > > >> > > do > > > > > >> > > > > not > > > > > >> > > > > > > need > > > > > >> > > > > > > > > to hack for the Lua finding path[2]. > > > > > >> > > > > > > > > > > > > > >> > > > > > > > > > > > > > >> > > > > > > > > [1] > > > > > >> https://github.com/apache/incubator-apisix/tree/master/lua > > > > > >> > > > > > > > > [2] > > > > > >> > > > > > > > > > > > > > >> > > > > > > > > > > > > >> > > > > > > > > > > > >> > > > > > > > > > >> > > > > > > > >> > > > > > > > > > > > > > > > https://github.com/apache/incubator-apisix/blob/master/bin/apisix#L105-L107 > > > > > >> > > > > > > > > > > > > > >> > > > > > > > > > > > > > >> > > > > > > > > -- > > > > > >> > > > > > > > > > > > > > >> > > > > > > > > *MembPhis* > > > > > >> > > > > > > > > My github: https://github.com/membphis > > > > > >> > > > > > > > > Apache APISIX: > > > > > https://github.com/apache/incubator-apisix > > > > > >> > > > > > > > > > > > > > >> > > > > > > > > > > > > >> > > > > > > > > > > > >> > > > > > > > > > > > >> > > > > > > -- > > > > > >> > > > > > > > > > > > >> > > > > > > *MembPhis* > > > > > >> > > > > > > My github: https://github.com/membphis > > > > > >> > > > > > > Apache APISIX: > > > https://github.com/apache/incubator-apisix > > > > > >> > > > > > > > > > > > >> > > > > > > > > > >> > > > > > > > > > >> > > > > > > > > > >> > > > > -- > > > > > >> > > > > > > > > > >> > > > > MembPhis > > > > > >> > > > > My github: https://github.com/membphis > > > > > >> > > > > Apache APISIX: > https://github.com/apache/incubator-apisix > > > > > >> > > > > > > > > > >> > > > > > > > >> > > > > > > > >> > > > > > > > >> > > -- > > > > > >> > > MembPhis > > > > > >> > > My github: https://github.com/membphis > > > > > >> > > Apache APISIX: https://github.com/apache/incubator-apisix > > > > > >> > > > > > > > >> > > > > > >> > > > > > >> > > > > > >> -- > > > > > >> > > > > > >> MembPhis > > > > > >> My github: https://github.com/membphis > > > > > >> Apache APISIX: https://github.com/apache/incubator-apisix > > > > > >> > > > > > > > > > > > > > > > > > > > > > > > -- > > > > *MembPhis* > > > > My github: https://github.com/membphis > > > > Apache APISIX: https://github.com/apache/incubator-apisix > > > > > > > -- > > > Thanks, > > > Ming Wen, Apache APISIX & Apache SkyWalking > > > Twitter: _WenMing > > > > > > > > > -- > > *MembPhis* > > My github: https://github.com/membphis > > Apache APISIX: https://github.com/apache/incubator-apisix > > > -- *MembPhis* My github: https://github.com/membphis Apache APISIX: https://github.com/apache/incubator-apisix
