LuaRocks Repository
Cloudsmith provides public & private repositories for Lua Modules
LuaRocks is the package manager for Lua modules. It allows you to create and install Lua modules as self-contained packages called rocks. Cloudsmith is proud to support fully-featured repositories for managing your own private and public Lua rocks.
For more information on Lua, please see:
In the following examples:
Identifier | Description |
---|---|
OWNER | Your Cloudsmith account name or organization name (namespace) |
REPOSITORY | Your Cloudsmith Repository name (also called "slug") |
TOKEN | Your Cloudsmith Entitlement Token (see Entitlements for more details) |
USERNAME | Your Cloudsmith username |
PASSWORD | Your Cloudsmith password |
API-KEY | Your Cloudsmith API Key |
MODULE_NAME | The name of your Lua Module |
MODULE_VERSION | The version number of your Lua Module |
Upload a Module
To upload, you need to generate a module first (rockspec, source and binary can all be uploaded). You can do this with the luarocks CLI:
luarocks pack {<rockspec> | <name> [<version>]}
This generates a .rock
file like MODULE_NAME-MODULE_VERSION.src.rock
that you can upload. It is also possible to upload a .rockspec
file directly, without packing. In this case, luarocks will pull the sources from the upstream location and build a package automatically at install time.
Please see the official LuaRocks documentation for more information on building your own rocks.
The
luarocks upload
command currently only supports uploading modules to the official public rocks repository. To upload your modules to Cloudsmith, you can use the Web UI, the Cloudsmith CLI or the Cloudsmith API.
Upload via the Cloudsmith CLI
For full details of how to install and setup the Cloudsmith CLI, see Command Line Interface.
The command to upload a Lua module via the Cloudsmith CLI is:
cloudsmith push luarocks OWNER/REPOSITORY MODULE_NAME-MODULE_VERSION.src.rock
Example:
cloudsmith push luarocks org/repo your-module-1.0.0-1.src.rock
Upload via Cloudsmith Website
Please see Upload a Package for details of how to upload via the Website UI.
Example Project
For examples of what your project should look like for packaging and publishing/uploading, please have a look at our examples repository (on GitHub).
Download / Install a Module
You can install modules directly by using the --server
command-line flag when executing a luarocks command.
Public Repositories
luarocks install MODULE_NAME MODULE_VERSION --server https://dl.cloudsmith.io/public/OWNER/REPOSITORY/luarocks/
Private Repositories
NOTE
Private Cloudsmith repositories require authentication. You can choose between two types of authentication, Entitlement Token Authentication or HTTP Basic Authentication.
The install command will differ depending on what authentication type you choose to use.
Entitlement Tokens, User Credentials and API-Keys should be treated as secrets, and you should ensure that you do not commit them in configurations files along with source code or expose them in any logs
luarocks install MODULE_NAME MODULE_VERSION --server https://dl.cloudsmith.io/TOKEN/OWNER/REPOSITORY/luarocks/
luarocks install MODULE_NAME MODULE_VERSION --server https://USERNAME:[email protected]/basic/OWNER/REPOSITORY/luarocks/
luarocks install MODULE_NAME MODULE_VERSION --server https://USERNAME:[email protected]/basic/OWNER/REPOSITORY/luarocks/
luarocks install MODULE_NAME MODULE_VERSION --server https://token:[email protected]/basic/OWNER/REPOSITORY/luarocks/
To search only your Cloudsmith repository for modules use the
--only-server
command-line flag. This will force luarocks to search only the Cloudsmith repository and will result in luarocks not being able to install public modules that your private module may depend on.
For most use cases, users will probably want to persist their repository settings and not specify them every time. luarocks provides a configuration file that can be modified to persist settings, see the luarocks config file documentation for full details of available options and the location of the file for your platform.
To add your private repository, adjust the rocks_servers
section of your config file.
Note - if you still want to be able to install packages from luarocks.org you should leave the default value in place and add your repository, otherwise you can replace the value entirely:
Public Repositories
rocks_servers = {
"http://luarocks.org/repositories/rocks",
"https://dl.cloudsmith.io/public/OWNER/REPOSITORY/luarocks/"
}
Private Repositories
rocks_servers = {
"http://luarocks.org/repositories/rocks",
"https://dl.cloudsmith.io/TOKEN/OWNER/REPOSITORY/luarocks/"
}
rocks_servers = {
"http://luarocks.org/repositories/rocks",
"https://USERNAME:[email protected]/basic/OWNER/REPOSITORY/luarocks/"
}
rocks_servers = {
"http://luarocks.org/repositories/rocks",
"https://USERNAME:[email protected]/basic/OWNER/REPOSITORY/luarocks/"
}
rocks_servers = {
"http://luarocks.org/repositories/rocks",
"https://token:[email protected]/basic/OWNER/REPOSITORY/luarocks/"
}
Upstream Proxying / Caching
Not Supported
Troubleshooting
Please see the Troubleshooting page for further help and information.
Updated 5 months ago