Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I wanted to install luasql.mysql with luarocks, and I've ran into a problem. Even though the packages were installed providing mysql.h, luarocks couldn't find it. I solved it eventually:

luarocks install luasql-mysql MYSQL_INCDIR=/usr/include/mysql

Now, all prerequisites should be met, to use luasql.mysql, but I'm getting an error:

> require "luasql.mysql"
stdin:1: module 'luasql.mysql' not found:
    no field package.preload['luasql.mysql']
    no file '/usr/local/share/lua/5.2/luasql/mysql.lua'
    no file '/usr/local/share/lua/5.2/luasql/mysql/init.lua'
    no file '/usr/local/lib/lua/5.2/luasql/mysql.lua'
    no file '/usr/local/lib/lua/5.2/luasql/mysql/init.lua'
    no file './luasql/mysql.lua'
    no file '/usr/share/lua/5.2/luasql/mysql.lua'
    no file '/usr/share/lua/5.2/luasql/mysql/init.lua'
    no file './luasql/mysql.lua'
    no file '/usr/local/lib/lua/5.2/luasql/mysql.so'
    no file '/usr/lib/x86_64-linux-gnu/lua/5.2/luasql/mysql.so'
    no file '/usr/lib/lua/5.2/luasql/mysql.so'
    no file '/usr/local/lib/lua/5.2/loadall.so'
    no file './luasql/mysql.so'
    no file '/usr/local/lib/lua/5.2/luasql.so'
    no file '/usr/lib/x86_64-linux-gnu/lua/5.2/luasql.so'
    no file '/usr/lib/lua/5.2/luasql.so'
    no file '/usr/local/lib/lua/5.2/loadall.so'
    no file './luasql.so'
stack traceback:
    [C]: in function 'require'
    stdin:1: in main chunk
    [C]: in ?

Now, in that list, there is no /usr/local/lib/luarocks/rocks/ or anything like that. Also, I can't seem to find a mysql.lua.

According to luarocks, luasql-mysql is installed correctly, though:

% luarocks list

Installed rocks:
----------------

luasql-mysql
   2.3.0-1 (installed) - /usr/local/lib/luarocks/rocks

I believe I did something wrong, but I have no idea where. Also, it seems Lua is quite obscure when it comes to installing additional packages...

share|improve this question

2 Answers 2

up vote 1 down vote accepted

OK, I solved it, and it was quite a stupid mistake:

luasql.mysql is only available for Lua 5.1, not Lua 5.2, which I use by default. Running lua5.1 solves the issue:

% lua5.1       
Lua 5.1.5  Copyright (C) 1994-2012 Lua.org, PUC-Rio
> require "luasql.mysql"
>

...and all is good.

Sorry to have created a confusion...

share|improve this answer

Have you tried to set lua.package_cpath or lua.package_path in your LUA script?

Or set LUA_CPATH and LUA_PATH environment variable?

i.e export LUA_PATH='/usr/local/lib/luarocks/?.so'; lua ./XX.lua

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.