Plain
Text
code
?
/tmp/
cat
test1.lua
package.path
=
package.path
..
"./?.lua"
local
test2
=
require("test2")
/tmp/
~/tmp/lua-5.2.2/src/lua
test1.lua
#
没问题
/tmp/
rm
test2.lua
#
删掉test2.lua
/tmp/
~/tmp/lua-5.2.2/src/lua
test1.lua
#
报错了
/home/user/tmp/lua-5.2.2/src/lua:
test1.lua:2:
module
'test2'
not
found:
no
field
package.preload['test2']
no
file
'/usr/local/share/lua/5.2/test2.lua'
no
file
'/usr/local/share/lua/5.2/test2/init.lua'
no
file
'/usr/local/lib/lua/5.2/test2.lua'
no
file
'/usr/local/lib/lua/5.2/test2/init.lua'
no
file
'./test2.lua'
no
file
'./test2.lua'
no
file
'正闷庆/usr/local/lib/lua/5.2/test2.so'
no
file
'/usr/local/lib/lua/5.2/loadall.so'
no
file
'./test2.so'
stack
traceback:
[C]:
in
function
'require'
test1.lua:2:
in
main
chunk
[C]:
in
?
/tmp/
touch
test2.lua
#
重新建举握立test2.lua
/tmp/
~/tmp/lua-5.2.2/src/lua
test1.lua
#
没问题
/tmp/
cd
~/tmp
#
换到别的目录
~/tmp/
~/tmp/lua-5.2.2/src/lua
/tmp/test1.lua
#
出错了
/home/user/tmp/lua-5.2.2/src/lua:
/tmp/test1.lua:2:
module
'test2'
not
found:
no
field
package.preload['test2']
no
file
'/usr/local/share/lua/5.2/test2.lua'
no
file
'/usr/local/share/lua/5.2/test2/init.lua'
no
file
'/usr/local/lib/lua/5.2/test2.lua'
no
file
'/usr/local/lib/lua/5.2/test2/init.lua'
no
file
'./test2.lua'
no
file
'./test2.lua'
no
file
'/usr/local/lib/lua/5.2/test2.so'
no
file
'/usr/local/lib/lua/5.2/loadall.so'
no
file
'./test2.so'
stack
traceback:
[C]:
in
function
'require'
/tmp/test1.lua:2:
in
main
chunk
[C]:
in
?
local ui=require("framework.ui")你这里已经引入了framework.ui
有可能通过这个友枣文件间接的引用了SelectChapter
或者framework.ui里引用的某一个文件引用轮仔了它 这是其中的一种情况
另一种情况是 SelectChapter是一个global的值 而这个值甚至有可能在你这个文件之好桐拆前就已经先引用了 所以被赋值了
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)