The Universal Binary Installer
When I say "universal", I mean it downloads binaries from GitHub or GitLab releases.
When I say "binary", I mean it handles single-file executables like those created by most Go and Rust projects.
When I say "installer", I mean it plops the binary wherever you tell it to.
And finally, when I say "UBI", I don't mean "universal basic income", but that'd be nice too.
If you want to manage per-project tooling, I strongly recommend using
mise instead of ubi. But if you just want a simple tool for globally
installing tools like ripgrep or
go-grip, then ubi is a good choice.
[dependencies]
ubi = "x.y.z"See the ubi docs on docs.rs for more details.
You can install the CLI tool by hand by downloading the latest release from the releases page.
There are also bootstrap installer scripts that provide a half-assed implementation of ubi:
curl --silent --location \
https://raw.githubusercontent.com/houseabsolute/ubi/master/bootstrap/bootstrap-ubi.sh |
shIf you run this as a non-root user, it will install ubi into $HOME/bin. If run as root it
installs it into /usr/local/bin.
The bootstrap script supports several environment variables as parameters.
| Variable | Description |
|---|---|
TARGET |
The directory in which to install ubi. Defaults to $HOME/bin for non-root users and /usr/local/bin for root. |
TAG |
The ubi version tag to download. Defaults to the latest release. |
FILENAME |
The name of the release file asset to download. This skips the platform detection and just downloads the file with this name. Use this if the bootstrap script fails to detect your platform (but please consider submitting a PR to fix the detection). |
GITHUB_TOKEN |
The GitHub API token to use when downloading releases. This is only necessary for private repos or if you are hitting the GitHub API anonymous usage limits. Hitting these limits is mostly likely to happen when you're running the bootstrap script repeatedly in CI. |
To set these variables, you can either set them in the environment before running the script, or you
can set them on the command line. Note that you need to set them on the right side of the pipe.
For example, to install a specific version of ubi using the TAG env var:
curl --silent --location \
https://raw.githubusercontent.com/houseabsolute/ubi/master/bootstrap/bootstrap-ubi.sh |
TAG=v0.0.15 shNote for GitHub Enterprise: If you are running this script from an Action in a GitHub Enterprise
installation, the GITHUB_TOKEN environment variable will be for that GH Enterprise setup. You will
need to create a separate token for github.com, and explicitly pass that as your GITHUB_TOKEN.
powershell -exec bypass -c "Invoke-WebRequest -URI 'https://raw.githubusercontent.com/houseabsolute/ubi/master/bootstrap/bootstrap-ubi.ps1' -UseBasicParsing | Invoke-Expression"You can run this from a command or the Powershell command line. This will install ubi.exe into the
current directory.
The ubi CLI tool takes the following command line flags:
| Key | Env Var | Type | Required? | Description |
|---|---|---|---|---|
-p, --project |
UBI_PROJECT |
string | no (but you must pass this or --url) |
The project you want to install, like houseabsolute/precious or https://github.com/houseabsolute/precious. You cannot pass this with the --url flag. |
-t, --tag |
UBI_TAG |
string | no | The tag to download. Defaults to the latest release. This is only valid if you also pass --project. |
-u, --url |
UBI_URL |
string | no (but you must pass this or --project) |
The url of the file to download. This can be provided instead of a project or tag. This will not use the forge site's API, so you will never hit its API limits. With this parameter, you do not need to set a token env var except for private repos. You cannot pass --project or --tag with this flag. |
-i, --in |
UBI_IN |
string | no | The directory in which the binary should be placed. Defaults to ./bin. |
-e, --exe |
UBI_EXE |
string | no | The name of the file to look for in an archive file, or the name of the downloadable file excluding its extension, e.g. ubi.gz. By default this is the same as the project name, so for houseabsolute/precious we look for precious or precious.exe. When running on Windows the .exe suffix will be added, as needed. You cannot pass --extract-all when this is set. |
-m, --matching |
UBI_MATCHING |
string | no | A string that will be matched against the release filename when there are multiple matching files for your OS/arch. For example, there may be multiple releases for an OS/arch that differ by compiler (MSVC vs. gcc) or linked libc (glibc vs. musl). Note that this will be ignored if there is only one matching release filename for your OS/arch. |
-r, --matching-regex |
UBI_MATCHING_REGEX |
string | no | A regular expression string that will be matched against release filenames before matching against your OS/arch. If the pattern yields a single match, that release will be selected. If no matches are found, this will result in an error. |
--min-age-days |
UBI_MIN_AGE_DAYS |
positive integer | no | Minimum age in days for releases. Only releases at least this many days old will be installed. This is useful for mitigating supply chain attacks. It's especially useful for projects that use GitHub's immutable releases feature. You cannot pass this with --tag or --url. |
--rename-exe |
UBI_RENAME_EXE |
string | no | The name to use for the executable after it is unpacked. By default this is the same as the name of the file passed for the --exe flag. If that flag isn't passed, this is the same as the name of the project. Note that when set, this name is used as-is, so on Windows, .exe will not be appended to the name given. You cannot pass --extract-all when this is set. |
--extract-all |
UBI_EXTRACT_ALL |
boolean | no | Pass this to tell ubi to extract all files from the archive. By default ubi will only extract |
No open issues yet, or sync has not completed.