Lua libraries built against lua-5.2 are installed into an incorrect directory. For me, they end up in /usr/lib64/lua, whereas lua5.2 looks for them in /usr/lib64/lua/5.2. (Libraries built against lua-5.1 end up in /usr/lib64/lua/5.1 and are found by lua5.1.) I believe the problem arises from line 111 in lua-5.2.3-r1.ebuild, where a portage-provided lua.pc has the contents of variable V replaced with ${PATCH_PV}, which was only defined locally in src_prepare(). So lua5.2.pc ends up with an empty V, and so "$(pkg-config --variable INSTALL_CMOD lua)" (used by other ebuilds, e.g. lpeg and luaexpat) returns the incorrect /usr/lib64/lua when lua5.2.pc is in use thanks to eselect lua. I did not test a modified ebuild, but libraries manually placed in /usr/lib64/lua/5.2 are successfully found by lua5.2. Reproducible: Always Steps to Reproduce: 1. eselect lua set 5.2 2. emerge -1av lpeg 3. lua -e "require('lpeg')" Actual Results: lua: (command line):1: module 'lpeg' not found: no field package.preload['lpeg'] no file '/usr/share/lua/5.2/lpeg.lua' no file '/usr/share/lua/5.2/lpeg/init.lua' no file '/usr/lib64/lua/5.2/lpeg.lua' no file '/usr/lib64/lua/5.2/lpeg/init.lua' no file './lpeg.lua' no file '/usr/lib64/lua/5.2/lpeg.so' no file '/usr/lib64/lua/5.2/loadall.so' no file './lpeg.so' stack traceback: [C]: in function 'require' (command line):1: in main chunk [C]: in ? Expected Results: lua -e "require('lpeg')" should print nothing, load lpeg successfully
Just to be clear, this does not effect only lpeg. It should effect all of these, because they determine their install directory in the same way: grep -r --include='*.ebuild' /usr/portage/ -e 'INSTALL_CMOD lua'
Confirming the issue. V= in the pkgconfig is empty, which is wrong. According to Tim's investigation the fix should be simple.
Created attachment 397210 [details, diff] patch for lua-5.2.3-r1.ebuild This fixes it. Keywords=+PATCH
Created attachment 397212 [details, diff] patch for lua-5.2.3-r1.ebuild Patch using SLOT instead of PATCH_PV.
Created attachment 397214 [details, diff] patch for lua-5.2.3-r1.ebuild This patch also fixes INSTALL_INC by using a new revision of lua.pc
Created attachment 397216 [details, diff] patch for lua.pc
Created attachment 397224 [details, diff] patch for lua-5.2.3-r1.ebuild
See bug #534150 for a proposal how to build against multiple versions of Lua.
dev-lang/lpeg-1.0.2 correctly installs its files into /usr/share/lua/x.y/ and /usr/lib64/lua/x.y/ , for both 5.2 and 5.3