mwild1 / luadbi

Multi-backend SQL database library for Lua
MIT License
38 stars 14 forks source link

Lualatex can't find mysql.so #74

Open vomus opened 4 months ago

vomus commented 4 months ago

Hi! I just don't seem to be able to get DBI to work from lualatex although it works fine from a plain lua script. This is what I get on the console:

)) (/usr/share/texmf-dist/tex/luatex/luapackageloader/luapackageloader.sty)./DB
I.lua:53: Cannot load driver MySQL. Available drivers are: (None)
stack traceback:
        [C]: in function 'error'
        ./DBI.lua:53: in function 'DBI.Connect'

when there are only two lines of code:

\luadirect{
local DBI = require("DBI")
local dbh = assert(DBI.Connect("MySQL","serge", "serge", "serge", "localhost", 3306))
}

Lualatex stop yelling when I leave only the first line where it just requires DBI, so it seems there is something in DBI.lua it does not like. And that means there is something wrong with function available_drivers()...

sparked435 commented 4 months ago

You are probably missing the MySQL driver. Drivers are typically seperate packages not included with the core DBI module. Look for something like luadbi-mysql, luadbi-dbd-mysql, dbd-mysql or similiar in your package manager.

vomus commented 4 months ago

Those are in place in /usr/lib64/lua/5.3/dbd/

[serge@yarilo 5.3]$ pwd
/usr/lib64/lua/5.3
[serge@yarilo 5.3]$ ls dbd/
total 72
24 mysql.so  24 postgresql.so  24 sqlite3.so
[serge@yarilo 5.3]$

I can also see that kpsewhich can find it

[serge@yarilo 5.3]$ kpsewhich mysql.so
/usr/lib64/lua/5.3/dbd/mysql.so
[serge@yarilo 5.3]$ kpsewhich DBI.lua
/usr/share/lua/5.3/DBI.lua
[serge@yarilo 5.3]$ 

How is that possible?

vomus commented 4 months ago

I looked what the correct cpath is

[serge@veles latex]$ lua5.3
Lua 5.3.6  Copyright (C) 1994-2020 Lua.org, PUC-Rio
> package.cpath
/usr/lib64/lua/5.3/?.so;/usr/lib64/lua/5.3/loadall.so;./?.so
> 

changed the code and explicitly told where to look for the drivers:

   \directlua{
     package.cpath = "/usr/lib64/lua/5.3/?.so;/usr/lib64/lua/5.3/loadall.so;./?.so"
     print(package.cpath)
     local DBI = require('DBI')
     local dbh = assert(DBI.Connect("MySQL","serge", "serge", "serge", "localhost", 3306))
   }

it shows the correct paths all right but still can not load the driver:

(/usr/share/texmf-dist/tex/latex/base/ts1cmr.fd)package.cpath:  /usr/lib64/lua/5.3/?;/usr/local/lib/lua/5.3/?.so;/usr/local/lib/lua/5.3/loadall.so;./?.so
./DBI.lua:53: Cannot load drive
r MySQL. Available drivers are: (None)
stack traceback:
        [C]: in function 'error'
        ./DBI.lua:53: in function 'DBI.Connect'
        [\directlua]:1: in main chunk.
l.10    }
sparked435 commented 4 months ago

Possibly some other error is occuring and being masked by DBI.lua. From inside Latex, try "require 'dbd.mysql'"