threefoldtecharchive / jumpscaleX_archived

Apache License 2.0
1 stars 6 forks source link

Lua builder: luarocks installed packages cannot be loaded #683

Open abom opened 5 years ago

abom commented 5 years ago

Installing packages using luarocks install <name> or even using j.builders.lua.lua_rock_install("<name>") doesn't work properly.

Example

3BOTDEVEL:3bot:~: luarocks install luacheck
Installing https://luarocks.org/luacheck-0.23.0-1.src.rock
Missing dependencies for luacheck 0.23.0-1:
   argparse >= 0.6.0 (not installed)

luacheck 0.23.0-1 depends on argparse >= 0.6.0 (not installed)
Installing https://luarocks.org/argparse-0.6.0-1.src.rock

argparse 0.6.0-1 is now installed in /tmp/builders/lua/luarocks/lua_modules (license: MIT)

luacheck 0.23.0-1 is now installed in /tmp/builders/lua/luarocks/lua_modules (license: MIT)

The package is installed into /tmp/builders/lua..., this needs to be changed.

Trying to access the installed binary or library, but it doesn't work, because the binary and library are installed to a directory that is not set in LUA_PATH/LUA_CPATH and related paths, so lua can find them (and binaries can be executed directly from the shell).

3BOTDEVEL:3bot:~: luacheck
-bash: luacheck: command not found
3BOTDEVEL:3bot:~: lua
LuaJIT 2.1.0-beta3 -- Copyright (C) 2005-2017 Mike Pall. http://luajit.org/
JIT: ON SSE2 SSE3 SSE4.1 BMI2 fold cse dce fwd dse narrow loop abc sink fuse
> require 'luacheck/config'
stdin:1: module 'luacheck/config' not found:
        no field package.preload['luacheck/config']
        no file 'luacheck/config.lua'
        no file '/sandbox/openresty/lualib/luacheck/config/init.lua'
        no file '/sandbox/openresty/lualib/luacheck/config.lua'
        no file '/sandbox/openresty/lualib/luacheck/config/luacheck/config.lua'
        no file '/sandbox/openresty/lualib/luacheck/config/core.lua'
        no file '/sandbox/openresty/lapis/luacheck/config.lua'
        no file '/sandbox/openresty/lualib/luacheck/config.so'
        no file './luacheck/config.so'
stack traceback:
        [C]: in function 'require'
        stdin:1: in main chunk
        [C]: at 0x55ef86fc2310

In the builder, lua_rocks_instal() do rsync -vaf.... to copy luarocks modules to correct destination set in PATH., but this is not the right solution.

See how to customize luarocks tree and how lua searches for modules.

Dinaamagdy commented 5 years ago

verified on development_builders

abom commented 5 years ago

The PR is still another branch (not tested yet) and the main problem is stated in this issue, not #665.

Dinaamagdy commented 5 years ago

tried on development_jumpscale and install itself doesn't work with the follwoing error :

lua build bydreb hnak asln 
Wed 24 14:12:24 JSBase.py        - 103 - buildertools                       : ***CLASS INIT 1: buildertools
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/sandbox/lib/jumpscale/Jumpscale/builders/builder/system/BuilderBaseClass.py", line 168, in wrapper_action
    res = self.apply_method(func, kwargs)
  File "/sandbox/lib/jumpscale/Jumpscale/builders/builder/system/BuilderBaseClass.py", line 93, in apply_method
    return func(**kwargs)
  File "/sandbox/lib/jumpscale/Jumpscale/builders/builder/runtimes/BuilderLua.py", line 29, in build
    j.builders.web.openresty.build(reset=deps_reset)
  File "/sandbox/lib/jumpscale/Jumpscale/builders/builder/system/BuilderBaseClass.py", line 168, in wrapper_action
    res = self.apply_method(func, kwargs)
  File "/sandbox/lib/jumpscale/Jumpscale/builders/builder/system/BuilderBaseClass.py", line 93, in apply_method
    return func(**kwargs)
  File "/sandbox/lib/jumpscale/Jumpscale/builders/builder/web/BuilderOpenResty.py", line 27, in build
    url, to=dest, overwrite=False, retry=3, expand=True, minsizekb=1000, removeTopDir=True, deletedest=True
  File "/sandbox/lib/jumpscale/Jumpscale/builders/builder/tools/BuilderTools.py", line 179, in file_download
    raise RuntimeError("cannot find:%s" % to)
RuntimeError: cannot find:{DIR_TEMP}/openresty-1.13.6.2.tar.gz

cannot find:{DIR_TEMP}/openresty-1.13.6.2.tar.gz
JSX>
rkhamis commented 5 years ago

@Dinaamagdy fixed on development_jumpscale, and development_jumpscale is merged into builders as well

Dinaamagdy commented 5 years ago

STEPS

j.builders.runtimes.lua.install(reset=True) : works successfully but

Error: Failed finding Lua header files. You may need to install them or configure LUA_INCDIR.

then 

3BOTDEVEL:3bot:jumpscaleX: luacheck bash: luacheck: command not found