Call Us Today! 877.742.2583




Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Package Paths

Some Lua packages installed via apt-getyumrpms, (or other package managers) might be installed in places that aren't in the default Lua package search path. If you encounter an error while trying to require a new library, like this...

Code Block
2016-12-29 21:56:45.507805 [ERR] mod_lua.cpp:203 /var/fs/scripts/somescript.lua:1: module 'somelibrary.lua' not found:
        no field package.preload['somelibrary.lua']
        no file '/var/fs/scripts/somelibrary/lua.lua'
        no file '/usr/local/lib/lua/5.2/somelibrary/lua.so'
        no file '/usr/lib/x86_64-linux-gnu/lua/5.2/somelibrary/lua.so'
        no file '/usr/lib/lua/5.2/somelibrary/lua.so'
        no file '/usr/local/lib/lua/5.2/loadall.so'
        no file './somelibrary/lua.so'
        no file '/usr/local/lib/lua/5.2/somelibrary.so'
        no file '/usr/lib/x86_64-linux-gnu/lua/5.2/somelibrary.so'
        no file '/usr/lib/lua/5.2/somelibrary.so'
        no file '/usr/local/lib/lua/5.2/loadall.so'
        no file './somelibrary.so'

... then you may have to append to Lua's default package search path. 

 

You can add arbitrary paths to Lua's package search path as follows:

Code Block
package.path = package.path .. ";" .. [[/usr/share/lua/5.2/?.lua]]

Simply add that line to the top of your Lua script before requiring anything.