包裹管理 – 使用安装有luarocks的lua岩石
作者:互联网
我想用luarocks安装luasql.mysql,我遇到了一个问题.即使安装了提供mysql.h的软件包,luarocks也找不到它.我最终解决了它:
luarocks install luasql-mysql MYSQL_INCDIR=/usr/include/mysql
现在,应该满足所有先决条件,使用luasql.mysql,但我收到一个错误:
> 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 ?
现在,在该列表中,没有/usr/local/lib / luarocks / rocks /或类似的东西.另外,我似乎找不到mysql.lua.
根据luarocks,luasql-mysql安装正确,但:
% luarocks list
Installed rocks:
----------------
luasql-mysql
2.3.0-1 (installed) - /usr/local/lib/luarocks/rocks
我相信我做错了什么,但我不知道在哪里.此外,在安装其他软件包时,Lua似乎相当模糊……
解决方法:
好的,我解决了,这是一个非常愚蠢的错误:
luasql.mysql是only available for Lua 5.1,而不是Lua 5.2,我默认使用它.运行lua5.1解决了这个问题:
% lua5.1
Lua 5.1.5 Copyright (C) 1994-2012 Lua.org, PUC-Rio
> require "luasql.mysql"
>
……一切都很好.
很抱歉造成了混乱……
标签:mysql,lua,package-management 来源: https://codeday.me/bug/20190816/1670393.html