Skip to content

luarocks #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jney opened this issue Feb 11, 2011 · 14 comments
Closed

luarocks #16

jney opened this issue Feb 11, 2011 · 14 comments

Comments

@jney
Copy link

jney commented Feb 11, 2011

Is it possible to make it works with luarocks ?
if yes, how ?
i can require luarocks itself require("luarocks.require"), but i call another library i installed with luarocks i got some errors.

@chaoslawful
Copy link
Contributor

Hi,

I tried requiring and using several luarocks-installed modules in ngx_lua, including luasocket and luayaml, and found no errors. Could you show us some problematic modules and example scripts?

Thanks!

@jney
Copy link
Author

jney commented Feb 12, 2011

Hi,

Depending on the rocks i am calling, i got this kind of error :

2011/02/12 11:10:03 [error] 42397#0: *72 content_by_lua aborted: runtime error: /usr/local/share/lua/5.1/luarocks/loader.lua:95: error loading module 'lpeg' from file '/usr/local/lib/luarocks/lib/lua/5.1//lpeg.so':
dlopen(/usr/local/lib/luarocks/lib/lua/5.1//lpeg.so, 2): Symbol not found: _luaL_addlstring
Referenced from: /usr/local/lib/luarocks/lib/lua/5.1//lpeg.so
Expected in: dynamic lookup
, client: 127.0.0.1, server: , request: "GET / HTTP/1.1", host: "localhost:6789"
2011/02/12 11:10:03 [error] 42397#0: *73 content_by_lua aborted: runtime error: /Users/jney/src/test/server.lua:2: loop or previous error loading module 'json', client: 127.0.0.1, server: , request: "GET /favicon.ico HTTP/1.1", host: "localhost:6789"

Or this kind :

2011/02/12 10:51:54 [error] 39866#0: *59 content_by_lua aborted: runtime error: /Users/jney/src/test/server.lua:2: module 'luasocket' not found:

@chaoslawful
Copy link
Contributor

Hi,

Rocks luasocket/lpeg/luajson work well with ngx_lua in my environment...Would you please offer the following commands' output?

  • uname -a

  • /path/to/your/nginx/executable -V

  • nm /path/to/your/nginx/executable | grep luaL_

  • ldd /path/to/your/nginx/executable

  • Output of this script in your nginx with ngx_lua:

    require("luarocks.require")
    ngx.say(package.path)
    ngx.say(package.cpath)

  • luarocks --version; luarocks path

@jney
Copy link
Author

jney commented Feb 12, 2011

Hi,

Here it is :

  • uname -a :

    Darwin hackro 10.6.0 Darwin Kernel Version 10.6.0: Wed Nov 10 18:13:17 PST 2010; root:xnu-1504.9.26~3/RELEASE_I386 i386 i386

  • nginx -V

    nginx version: nginx/0.8.54
    TLS SNI support enabled
    configure arguments: --prefix=/usr/local/Cellar/nginx/0.8.54 --with-http_ssl_module --with-pcre --conf-path=/usr/local/etc/nginx/nginx.conf --pid-path=/usr/local/var/run/nginx.pid --lock-path=/usr/local/var/nginx/nginx.lock --without-mail_pop3_module --without-mail_imap_module --without-mail_smtp_module --with-http_realip_module --with-http_gzip_static_module --with-http_geoip_module --add-module=/Users/jney/src/nginx/ngx_devel_kit/ --add-module=/Users/jney/src/nginx/lua-nginx-module/ --add-module=/Users/jney/src/nginx/redis2-nginx-module/ --add-module=/Users/jney/src/nginx/encrypted-session-nginx-module/

  • nm $(which nginx) | grep luaL_

    zsh: done nm $(which nginx) |
    zsh: exit 1 grep --color=auto luaL_

  • otool -L $(which nginx)

    /usr/local/sbin/nginx:
    /usr/lib/libcrypto.0.9.8.dylib (compatibility version 0.9.8, current version 0.9.8)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.1)
    /usr/lib/libssl.0.9.8.dylib (compatibility version 0.9.8, current version 0.9.8)
    /usr/lib/libpcre.0.dylib (compatibility version 1.0.0, current version 1.1.0)
    /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.3)
    /usr/local/Cellar/geoip/1.4.6/lib/libGeoIP.1.dylib (compatibility version 6.0.0, current version 6.6.0)

  • require("luarocks.require") ngx.say(package.path) ngx.say(package.cpath)

    package.path :
    /usr/local/lib/luarocks/share/lua/5.1//?.lua;/usr/local/lib/luarocks/share/lua/5.1//?/init.lua;/.luarocks/share/lua/5.1//?.lua;/.luarocks/share/lua/5.1//?/init.lua;./?.lua;/usr/local/share/lua/5.1/?.lua;/usr/local/share/lua/5.1/?/init.lua;/usr/local/lib/lua/5.1/?.lua;/usr/local/lib/lua/5.1/?/init.lua
    package.cpath :
    /usr/local/lib/luarocks/lib/lua/5.1//?.so;/.luarocks/lib/lua/5.1//?.so;./?.so;/usr/local/lib/lua/5.1/?.so;/usr/local/lib/lua/5.1/loadall.so

  • luarocks --version

    luarocks 2.0.2
    LuaRocks main command-line interface

I don't know how to get luarocks path, but i think it is /usr/local/lib/luarocks
Plus, when i require a rocks in a script with lua installed binary, it works. so i tried to set lua_package_path and lua_package_cpath to what i got on my system, getting them with package.path and package.cpath. but it doesn't work.

Thank you for the support.

@chaoslawful
Copy link
Contributor

Hi,

It's weird that your nginx executable doesn't export any luaL_* symbols. What about the standard lua executable? Would you run the nm cmdline on it again and paste its output?

Besides, the strace output of nginx is also helpful. Please run:

strace -o strace.log /path/to/your/nginx/executable

Access the problematic script, then interrupt strace and send both strace.log and the script itself to me.

Thanks

@jney
Copy link
Author

jney commented Feb 14, 2011

Here it is :

@chaoslawful
Copy link
Contributor

Sorry, I mean the output of nm $(which lua). Besides, would you add -f option to dtruss in order to trace all the child processes, like sudo dtruss -a -f -l $(which nginx) 2>&1 | tee ./trace.log > /dev/null ?

@jney
Copy link
Author

jney commented Feb 15, 2011

Here it is :

@chaoslawful
Copy link
Contributor

It seems that nginx executable doesn't export lua related symbols, so lua c-modules doesn't work. On Linux there's -E linking options to do executable symbols exporting, I don't know if OSX has some linking options with similar behavior. Could you search your linker's document to find some hints?

@chaoslawful
Copy link
Contributor

You compiled nginx with homebrew interactive shell, right? I tried this way under OSX, and found that homebrew strangely disabled all exported symbols from installed nginx executable file. The exported symbols are correct both in the building directory AND installed directory, as long as we are in homebrew interactive shell. We have to find out what had it done after building shell exited.

@chaoslawful
Copy link
Contributor

OK...homebrew just stripped debug symbols out of nginx executables, normally this should be okay. But it seems that lpeg could not work in such a environment, we have to dig out reason from lpeg...

@chaoslawful
Copy link
Contributor

Sorry, the problem is related to luarocks, not lpeg. We'll find out how to solve it....

@agentzh
Copy link
Member

agentzh commented Aug 11, 2011

Sorry for the delay but I just tried and could not reproduce this issue on Mac OS X 10.6.8 using the standard nginx tarball and plain gcc (shipped by Xcode).

How exactly did you build your nginx/ngx_lua? Have you stripped dynamic symbols from your nginx executable?

Can you try out the ngx_openresty bundle to see if it works with your LuaRocks modules? http://openresty.org/#Download

@agentzh
Copy link
Member

agentzh commented Aug 16, 2011

Consider it resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants