lunarmodules / luafilesystem

LuaFileSystem is a Lua library developed to complement the set of functions related to file systems offered by the standard Lua distribution.
https://lunarmodules.github.io/luafilesystem/
MIT License
914 stars 292 forks source link

lua:5: module 'lfs' not found even after running luarocks .. #142

Open nodecentral opened 4 years ago

nodecentral commented 4 years ago

Hi

I’m trying to get the LfS installed, and have tried luarocks a few times, but when I eventually run some code that requires it , it’s not found ? Any ideas ?

pi@raspberrypi:~ $ sudo luarocks install luafilesystem
Warning: falling back to wget - install luasec to get native HTTPS support
Installing https://rocks.moonscript.org/luafilesystem-1.8.0-1.src.rock...
Using https://rocks.moonscript.org/luafilesystem-1.8.0-1.src.rock... switching to 'build' mode
gcc -O2 -fPIC -I/usr/include/lua5.1 -c src/lfs.c -o src/lfs.o
gcc -shared -o lfs.so -L/usr/local/lib src/lfs.o
Updating manifest for /usr/local/lib/luarocks/rocks
luafilesystem 1.8.0-1 is now built and installed in /usr/local (license: MIT/X11)

When I try to use the lfs module I always get the following message ??

usr/bin/lua: ./ircodetest10.lua:5: module 'lfs' not found:
        no field package.preload['lfs']
        no file '/usr/local/share/lua/5.2/lfs.lua'
        no file '/usr/local/share/lua/5.2/lfs/init.lua'
        no file '/usr/local/lib/lua/5.2/lfs.lua'
        no file '/usr/local/lib/lua/5.2/lfs/init.lua'
        no file '/usr/share/lua/5.2/lfs.lua'
        no file '/usr/share/lua/5.2/lfs/init.lua'
        no file './lfs.lua'
        no file '/usr/local/lib/lua/5.2/lfs.so'
        no file '/usr/lib/arm-linux-gnueabihf/lua/5.2/lfs.so'
        no file '/usr/lib/lua/5.2/lfs.so'
        no file '/usr/local/lib/lua/5.2/loadall.so'
        no file './lfs.so'
stack traceback:
        [C]: in function 'require'
        ./ircodetest10.lua:5: in main chunk
        [C]: in ?
nodecentral commented 4 years ago

Checking /use/local/ which luarocks reported, I can’t see it listed?

pi@raspberrypi:/usr/local $ ls
bin  etc  games  include  lib  man  sbin  share  src
Kabouik commented 3 years ago

I am having the same issue. Note that my distribution does not offer any luafilesystem package, so I just used sudo luarocks install luafilesystem, it is not clear to me if that is enough or if the module would be found only if a distributioin package is installed as well (in which case, I'm stuck, unless I compile it).

$ echo $LUA_PATH
/usr/share/lua/5.3/?.lua;/usr/share/lua/5.3/?/init.lua;/usr/lib/lua/5.3/?.lua;/usr/lib/lua/5.3/?/init.lua;./?.lua;./?/init.lua;/home/mathieu/.luarocks/share/lua/5.3/?.lua;/home/mathieu/.luarocks/share/lua/5.3/?/init.lua
robertlzj commented 3 years ago

I'm using windows only, some suggestion try to help.

  1. Check the actual file location of lfs.so, seems at '/usr/local'?
  2. move file to path where lua could find it - from package.cpath (like usr/lib/lua/5.2/), or append file path to cpath.
Kabouik commented 3 years ago

I don't know about @nodecentral, but in my case just running sudo luarocks install luafilesystem on Debian was enough this time.

My initial goal was to compile the luakit web browser. I pulled the luakit sources from git again today and had to install luajit and libluajit-5.1-dev with apt, then the compilation of luakit just worked.

This was already what I tried three weeks ago when I got the error, so I'm not sure what changed; maybe the luakit sources coincidentally fixed that.

[Edit] Wait, I just realized I was having this issue on another machine with another distribution. The issue is probably still there on that machine.