Reputation: 6247
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.
Upvotes: 9
Views: 43639
Reputation: 4422
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.
Upvotes: 27
Reputation: 6247
I add following method into the /opt/zbsstudio/lualibs/mobdebug/mobdebug.lua
file.
package.path = package.path .. ';my_path/?/init.lua'
package.cpath = package.cpath .. ';my_path/?.so'
But I'm not sure that's the best way.
Upvotes: -3
Reputation: 26774
You can set LUA_PATH
and LUA_CPATH
before starting ZeroBrane Studio and it should pass those values to all the projects you run or debug from the IDE.
Upvotes: 0