Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LuaSocket, Lua 5.2 and Redis

Has anyone been able to get these working together? I've gotten 5.2 working great, and it can find lua-redis (redis.lua), however it fails loading the socket module, which I can't seem to get working with lua (LuaSocket version 2.0.2). Anyone have any tips to get this working?

I've tried making luasocket, however it fails completely, which I'm assuming is due to my lua version 5.2.

Is the answer just to revert back to lua 5.1, or is there another fix that i'm not aware of?

like image 716
Jonathan Coe Avatar asked Oct 09 '22 09:10

Jonathan Coe


1 Answers

The current release of LuaSocket, as many Lua libraries, does not support Lua 5.2. For Lua changes in the second digit of the version indicate major releases, and backwards-compatibility is not maintained (except in some cases via compilation flags to re-enable deprecated features).

Lua 5.1 is stable, and there is no particular reason not to use it unless you need a feature that was added in 5.2.

That said, many libraries are currently being updated to be 5.2-compatible, including LuaSocket. If you are determined and happy to compile from source and tweak makefiles, try this repository which is a 5.2 compatible version of LuaSocket.

Note that Lua 5.2 must have been built with LUA_COMPAT_MODULE defined for this version of LuaSocket to compile with it. You'll also need to edit the makefiles to adjust for the correct paths on your system.

Given another 3-4 months or so and I think many of the common libraries will be 5.2 compatible. However in my opinion unless it's small stuff, I think it is early days to be basing projects off 5.2. Porting code to 5.2 down the line is not that hard (especially if you familiarise yourself with the deprecated features so you can avoid depending on them too much in 5.1 - especially setfenv() and module()).

like image 74
MattJ Avatar answered Oct 13 '22 09:10

MattJ