how to set the LUA_PATH and LUA_CPATH for the zerobrane studio in linux

Samuel picture Samuel · Oct 19, 2014 · Viewed 26.8k times · Source

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.

Answer

bytefire picture bytefire · Jul 25, 2015

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.