calio / lua-capnproto

Lua-capnp is a pure lua implementation of capnproto based on luajit.
BSD 2-Clause "Simplified" License
70 stars 24 forks source link

LuaJIT 2.0.3 vs Lua 5.2 #1

Closed kaos closed 10 years ago

kaos commented 10 years ago

Hi,

I see I have LuaJIT 2.0.3, which seems to be based on Lua 5.1.. while I have Lua 5.2 installed. So, luarocks installs libraries under a 5.2 path, while luajit fails to find them under a 5.1 one.. any hints on how to get around this? (I just started looking at it, maybe it will work just messing with lib paths..?)

...
lua-capnproto 0.0.1-1 is now built and installed in /usr (license: BSD)
kaos@cypher ~/src/lua-capnproto (master *)
$ make test

Running test/01-sanity.lua...
luajit: test/01-sanity.lua:2: module 'lunitx' not found:
        no field package.preload['lunitx']
        no file '/home/kaos/src/lua-capnproto/lua/lunitx.lua'
        no file '/home/kaos/src/lua-capnproto/proto/lunitx.lua'
        no file '/home/kaos/src/lua-capnproto/../capnp_test/lunitx.lua'
        no file './lunitx.lua'
        no file '/usr/share/luajit-2.0.3/lunitx.lua'
        no file '/usr/local/share/lua/5.1/lunitx.lua'
        no file '/usr/local/share/lua/5.1/lunitx/init.lua'
        no file '/usr/share/lua/5.1/lunitx.lua'
        no file '/usr/share/lua/5.1/lunitx/init.lua'
        no file './lunitx.so'
        no file '/usr/local/lib/lua/5.1/lunitx.so'
        no file '/usr/lib64/lua/5.1/lunitx.so'
        no file '/usr/local/lib/lua/5.1/loadall.so'
stack traceback:
        [C]: in function 'require'
        test/01-sanity.lua:2: in main chunk
        [C]: at 0x00404e90
make: *** [test] Error 1
kaos@cypher ~/src/lua-capnproto (master *)
$ luarocks show lunitx

lunitx 0.7-1 - Lunitx is a unit testing framework for lua, written in lua.

Lunitx is a unit testing framework for lua, written in lua, based heavily on
Lunit 0.5, but modified to work with Lua 5.2. Lunitx provides 27 assert
functions, and a few misc functions for usage in an easy unit testing
framework. Lunit comes with a test suite to test itself. The testsuite consists
of approximately 710 assertions.

License:        MIT/X11
Homepage:       https://github.com/dcurrie/lunit
Installed in:   /usr

Modules:
        lunit (/usr/share/lua/5.2/lunit.lua)
        lunit.console (/usr/share/lua/5.2/lunit/console.lua)
        lunitx (/usr/share/lua/5.2/lunitx.lua)
        lunitx.atexit (/usr/share/lua/5.2/lunitx/atexit.lua)

kaos@cypher ~/src/lua-capnproto (master *)
calio commented 10 years ago

Hi kaos,

Currently, lua-capnproto works only with LuaJIT 2.1. There are some 64 bit int issues with LuaJIT 2.0 and Lua 5.1, Lua 5.2. You can checkout LuaJIT's repository "git clone http://luajit.org/git/luajit-2.0.git", switch to "v2.1" branch, and "make && sudo make install". LuaJIT is based on Lua 5.1, so you need luarocks to install libs to Lua 5.1 dirs. See http://stackoverflow.com/questions/20321560/how-do-install-libraries-for-both-lua5-2-and-5-1-using-luarocks. And then install lunitx and lua-cjson:

$sudo luarocks-5.1 install lua-cjson $sudo luarocks-5.1 install lunitx

And then you should run tests. Could you please pull the lua-capnproto repository, I just fixed some issues.

kaos commented 10 years ago

Ouch, that could be worth mentioning in the readme (that luajit should be >= 2.1). Even the comment in the rockspec is misleading regarding this (stating that luajit should be >= 2.0.0).

Thanks for the additional information, though. I find the issue resolved with the provided answer.

For now, I simply converted the output from capnpc -owhich cat<schema-file> | capnp decode ... to a valid lua table structure. I'll let you know how it works out once I get back to another attempt with lua-capnproto.

calio commented 10 years ago

Yes, I should have wrote something. I just submitted a commit 3fb4fb2d36590e512bc73f439312dc76a3bdce27 mentioning it in the readme file.