> ## Documentation Index
> Fetch the complete documentation index at: https://docs.crewship.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# upgrade

> Update crewship to the latest version

The `upgrade` command downloads and installs the latest version of the crewship CLI.

## Usage

```bash theme={null}
crewship upgrade [options]
```

## Options

| Option        | Description                                       |
| ------------- | ------------------------------------------------- |
| `-f, --force` | Force reinstall even if already on latest version |
| `-h, --help`  | Show help message                                 |

## How It Works

The upgrade process:

1. **Check for updates** - Fetches the latest version information from the Crewship API
2. **Download** - Downloads the binary for your platform
3. **Verify** - Validates the SHA256 checksum to ensure integrity
4. **Backup** - Creates a backup of the current binary
5. **Install** - Replaces the current binary with the new version
6. **Cleanup** - Removes the backup after successful installation

If anything goes wrong during installation, the original binary is automatically restored.

## Examples

### Check for and Install Updates

```bash theme={null}
crewship upgrade
```

Output when an update is available:

```
Checking for updates...
New version available: 0.2.0 (current: 0.1.0)
Downloading crewship 0.2.0 for darwin-arm64...
Verifying checksum...
Checksum verified.
Installing update...

Successfully upgraded to crewship 0.2.0!
```

Output when already up to date:

```
Checking for updates...
You are already running the latest version (0.2.0).
```

### Force Reinstall

Reinstall the latest version even if already up to date (useful for repairing a corrupted installation):

```bash theme={null}
crewship upgrade --force
```

## Automatic Update Notifications

Crewship automatically checks for updates once per day when you run any command. If a new version is available, you'll see a notification:

```
┌───────────────────────────────────────────────────────────┐
│  A new version of crewship is available: 0.2.0           │
│  You are currently running: 0.1.0                        │
│                                                           │
│  Run crewship upgrade to update                          │
└───────────────────────────────────────────────────────────┘
```

This check is non-blocking and won't slow down your commands. The notification only appears once per new version.

## Security

* **Checksum verification** - All downloads are verified against SHA256 checksums
* **HTTPS** - All downloads use HTTPS encryption
* **Atomic updates** - The update either completes fully or rolls back

## Troubleshooting

### Permission Denied

If you get a permission error, the CLI may have been installed with elevated privileges:

```bash theme={null}
sudo crewship upgrade
```

Or reinstall to a user-writable location:

```bash theme={null}
curl -fsSL https://www.crewship.dev/install.sh | bash
```

### Manual Update

If automatic upgrade fails, download manually:

<Tabs>
  <Tab title="macOS / Linux">
    ```bash theme={null}
    # macOS (Apple Silicon)
    curl -fsSL "https://api.crewship.dev/cli/releases/latest/download?platform=darwin-arm64" -o crewship
    chmod +x crewship
    mv crewship ~/.local/bin/

    # macOS (Intel)
    curl -fsSL "https://api.crewship.dev/cli/releases/latest/download?platform=darwin-x64" -o crewship
    chmod +x crewship
    mv crewship ~/.local/bin/

    # Linux
    curl -fsSL "https://api.crewship.dev/cli/releases/latest/download?platform=linux-x64" -o crewship
    chmod +x crewship
    mv crewship ~/.local/bin/
    ```
  </Tab>

  <Tab title="Windows">
    ```powershell theme={null}
    Invoke-WebRequest -Uri "https://api.crewship.dev/cli/releases/latest/download?platform=windows-x64" -OutFile "$env:LOCALAPPDATA\Programs\crewship.exe"
    ```
  </Tab>
</Tabs>
