aboutsummaryrefslogtreecommitdiff
path: root/docs/namespaces.md
diff options
context:
space:
mode:
Diffstat (limited to 'docs/namespaces.md')
-rw-r--r--docs/namespaces.md71
1 files changed, 71 insertions, 0 deletions
diff --git a/docs/namespaces.md b/docs/namespaces.md
new file mode 100644
index 00000000..f00c692a
--- /dev/null
+++ b/docs/namespaces.md
@@ -0,0 +1,71 @@
1# Namespaces
2
3The LuaRocks.org repository allows for each user to published their own
4collection of rocks. Since LuaRocks 3, this concept of per-user rocks has been
5integrated into the tool, in the form of **namespaces**.
6
7What you can do with namespaces:
8
9* Install packages using a namespace:
10 * `luarocks install my_user/my_rock`
11* Depend on a specific namespaced version of a rock in your rockspec:
12 * `dependencies = { "my_user/my_rock > 2.0" }`
13
14## Background
15
16LuaRocks has always supported multiple repositories, which can be set in the
17[config file](config_file_format.md) with the `rocks_servers` entry. A
18repository is an address (a local directory or a remote URL) where LuaRocks
19can find a `manifest-5.x` file and .rock and .rockspec files. We also call
20such repository a "manifest", for short.
21
22The [LuaRocks.org](LuaRocks.org)(LuaRocks.org)(https://luarocks.org) website
23features a root manifest at `https://luarocks.org` as well as per-user
24manifests at `https://luarocks.org/manifests/<your-user-name>`. Entries in the
25root manifest are operated in a first-come first-served manner, but even if
26someone else has already taken a rock name, you can upload your own version of
27it to your user manifest. You can refer to a per-user manifest the same way as
28any other rocks server, adding to your configuration or using it with the
29`--server` flag. This means that you were always able to install your own
30version of a rock using a command such as `luarocks install <my-rock>
31--server=https://luarocks.org/manifests/<your-user-name>`. However, you could
32not specifically depend on it from another rockspec, and once installed, the
33information that this rock came from a specific manifest was lost. With
34namespaces, now you can!
35
36## Using namespaces
37
38All `luarocks` commands that accept a rock name as command line argument can
39now take a namespaced variant:
40
41```
42luarocks install my_user/my_rock
43```
44
45LuaRocks will take your `rocks_trees` configuration and search for namespaced
46manifests on each entry: for example, given the default server
47`https://luarocks.org` it will look in
48`https://luarocks.org/manifests/my_user`.
49
50When installing, LuaRocks will internally store the information that this copy
51of `my_rock` came from the `my_user` namespace, so it will be able to use that
52information when another rockspec specifically asks for `my_user/my_rock` in
53its dependencies. (The namespace information is stored in a separate
54`rock_namespace` metadata file, at
55`lib/luarocks/rocks-5.x/my_rock/1.0-1/rock_namespace`, relative to your local
56rocks tree.)
57
58## Compatibility between non-namespaced and namespaced rocks
59
60A namespaced package can stand for a non-namespaced one. If you have
61`my_user/my_rock 1.0` installed and a rock depends on `my_rock 1.0`, the
62installed rock will satisfy the dependency.
63
64The opposite is not true: if you have `my_rock 1.0` installed but that did not
65come from a `my_user` namespace, it will not satisfy a dependency for
66`my_user/my_rock`.
67
68## Current limitations
69
70You cannot have two rocks with the same name and version but different
71namespaces installed at the same time in the same local rocks tree.