# Installation

There are several ways to use **Kyso CLI** in your machine, depending on your operating system, your needs and your preferences.

## NPM & YARN

The easiest way to use kyso cli is throught NPM or YARN

The **Kyso CLI** can be installed as a NPM or YARN global package easily, by just launching one of the commands below:

```
npm install -g kyso

or

yarn global add kyso
```

{% hint style="info" %}
Depending on your local configuration, you might need to use **sudo or launch the windows terminal with administrative rights.** If that's the case, it's preferrable to review your configuration, but if you are in a hurry you can use **sudo** 😉
{% endhint %}

Once installed, check that it's available executing this command:

```
$ kyso
Kyso Client

VERSION
  kyso/1.6.0 linux-x64 node-v18.6.0

USAGE
  $ kyso [COMMAND]

TOPICS
  plugins  List installed plugins.

COMMANDS
  clone              Clone a report from Kyso
  help               Display help for kyso.
  import-repository  Import repository to Kyso
  init               Interactivel build a kyso.yaml file
  kyso-command
  login              Login into Kyso
  open               Open a report in the browser
  plugins            List installed plugins.
  pull               Pull repository from Kyso
  push               Upload local repository to Kyso
  whoami             Current logged user and platform

```

## NPX

Since npm version 5.2.0 you can use npx instead of an npm global install. The difference between npm and npx is that npx doesn't install anything globally on your computer, but just downloads the dependency, executes it and then deletes it, keeping your local node\_modules smaller.

To use NPX just execute this command:

```
$ npx kyso
Need to install the following packages:
  kyso@1.6.0
Ok to proceed? (y) y
Kyso Client

VERSION
  kyso/1.6.0 linux-x64 node-v18.6.0

USAGE
  $ kyso [COMMAND]

TOPICS
  plugins  List installed plugins.

COMMANDS
  clone              Clone a report from Kyso
  help               Display help for kyso.
  import-repository  Import repository to Kyso
  init               Interactivel build a kyso.yaml file
  kyso-command
  login              Login into Kyso
  open               Open a report in the browser
  plugins            List installed plugins.
  pull               Pull repository from Kyso
  push               Upload local repository to Kyso
  whoami             Current logged user and platform
  
```

## Windows Installers

Visit [https://cli.kyso.io](https://cli.kyso.io/) to download the installers. Download the installer that fits with your architecture and execute it.

Keep all the options selected for a better experience!

![Installer components selection](https://4003540104-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LjzfPqQ1fXmC4OMXwiD%2Fuploads%2Frl7CbcEajCWWunYWNy5C%2Fimage.png?alt=media\&token=9e221528-41fb-4b69-8762-f210a617c094)

Select the destination folder and select 'Install':

![Installer location selection](https://4003540104-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LjzfPqQ1fXmC4OMXwiD%2Fuploads%2FCB3wPqdlwVgl0rnvechQ%2Fimage.png?alt=media\&token=1080005c-5187-4875-b596-af5f7c64366c)

![Installer installing ;)](https://4003540104-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LjzfPqQ1fXmC4OMXwiD%2Fuploads%2Fyq6d5KAIX4Egwmd3DNUl%2Fimage.png?alt=media\&token=5524dac2-fc00-44e1-a41b-044efa9e24db)

Once the installation is completed, select the 'Close' button, open your terminal and write the following command:

```
kyso
```

![kyso command running](https://4003540104-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LjzfPqQ1fXmC4OMXwiD%2Fuploads%2FkTRwPGM0bXIguEUxEQG8%2Fimage.png?alt=media\&token=b7c06bd7-baa4-4951-9122-b02be46474c1)

## Tarballs

Visit [https://cli.kyso.io](https://cli.kyso.io/) to download the installers.

Download the tarball that fits with your operating system and your architecture, extract it in your preferred destination and add it to the PATH of your system.

Add the destination folder, plus bin, into the PATH of your system. For example, if your destination folder is `C:\Users\your_user\kyso`*, then* add `C:\Users\your_user\kyso\bin` to the PATH of your system

### Adding kyso to the system path in Windows

Type into the search bar **edit environment variables** and choose the suggested result. That should open the following window:

![System settings window](https://4003540104-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LjzfPqQ1fXmC4OMXwiD%2Fuploads%2Fe8f5SbPQ7ut5GIptkeAy%2Fimage.png?alt=media\&token=c4e58c67-c3bc-4462-904e-29d77bac33b9)

Click on **Environment Variables**

![Environment variables window](https://4003540104-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LjzfPqQ1fXmC4OMXwiD%2Fuploads%2FVKKTRxUqeRkLK3st8w6I%2Fimage.png?alt=media\&token=cb756408-a5e3-4783-a860-02373be211b8)

Select the **Path** variable of your user, and click **Edit.**

![Edit path environment variable](https://4003540104-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LjzfPqQ1fXmC4OMXwiD%2Fuploads%2FWOk5fzz5nvKHOQ4fKlBH%2Fimage.png?alt=media\&token=bdfe5744-2cc9-4ed9-a2b8-26585af86741)

Click on **New** and type the full path in which kyso was unzipped, pointing to the **bin** directory. For example, if kyso is located at `C:\Users\Usuario\Downloads\kyso-v1.3.1-9b24ecb-win32-x64`, then the value you should put is `C:\Users\Usuario\Downloads\kyso-v1.3.1-9b24ecb-win32-x64`**`\bin`**

![Added path](https://4003540104-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LjzfPqQ1fXmC4OMXwiD%2Fuploads%2FDjsj3gpjqokiqXF9Y5zE%2Fimage.png?alt=media\&token=f917f650-3e06-4416-8eae-bf4d390406ff)

Open a terminal and type the command **kyso to check that the installation was completed succesfully:**

![](https://4003540104-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LjzfPqQ1fXmC4OMXwiD%2Fuploads%2F9VaaVrUuuzTMCZ4Crit7%2Fimage.png?alt=media\&token=7ef1ec3f-91ee-4ad8-a647-39a98b4e66b1)

### Adding kyso to the system path in MacOS **and Linux**

#### Using zsh terminal

Open a ZSH terminal and edit the file `~/.zshrc` to edit the `PATH` variable. Type the full path in which `kyso` was unzipped, pointing to the `bin` directory. For example, if `kyso` is located at `/home/user/kyso-v1.3.1-9b24ecb-linux-x64`, then the value you should put is `/home/user/kyso-v1.3.1-9b24ecb-linux-x64/bin`

```
export PATH="/home/user/kyso-v1.3.1-9b24ecb-linux-x64/bin:$PATH"
```

Check that it's effectively added by executing:

```
cat ~/.zshrc
export PATH="/home/user/kyso-v1.3.1-9b24ecb-linux-x64/bin:$PATH"
```

Open a terminal and type the command `kyso` to check that the installation was completed succesfully

#### Using bash terminal

Open a BASH terminal and edit the file `~/.bashrc` to edit the `PATH` variable. Type the full path in which `kyso` was unzipped, pointing to the `bin` directory. For example, if `kyso` is located at `/home/user/kyso-v1.3.1-9b24ecb-linux-x64`, then the value you should put is `/home/user/kyso-v1.3.1-9b24ecb-linux-x64/bin`

```
export PATH="/home/user/kyso-v1.3.1-9b24ecb-linux-x64/bin:$PATH"
```

Check that it's effectively added by executing:

```
cat ~/.bashrc
export PATH="/home/user/kyso-v1.3.1-9b24ecb-linux-x64/bin:$PATH"
```

Open a terminal and type the command `kyso` to check that the installation was completed succesfully

## **Docker**

If you don't want to install the client you can also run it using a docker container, the image is available as `kyso/kyso`, to download the latest version of the image execute:

```
$ docker pull kyso/kyso
```

While the container was created mainly to be used in CI/CD systems the following script can be used on **Linux** or **MacOS** to run the `kyso` client as if it were installed on the HOST machine (see the [limitations](#limitations) below):

```shell
#!/bin/sh
set -e
docker run --rm -ti -v "$HOME:$HOME" -e "HOME=$HOME" -w "$(pwd)" \
  -u "$(id -u):$(id -g)" --name kyso kyso/kyso kyso "$@"
```

To run the client do the following:

```
$ ./kyso.sh
Kyso Client

VERSION
  kyso/1.8.0 linux-x64 node-v16.16.0

USAGE
  $ kyso [COMMAND]

TOPICS
  plugins  List installed plugins.

COMMANDS
  clone              Clone a report from Kyso
  format             Format your current report files to add new great features
  help               Display help for kyso.
  import-repository  Import repository to Kyso
  init               Interactivel build a kyso.yaml file
  kyso-command
  login              Login into Kyso
  open               Open a report in the browser
  plugins            List installed plugins.
  pull               Pull repository from Kyso
  push               Upload local repository to Kyso
  whoami             Current logged user and platform
 
```

### Limitations

1. The client executed with the previous script works fine as long as the working directory is under the user's `HOME` directory when it is executed; if that is not the case the directory is going to be the internal version of the `PATH` inside the container, not the host.
2. If the `COMMAND` called needs to launch programs from the `HOST` system it will fail, as we are running inside a container. Currently the commands that fail are `open` and the `login` command when used with a provider that uses the browser (like **Google** or **GitHub**).
