2020-10-20 21:11:17 +00:00
# balena CLI Advanced Installation Options
2020-09-16 13:53:46 +00:00
**These are alternative, advanced installation options. Most users would prefer the [recommended,
streamlined installation
instructions](https://github.com/balena-io/balena-cli/blob/master/INSTALL.md).**
There are 3 options to choose from to install balena's CLI:
* [Executable Installer ](#executable-installer ): the easiest method on Windows and macOS, using the
traditional graphical desktop application installers.
2020-10-20 21:11:17 +00:00
* [Standalone Zip Package ](#standalone-zip-package ): these are plain zip files with the balena CLI
2020-09-16 13:53:46 +00:00
executable in them: extract and run. Available for all platforms: Linux, Windows, macOS.
Recommended also for scripted installation in CI (continuous integration) environments.
* [NPM Installation ](#npm-installation ): recommended for Node.js developers who may be interested
2020-10-20 21:11:17 +00:00
in integrating the balena CLI in their existing projects or workflow.
2020-09-16 13:53:46 +00:00
Some specific CLI commands have a few extra installation steps: see section [Additional
Dependencies](#additional-dependencies).
## Executable Installer
This is the recommended installation option on macOS and Windows. Follow the specific OS
instructions:
* [Windows ](./INSTALL-WINDOWS.md )
* [macOS ](./INSTALL-MAC.md )
> Note regarding WSL ([Windows Subsystem for
> Linux](https://docs.microsoft.com/en-us/windows/wsl/about))
> If you would like to use WSL, follow the [installations instructions for
> Linux](./INSTALL-LINUX.md) rather than Windows, as WSL consists of a Linux environment.
If you had previously installed the CLI using a standalone zip package, it may be a good idea to
check your system's `PATH` environment variable for duplicate entries, as the terminal will use the
entry that comes first. Check the [Standalone Zip Package ](#standalone-zip-package ) instructions
for how to modify the PATH variable.
By default, the CLI is installed to the following folders:
OS | Folders
--- | ---
Windows: | `C:\Program Files\balena-cli\`
2024-08-22 16:03:37 +00:00
macOS: | `/usr/local/src/balena-cli/` < br > `/usr/local/bin/balena`
2020-09-16 13:53:46 +00:00
## Standalone Zip Package
1. Download the latest zip file from the [releases page ](https://github.com/balena-io/balena-cli/releases ).
Look for a file name that ends with the word "standalone", for example:
`balena-cli-vX.Y.Z-linux-x64-standalone.zip` ← _also for the Windows Subsystem for Linux_
`balena-cli-vX.Y.Z-macOS-x64-standalone.zip`
`balena-cli-vX.Y.Z-windows-x64-standalone.zip`
2. Extract the zip file contents to any folder you choose. The extracted contents will include a
`balena-cli` folder.
3. Add the `balena-cli` folder to the system's `PATH` environment variable.
See instructions for:
[Linux ](https://stackoverflow.com/questions/14637979/how-to-permanently-set-path-on-linux-unix ) |
[macOS ](https://www.architectryan.com/2012/10/02/add-to-the-path-on-mac-os-x-mountain-lion/#.Uydjga1dXDg ) |
[Windows ](https://www.computerhope.com/issues/ch000549.htm )
2020-11-14 22:23:41 +00:00
> * If you are using macOS 10.15 or later (Catalina, Big Sur), [check this known issue and
2021-04-07 15:53:36 +00:00
> workaround](https://github.com/balena-io/balena-cli/issues/2244).
2020-09-16 13:53:46 +00:00
> * **Linux Alpine** and **Busybox:** the standalone zip package is not currently compatible with
> these "compact" Linux distributions, because of the alternative C libraries they ship with.
> For these, consider the [NPM Installation](#npm-installation) option.
> * Note that moving the `balena` executable out of the extracted `balena-cli` folder on its own
> (e.g. moving it to `/usr/local/bin/balena`) will **not** work, as it depends on the other
> folders and files also present in the `balena-cli` folder.
To update the CLI to a new version, download a new release zip file and replace the previous
installation folder. To uninstall, simply delete the folder and edit the PATH environment variable
as described above.
## NPM Installation
2020-10-20 21:11:17 +00:00
If you are a Node.js developer, you may wish to install the balena CLI via [npm ](https://www.npmjs.com ).
2020-09-16 13:53:46 +00:00
The npm installation involves building native (platform-specific) binary modules, which require
2021-05-27 19:05:08 +00:00
some development tools to be installed first, as follows.
2024-04-16 10:01:04 +00:00
> **The balena CLI currently requires Node.js version ^20.6.0**
2024-01-17 11:43:14 +00:00
> **Versions 21 and later are not yet fully supported.**
2021-05-27 19:05:08 +00:00
### Install development tools
#### **Linux or WSL** (Windows Subsystem for Linux)
```sh
$ sudo apt-get update & & sudo apt-get -y install curl python3 git make g++
$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
$ . ~/.bashrc
2024-01-17 11:43:14 +00:00
$ nvm install 20
2021-05-27 19:05:08 +00:00
```
The `curl` command line above uses
[nvm ](https://github.com/nvm-sh/nvm/blob/master/README.md#install--update-script ) to install
Node.js, instead of using `apt-get` . Installing Node.js through `apt-get` is a common source of
problems from permission errors to conflict with other system packages, and therefore not
recommended.
#### **macOS**
* Download and install Apple's Command Line Tools from https://developer.apple.com/downloads/
* Install Node.js through [nvm ](https://github.com/nvm-sh/nvm/blob/master/README.md#install--update-script ):
```sh
$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
$ . ~/.bashrc
2024-01-17 11:43:14 +00:00
$ nvm install 20
2021-05-27 19:05:08 +00:00
```
#### **Windows** (not WSL)
Install:
* If you'd like the ability to switch between Node.js versions, install
2024-01-17 11:43:14 +00:00
- Node.js v20 from the [Nodejs.org releases page ](https://nodejs.org/en/download/releases/ ).
2021-05-27 19:05:08 +00:00
[nvm-windows ](https://github.com/coreybutler/nvm-windows#node-version-manager-nvm-for-windows )
instead.
* The [MSYS2 shell ](https://www.msys2.org/ ), which provides `git` , `make` , `g++` and more:
2021-03-22 16:03:44 +00:00
* `pacman -S git gcc make openssh p7zip`
2020-09-16 13:53:46 +00:00
* [Set a Windows environment variable ](https://www.onmsft.com/how-to/how-to-set-an-environment-variable-in-windows-10 ): `MSYS2_PATH_TYPE=inherit`
* Note that a bug in the MSYS2 launch script (`msys2_shell.cmd`) makes text-based
interactive CLI menus to misbehave. [Check this Github issue for a
workaround](https://github.com/msys2/MINGW-packages/issues/1633#issuecomment-240583890).
* The Windows Driver Kit (WDK), which is needed to compile some native Node modules. It is **not**
necessary to install Visual Studio, only the WDK, which is "step 2" in the following guides:
2021-05-27 19:05:08 +00:00
* [WDK for Windows 10 ](https://docs.microsoft.com/en-us/windows-hardware/drivers/download-the-wdk#download-icon-step-2-install-refreshed-wdk-for-windows-10-version-2004 )
2020-09-16 13:53:46 +00:00
* [WDK for earlier versions of Windows ](https://docs.microsoft.com/en-us/windows-hardware/drivers/other-wdk-downloads#step-2-install-the-wdk )
2021-05-27 19:05:08 +00:00
* The [windows-build-tools ](https://www.npmjs.com/package/windows-build-tools ) npm package,
by running the following command on an [administrator
console](https://www.howtogeek.com/194041/how-to-open-the-command-prompt-as-administrator-in-windows-8.1/):
`npm install --global --production windows-build-tools`
### Install the balena CLI
2020-09-16 13:53:46 +00:00
2021-05-27 19:05:08 +00:00
After installing the development tools, install the balena CLI with:
2020-09-16 13:53:46 +00:00
```sh
2021-05-27 19:05:08 +00:00
$ npm install balena-cli --global --production --unsafe-perm
2020-09-16 13:53:46 +00:00
```
2021-05-27 19:05:08 +00:00
`--unsafe-perm` is needed when `npm install` is executed as the `root` user (e.g. in a Docker
container) in order to allow npm scripts like `postinstall` to be executed.
2020-09-16 13:53:46 +00:00
## Additional Dependencies
2024-09-26 15:26:19 +00:00
The `balena device ssh` , `device detect` , `build` , `deploy` and `preload` commands may require
2020-09-16 13:53:46 +00:00
additional software to be installed. Check the Additional Dependencies sections for each operating
system:
* [Windows ](./INSTALL-WINDOWS.md#additional-dependencies )
* [macOS ](./INSTALL-MAC.md#additional-dependencies )
* [Linux ](./INSTALL-LINUX.md#additional-dependencies )
2021-04-04 21:47:27 +00:00
Where Docker or balenaEngine are required, they may be installed on the local machine (where the
balena CLI is executed), on a remote server, or on a balenaOS device running a [balenaOS development
2021-05-27 19:05:08 +00:00
image](https://www.balena.io/docs/reference/OS/overview/2.x/#dev-vs-prod-images). Reasons why this
2020-09-16 13:53:46 +00:00
may be desirable include:
* To avoid having to install Docker on the development machine / laptop.
* To take advantage of a more powerful server (CPU, memory).
* To build or run images "natively" on an ARM device, avoiding the need for QEMU emulation.
To use a remote Docker Engine (daemon) or balenaEngine, specify the remote machine's IP address and
2021-04-04 21:47:27 +00:00
port number with the `--dockerHost` and `--dockerPort` command-line options. The `preload` command
has additional requirements because the bind mount feature is used. For more details, see
`balena help` for each command or the [online
2020-09-16 13:53:46 +00:00
reference](https://www.balena.io/docs/reference/cli/#cli-command-reference).