Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(*) improve Lua paths for dev environments (Kong#2845)
Historically, and so far, with success, the Lua path was always setup so that when in the `kong/` repository, the local files take precedence over any system-wide installation of code. This includes all Lua files in this repository, in the following environments: - The Kong CLI - Running Kong instances - Running tests suites Prior to this, we were having several issues with some disparities in the Lua path setups. Disparities that became more apparent after some recent changes, possibly related to the Homebrew Formula updates made with the prefix and the LuaRocks system tree. We here attempt to unify the various places in which we specify the Lua path values for each of the aforementioned environments. Following this change, our Lua path should look like so in all environments: # inserted by bin/kong in CLI and lua_package_path in configuration # used for development ./?.lua; ./?/init.lua; # inserted by OpenResty (lua-resty-core in lualib + unused site) /usr/local/Cellar/openresty/1.11.2.4/site/lualib/?.lua; /usr/local/Cellar/openresty/1.11.2.4/site/lualib/?/init.lua; /usr/local/Cellar/openresty/1.11.2.4/lualib/?.lua; /usr/local/Cellar/openresty/1.11.2.4/lualib/?/init.lua; # inserted by LuaRocks (user tree) /Users/chasum/.luarocks/share/lua/5.1/?.lua; /Users/chasum/.luarocks/share/lua/5.1/?/init.lua; # inserted by LuaRocks (system tree used by Homebrew) /usr/local/opt/kong/share/lua/5.1/?.lua; /usr/local/opt/kong/share/lua/5.1/?/init.lua; # Inserted by LuaRocks (luarocks rocks is installed there) /usr/local/Cellar/luarocks/2.4.2/share/lua/5.1/?.lua; # A default path from the VM ./?.lua; # LuaJIT introspection lib /usr/local/Cellar/openresty/1.11.2.4/luajit/share/luajit-2.1.0-beta2/?.lua; # Another default path from the VM I think /usr/local/share/lua/5.1/?.lua; /usr/local/share/lua/5.1/?/init.lua; # Yet another default path from the VM (I think) # <INSTALL_PREFIX>/share/lua/<VERSION> /usr/local/Cellar/openresty/1.11.2.4/luajit/share/lua/5.1/?.lua; /usr/local/Cellar/openresty/1.11.2.4/luajit/share/lua/5.1/?/init.lua; Note: to avoid having to keep using the `kong/?.lua` value which was only being used to load the main `kong.lua` module, we had two possible approaches: either change all of the `require "kong"` statements, which would be breaking because have to update the Nginx template, either finally make the main module adhere to our `init.lua` convention, already followed across the codebase.
- Loading branch information