Reputation: 2764
In NodeJS/NPM, you can create a package.json
and run npm install
to install all your dependencies in a folder within your project: ./node_modules
. (A project can be an app or another module/package.)
Ruby also has a "bundler" system (using a .bundle file) that keeps track of gems specific to a dir (ie project).
Does LuaRocks have similar conventions? Or is it recommeneded to install everything to /usr
or $HOME
?
So far I've been able to get similiar functionality, but I have to create a custom LuaRocks config file and specify --tree=my_local_lua_rocks_dir
every time I want to install a rock. Granted, I can always create a bash script. The point is that it seems I'm going against a convention.
Upvotes: 4
Views: 1115
Reputation: 6798
It is possible to install rocks into a directory under the current directory, using the --tree
flag:
luarocks install --tree ./lua_modules lpeg
And then you have to configure your package.path
and package.cpath
variables in Lua (settable via LUA_PATH
and LUA_CPATH
environment variables) so it finds the modules installed inside it. There are several ways to do this conveniently: this tutorial explains how to do it, with more examples.
Upvotes: 5
Reputation: 2764
Instead of using Vert, I've decided to just edit the LuaRocks config file:
In /etc/luarocks/config.lua
:
rocks_servers = {
[[http://rocks.moonscript.org/]],
[[http://luarocks.org/repositories/rocks]]
}
rocks_trees = {
[[/usr/local]],
[[./my_dir]]
}
./my_dir
is relative to the pwd
you're in, not to the location of the config file. Of course, change my_dir
to whatever you want.
"The order of the rock_trees
matters: When installing rocks, LuaRocks tries to pick a location to store the rock starting from the bottom of the list; when loading rocks in runtime, LuaRocks scans from the top of the list." From: http://luarocks.org/en/Config_file_format
Then in your .bashrc
:
eval `luarocks path`
export PATH=$PATH:my_dir/bin
However, for certain commands you now have to specify the tree or it will give you a confusing error:
luarocks make --tree=my_dir
Upvotes: 1