I want to add a module path for all of my project in zerobrane. I add following code into the user.lua.
LUA_PATH=LUA_PATH .. ';mypath' or
package.path=package.path .. ';mypath'
It can't work. how can I do it ?
PS
I don't want to set the package.path at the begin of all the project.
When Lua starts, it initialises package.path
and package.cpath
with values of LUA_PATH
and LUA_CPATH
environment variables. Setting up these environment variables will be one clean way to set paths. Appending LUA_PATH
's value with a double semi-colon will make Lua append the default path to the specified path.
Using bash on Linux, you can set the paths by adding these lines to the end of ~/.bashrc
file. For example:
## final ;; ensure that default path will be appended by Lua
export LUA_PATH="<path-to-add>;;"
export LUA_CPATH="./?.so;/usr/local/lib/lua/5.3/?.so;
/usr/local/share/lua/5.3/?.so;<path-to-add>"
Hope it helps.