lunarmodules / luasql

LuaSQL is a simple interface from Lua to a DBMS.
http://lunarmodules.github.io/luasql
535 stars 192 forks source link

Module 'luasql.mysql' not found #126

Closed kimnamcham closed 5 months ago

kimnamcham commented 3 years ago

I had install lua rock 5.1.

luarocks list

Rocks installed for Lua 5.1

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

But when i run this code example. It has error:

Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio

print(package.path) ./?.lua;/usr/share/lua/5.1/?.lua;/usr/share/lua/5.1/?/init.lua;/usr/lib64/lua/5.1/?.lua;/usr/lib64/lua/5.1/?/init.lua print(package.cpath) ./?.so;/usr/lib64/lua/5.1/?.so;/usr/lib64/lua/5.1/loadall.so

env = assert (require"luasql.mysql".mysql()) stdin:1: module 'luasql.mysql' not found: no field package.preload['luasql.mysql'] no file './luasql/mysql.lua' no file '/usr/share/lua/5.1/luasql/mysql.lua' no file '/usr/share/lua/5.1/luasql/mysql/init.lua' no file '/usr/lib64/lua/5.1/luasql/mysql.lua' no file '/usr/lib64/lua/5.1/luasql/mysql/init.lua' no file './luasql/mysql.so' no file '/usr/lib64/lua/5.1/luasql/mysql.so' no file '/usr/lib64/lua/5.1/loadall.so' no file './luasql.so' no file '/usr/lib64/lua/5.1/luasql.so' no file '/usr/lib64/lua/5.1/loadall.so' stack traceback: C: in function 'require' stdin:1: in main chunk

Any body can resolve this? My os is centos 7

tomasguisasola commented 3 years ago

Hi minhdv1392

Your package.cpath is not pointing to the path where the library was installed. You should correct one of them. Have you loaded luarocks.loader (or luarocks.require) while running Lua? This could solve the problem:

$ lua -lluarocks.loader -e "print(package.path)"

I recommend the docs about using LuaRocks:

https://github.com/luarocks/luarocks/wiki/Using-LuaRocks

Regards, Tomás

Em sáb., 2 de jan. de 2021 às 05:46, minhdv1392 notifications@github.com escreveu:

I had install lua rock 5.1.

luarocks list Rocks installed for Lua 5.1

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

But when i run this code example. It has error:

Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio

print(package.path)

./?.lua;/usr/share/lua/5.1/?.lua;/usr/share/lua/5.1/?/init.lua;/usr/lib64/lua/5.1/?.lua;/usr/lib64/lua/5.1/?/init.lua print(package.cpath) ./?.so;/usr/lib64/lua/5.1/?.so;/usr/lib64/lua/5.1/loadall.so

env = assert (require"luasql.mysql".mysql()) stdin:1: module 'luasql.mysql' not found: no field package.preload['luasql.mysql'] no file './luasql/mysql.lua' no file '/usr/share/lua/5.1/luasql/mysql.lua' no file '/usr/share/lua/5.1/luasql/mysql/init.lua' no file '/usr/lib64/lua/5.1/luasql/mysql.lua' no file '/usr/lib64/lua/5.1/luasql/mysql/init.lua' no file './luasql/mysql.so' no file '/usr/lib64/lua/5.1/luasql/mysql.so' no file '/usr/lib64/lua/5.1/loadall.so' no file './luasql.so' no file '/usr/lib64/lua/5.1/luasql.so' no file '/usr/lib64/lua/5.1/loadall.so' stack traceback: C: in function 'require' stdin:1: in main chunk

Any body can resolve this? My os is centos 7

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/keplerproject/luasql/issues/126, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABAB3MVHJDN7KOT5XS3AWDSX3MMXANCNFSM4VQ45MTQ .

kimnamcham commented 3 years ago

Hi minhdv1392 Your package.cpath is not pointing to the path where the library was installed. You should correct one of them. Have you loaded luarocks.loader (or luarocks.require) while running Lua? This could solve the problem: $ lua -lluarocks.loader -e "print(package.path)" I recommend the docs about using LuaRocks: https://github.com/luarocks/luarocks/wiki/Using-LuaRocks Regards, Tomás Em sáb., 2 de jan. de 2021 às 05:46, minhdv1392 notifications@github.com escreveu: I had install lua rock 5.1. luarocks list Rocks installed for Lua 5.1 luasql-mysql 2.6.0-1 (installed) - /usr/local/lib/luarocks/rocks-5.1 But when i run this code example. It has error: Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio print(package.path) ./?.lua;/usr/share/lua/5.1/?.lua;/usr/share/lua/5.1/?/init.lua;/usr/lib64/lua/5.1/?.lua;/usr/lib64/lua/5.1/?/init.lua print(package.cpath) ./?.so;/usr/lib64/lua/5.1/?.so;/usr/lib64/lua/5.1/loadall.so env = assert (require"luasql.mysql".mysql()) stdin:1: module 'luasql.mysql' not found: no field package.preload['luasql.mysql'] no file './luasql/mysql.lua' no file '/usr/share/lua/5.1/luasql/mysql.lua' no file '/usr/share/lua/5.1/luasql/mysql/init.lua' no file '/usr/lib64/lua/5.1/luasql/mysql.lua' no file '/usr/lib64/lua/5.1/luasql/mysql/init.lua' no file './luasql/mysql.so' no file '/usr/lib64/lua/5.1/luasql/mysql.so' no file '/usr/lib64/lua/5.1/loadall.so' no file './luasql.so' no file '/usr/lib64/lua/5.1/luasql.so' no file '/usr/lib64/lua/5.1/loadall.so' stack traceback: [C]: in function 'require' stdin:1: in main chunk [C]: ? Any body can resolve this? My os is centos 7 — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#126>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABAB3MVHJDN7KOT5XS3AWDSX3MMXANCNFSM4VQ45MTQ .

Thansk @tomasguisasola . When i pointing the cpath, the other issuses has:

Lua 5.1.4  Copyright (C) 1994-2008 Lua.org, PUC-Rio
> package.cpath = package.cpath .. ";/usr/local/lib/lua/5.1/?.so"
> env = assert (require"luasql.mysql".mysql())
error loading module 'luasql.mysql' from file '/usr/local/lib/lua/5.1/luasql/mysql.so':
        /usr/local/lib/lua/5.1/luasql/mysql.so: undefined symbol: EVP_DecryptFinal_ex
stack traceback:
        [C]: ?
        [C]: in function 'require'
        stdin:1: in main chunk
        [C]: ?
tomasguisasola commented 3 years ago

Hi minhdv1392

now you have to check how the library (.so) was built. Do you have the compilation messages? If not, can you compile it again? The error says that the library could not find a symbol which, by its name, I would think it should be exported by some other library (not Lua). Could you run the following?

$ ldd /usr/local/lib/lua/5.1/luasql/mysql.so

The result should be a series of names of libraries it depends on and the actual path where the libraries are located. Maybe there is a missing library or an incorrect version (it is not difficult to compile a program using an incorrect header file)...

Regards, Tomás

Em sáb., 2 de jan. de 2021 às 08:26, minhdv1392 notifications@github.com escreveu:

Hi minhdv1392 Your package.cpath is not pointing to the path where the library was installed. You should correct one of them. Have you loaded luarocks.loader (or luarocks.require) while running Lua? This could solve the problem: $ lua -lluarocks.loader -e "print(package.path)" I recommend the docs about using LuaRocks: https://github.com/luarocks/luarocks/wiki/Using-LuaRocks Regards, Tomás Em sáb., 2 de jan. de 2021 às 05:46, minhdv1392 notifications@github.com escreveu: … <#m-1980218108240525326> I had install lua rock 5.1. luarocks list Rocks installed for Lua 5.1 luasql-mysql 2.6.0-1 (installed) - /usr/local/lib/luarocks/rocks-5.1 But when i run this code example. It has error: Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio print(package.path) ./?.lua;/usr/share/lua/5.1/?.lua;/usr/share/lua/5.1/?/init.lua;/usr/lib64/lua/5.1/?.lua;/usr/lib64/lua/5.1/?/init.lua print(package.cpath) ./?.so;/usr/lib64/lua/5.1/?.so;/usr/lib64/lua/5.1/loadall.so env = assert (require"luasql.mysql".mysql()) stdin:1: module 'luasql.mysql' not found: no field package.preload['luasql.mysql'] no file './luasql/mysql.lua' no file '/usr/share/lua/5.1/luasql/mysql.lua' no file '/usr/share/lua/5.1/luasql/mysql/init.lua' no file '/usr/lib64/lua/5.1/luasql/mysql.lua' no file '/usr/lib64/lua/5.1/luasql/mysql/init.lua' no file './luasql/mysql.so' no file '/usr/lib64/lua/5.1/luasql/mysql.so' no file '/usr/lib64/lua/5.1/loadall.so' no file './luasql.so' no file '/usr/lib64/lua/5.1/luasql.so' no file '/usr/lib64/lua/5.1/loadall.so' stack traceback: [C]: in function 'require' stdin:1: in main chunk [C]: ? Any body can resolve this? My os is centos 7 — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#126 https://github.com/keplerproject/luasql/issues/126>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABAB3MVHJDN7KOT5XS3AWDSX3MMXANCNFSM4VQ45MTQ .

Thansk @tomasguisasola https://github.com/tomasguisasola . When i pointing the cpath, the other issuses has:

Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio

package.cpath = package.cpath .. ";/usr/local/lib/lua/5.1/?.so"

env = assert (require"luasql.mysql".mysql())

error loading module 'luasql.mysql' from file '/usr/local/lib/lua/5.1/luasql/mysql.so':

    /usr/local/lib/lua/5.1/luasql/mysql.so: undefined symbol: EVP_DecryptFinal_ex

stack traceback:

    [C]: ?

    [C]: in function 'require'

    stdin:1: in main chunk

    [C]: ?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/keplerproject/luasql/issues/126#issuecomment-753462058, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABAB3LR7PWR3OICZDMQWMLSX37FHANCNFSM4VQ45MTQ .

kimnamcham commented 3 years ago

I build library by this command:

[root@li1626-198 linux]# luarocks install luasql-mysql MYSQL_DIR=/www/server/mysql/ Warning: falling back to wget - install luasec to get native HTTPS support Installing https://luarocks.org/luasql-mysql-2.6.0-1.rockspec Cloning into 'luasql'... remote: Enumerating objects: 149, done. remote: Counting objects: 100% (149/149), done. remote: Compressing objects: 100% (99/99), done. remote: Total 149 (delta 72), reused 72 (delta 36), pack-reused 0 Receiving objects: 100% (149/149), 104.13 KiB | 0 bytes/s, done. Resolving deltas: 100% (72/72), done. Note: checking out '22d4a911f35cf851af9db71124e3998d96fb3fa1'.

You are in 'detached HEAD' state. You can look around, make experimental changes and commit them, and you can discard any commits you make in this state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may do so (now or later) by using -b with the checkout command again. Example:

git checkout -b new_branch_name

luasql-mysql 2.6.0-1 depends on lua >= 5.1 (5.1-1 provided by VM) gcc -O2 -fPIC -I/usr/local/include/luajit-2.0 -c src/luasql.c -o src/luasql.o -I/www/server/mysql/include gcc -O2 -fPIC -I/usr/local/include/luajit-2.0 -c src/ls_mysql.c -o src/ls_mysql.o -I/www/server/mysql/include gcc -shared -o luasql/mysql.so src/luasql.o src/ls_mysql.o -L/www/server/mysql/lib -Wl,-rpath,/www/server/mysql/lib -lmysqlclient luasql-mysql 2.6.0-1 is now installed in /usr/local (license: MIT/X11)

When i using : ldd /usr/local/lib/lua/5.1/luasql/mysql.so

The result is:

[root@li1626-198 linux]# ldd /usr/local/lib/lua/5.1/luasql/mysql.so linux-vdso.so.1 => (0x00007ffdebbc9000) libc.so.6 => /lib64/libc.so.6 (0x00007f909a9fd000) /lib64/ld-linux-x86-64.so.2 (0x00007f909b33b000)

How can resolve this issuse? Thanks Tomas

tomasguisasola commented 3 years ago

Hi minhdv1392

You compiled using LuaJIT headers and is trying to load the driver with Lua. I am not sure, but this could be the problem. Try running LuaJIT instead of Lua, which should be simpler, or configure luarocks to use Lua instead of LuaJIT.

Regards, Tomás

Em sáb., 2 de jan. de 2021 às 09:16, minhdv1392 notifications@github.com escreveu:

I build library by this command:

`[root@li1626-198 linux]# luarocks install luasql-mysql MYSQL_DIR=/www/server/mysql/ Warning: falling back to wget - install luasec to get native HTTPS support Installing https://luarocks.org/luasql-mysql-2.6.0-1.rockspec Cloning into 'luasql'... remote: Enumerating objects: 149, done. remote: Counting objects: 100% (149/149), done. remote: Compressing objects: 100% (99/99), done. remote: Total 149 (delta 72), reused 72 (delta 36), pack-reused 0 Receiving objects: 100% (149/149), 104.13 KiB | 0 bytes/s, done. Resolving deltas: 100% (72/72), done. Note: checking out '22d4a911f35cf851af9db71124e3998d96fb3fa1'.

You are in 'detached HEAD' state. You can look around, make experimental changes and commit them, and you can discard any commits you make in this state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may do so (now or later) by using -b with the checkout command again. Example:

git checkout -b new_branch_name

luasql-mysql 2.6.0-1 depends on lua >= 5.1 (5.1-1 provided by VM) gcc -O2 -fPIC -I/usr/local/include/luajit-2.0 -c src/luasql.c -o src/luasql.o -I/www/server/mysql/include gcc -O2 -fPIC -I/usr/local/include/luajit-2.0 -c src/ls_mysql.c -o src/ls_mysql.o -I/www/server/mysql/include gcc -shared -o luasql/mysql.so src/luasql.o src/ls_mysql.o -L/www/server/mysql/lib -Wl,-rpath,/www/server/mysql/lib -lmysqlclient luasql-mysql 2.6.0-1 is now installed in /usr/local (license: MIT/X11)`

When i using : ldd /usr/local/lib/lua/5.1/luasql/mysql.so

The result is:

[root@li1626-198 linux]# ldd /usr/local/lib/lua/5.1/luasql/mysql.so linux-vdso.so.1 => (0x00007ffdebbc9000) libc.so.6 => /lib64/libc.so.6 (0x00007f909a9fd000) /lib64/ld-linux-x86-64.so.2 (0x00007f909b33b000)

How can resolve this issuse? Thanks Tomas

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

kimnamcham commented 3 years ago

Hi Tomas, how to configure luarocks use Lua instead of LuaJIT? Thanks.

tomasguisasola commented 3 years ago

Hi minhdv1392

Run luarocks with no options and it will show you how it was configured. I am not sure if you'll have to reinstall it but maybe the configuration files could be used to rearrange this.

Take a look at LuaRocks documentation, too:

https://github.com/luarocks/luarocks/wiki/Documentation

Regards, Tomás

Em sáb., 2 de jan. de 2021 às 09:37, minhdv1392 notifications@github.com escreveu:

Hi Tomas, how to configure luarocks use Lua instead of LuaJIT? Thanks.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/keplerproject/luasql/issues/126#issuecomment-753468706, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABAB3KOQKBXYC6UIKAMK43SX4HQ5ANCNFSM4VQ45MTQ .

kimnamcham commented 3 years ago

I will try it. Thanks you so much !!