# Installation

Install the KeyEnv CLI on your machine.

Source: https://keyenv.dev/docs/getting-started/installation/

The KeyEnv CLI is available for macOS, Linux, and Windows.

## Quick Install (Recommended)

Install KeyEnv with a single command:

```bash
curl -fsSL https://keyenv.dev/install.sh | bash
```

This script automatically detects your operating system and architecture, downloads the correct binary, and installs it to `~/.keyenv/bin`.

### Install a Specific Version

```bash
curl -fsSL https://keyenv.dev/install.sh | bash -s -- v0.1.0
```

### Custom Install Location

```bash
KEYENV_INSTALL_DIR=/usr/local/bin curl -fsSL https://keyenv.dev/install.sh | bash
```

After installation, add KeyEnv to your PATH if prompted:

```bash
export PATH="$HOME/.keyenv/bin:$PATH"
```

Add this line to your `~/.bashrc`, `~/.zshrc`, or shell profile to make it permanent.

---

## Alternative Installation Methods

### Binary Download

Download pre-built binaries from [GitHub Releases](https://github.com/keyenv/keyenv/releases).

**macOS (Apple Silicon):**
```bash
curl -L https://github.com/keyenv/keyenv/releases/latest/download/keyenv-aarch64-apple-darwin.tar.gz | tar xz
sudo mv keyenv /usr/local/bin/
```

**macOS (Intel):**
```bash
curl -L https://github.com/keyenv/keyenv/releases/latest/download/keyenv-x86_64-apple-darwin.tar.gz | tar xz
sudo mv keyenv /usr/local/bin/
```

**Linux (x64):**
```bash
curl -L https://github.com/keyenv/keyenv/releases/latest/download/keyenv-x86_64-unknown-linux-gnu.tar.gz | tar xz
sudo mv keyenv /usr/local/bin/
```

**Linux (ARM64):**
```bash
curl -L https://github.com/keyenv/keyenv/releases/latest/download/keyenv-aarch64-unknown-linux-gnu.tar.gz | tar xz
sudo mv keyenv /usr/local/bin/
```

### Windows

Download `keyenv-x86_64-pc-windows-msvc.zip` from [GitHub Releases](https://github.com/keyenv/keyenv/releases), extract it, and add the folder to your PATH.

### Build from Source

Requires Rust 1.70+:

```bash
git clone https://github.com/keyenv/keyenv.git
cd keyenv/cli
cargo build --release
```

The binary will be at `target/release/keyenv`.

---

## Verify Installation

```bash
keyenv --version
```

You should see output like:

```
keyenv 0.1.0
```

## Troubleshooting

### "command not found" after installation

Make sure `~/.keyenv/bin` is in your PATH:

```bash
echo $PATH | grep -q ".keyenv" && echo "PATH is set" || echo "PATH not set"
```

Add to your shell profile:

```bash
echo 'export PATH="$HOME/.keyenv/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
```

### Permission denied

If using `/usr/local/bin`, you may need sudo:

```bash
sudo mv keyenv /usr/local/bin/
```

Or use the default install location (`~/.keyenv/bin`) which doesn't require sudo.

## Next Steps

Now that you have the CLI installed, [create your first project](/docs/getting-started/first-project).
