尝试设置调试后弄乱了lua路径

问题描述 投票:0回答:1

我想通过大型lua代码库进行调试。为此,我下载了ZeroBrane,并按照他们的指示设置了捆绑的mobdebug。

代码库是koreader。以下shellscript重现了我所做的事情:

# dependencies for building koreader
sudo apt-get install build-essential git patch wget unzip \
gettext autoconf automake cmake libtool nasm luarocks libsdl2-dev \
libssl-dev libffi-dev libsdl2-dev libc6-dev-i386 xutils-dev linux-libc-dev:i386 zlib1g:i386

# get the source
git clone https://github.com/koreader/koreader.git
cd koreader && ./kodev fetch-thirdparty

# build it, this will take a long time
./kodev build

# assuming you have ZeroBrane installed
export ZBS=/opt/zbstudio
export LUA_PATH="./?.lua;$ZBS/lualibs/?/?.lua;$ZBS/lualibs/?.lua"
export LUA_CPATH="$ZBS/bin/linux/x86/?.so;$ZBS/bin/linux/x86/clibs/?.so"

# execute it, this will run lua
./kodev run

执行./kodev run会导致以下错误消息:

 [*] Current time: 10/14/19-17:55:34
./luajit: ./datastorage.lua:3: module 'libs/libkoreader-lfs' not found:
    no field package.preload['libs/libkoreader-lfs']
    no file './libs/libkoreader-lfs.lua'
    no file '/opt/zbstudio/lualibs/libs/libkoreader-lfs/libs/libkoreader-lfs.lua'
    no file '/opt/zbstudio/lualibs/libs/libkoreader-lfs.lua'
    no file '/opt/zbstudio/bin/linux/x86/libs/libkoreader-lfs.so'
    no file '/opt/zbstudio/bin/linux/x86/clibs/libs/libkoreader-lfs.so'
stack traceback:
    [C]: in function 'require'
    ./datastorage.lua:3: in main chunk
    [C]: in function 'require'
    ./reader.lua:18: in main chunk
    [C]: at 0x55a81bf25771
~/programming/koreader

如果没有LUA_PATHLUA_CPATH的定义,则没有问题,koreader可以正常运行。因此,我认为导入路径被某种方式破坏了。如何正确设置?

也许这对您有帮助,如果我正确阅读了代码,./kodev run将(在某个时候)执行此操作:

-- set search path for 'require()'
package.path =
    "common/?.lua;rocks/share/lua/5.1/?.lua;frontend/?.lua;" ..
    package.path
package.cpath =
    "common/?.so;common/?.dll;/usr/lib/lua/?.so;rocks/lib/lua/5.1/?.so;" ..
    package.cpath
debugging lua zerobrane
1个回答
0
投票

您的代码正在尝试加载库libkoreader-lfs,在LUA_CPATHLUA_PATH中设置的任何路径中都找不到该库。我不知道您的项目结构可以为您提供确切的答案,但是由于它在您设置这些环境变量时有效,而在您这样做时不起作用,因此您似乎正在覆盖一些默认值这些变量的值。

尝试对这些变量进行添加,而不是对它们进行[[设置:

export LUA_PATH="$LUA_PATH;./?.lua;$ZBS/lualibs/?/?.lua;$ZBS/lualibs/?.lua" export LUA_CPATH="LUA_CPATH;$ZBS/bin/linux/x86/?.so;$ZBS/bin/linux/x86/clibs/?.so"
© www.soinside.com 2019 - 2024. All rights reserved.