# gpm version

Display version information for the GPM CLI.

## Usage

```bash
gpm version [flags]
```

## Flags

| Flag     | Description                   | Default |
| -------- | ----------------------------- | ------- |
| `--json` | Output results in JSON format | `false` |

## Description

The `gpm version` command displays comprehensive version information for the GPM CLI, including version number, build details, and system information.

### Information Displayed

* **Version**: GPM CLI version number
* **Commit**: Git commit hash
* **Built**: Build timestamp
* **Go Version**: Go version used for build
* **Platform**: Operating system and architecture

## Examples

### Basic Usage

```bash
# Show version information
gpm version

# Show version in JSON format
gpm version --json
```

## Output

### Human Format (Default)

```
GPM CLI
─────────────────────────────────────────
Version: v0.1.0-alpha.7-dirty
Commit: 754da3a
Built: 2025-09-14_09:39:23
Go Version: go1.25.0
Platform: darwin/arm64
─────────────────────────────────────────
```

### JSON Format (`--json`)

```json
{
  "version": "v0.1.0-alpha.7-dirty",
  "commit": "754da3a",
  "built": "2025-09-14_09:39:23",
  "go_version": "go1.25.0",
  "platform": "darwin/arm64",
  "arch": "arm64",
  "os": "darwin"
}
```

## Version Information

### Version Number

The version number follows semantic versioning:

* **Format**: `v<major>.<minor>.<patch>[-<prerelease>][-<build>]`
* **Examples**: `v1.0.0`, `v1.0.0-alpha.1`, `v1.0.0-beta.2-dirty`

### Build Information

* **Commit**: Git commit hash used for build
* **Built**: Timestamp when CLI was built
* **Go Version**: Go version used for compilation
* **Platform**: Operating system and architecture

## Use Cases

### Version Checking

```bash
# Check GPM version
gpm version

# Verify minimum version
gpm version --json | jq '.version'
```

### System Information

```bash
# Get system information
gpm version --json | jq '.platform'

# Check Go version
gpm version --json | jq '.go_version'
```

### CI/CD Integration

```bash
# Check version in CI
gpm version --json > version-info.json

# Verify version compatibility
gpm version --json | jq '.version | startswith("v1.")'
```

## Version Comparison

### Semantic Versioning

GPM uses semantic versioning for version numbers:

* **Major**: Breaking changes
* **Minor**: New features (backward compatible)
* **Patch**: Bug fixes (backward compatible)
* **Prerelease**: Alpha, beta, or release candidate versions

### Version Examples

```bash
# Stable release
gpm version
# Version: v1.0.0

# Alpha release
gpm version
# Version: v1.1.0-alpha.1

# Beta release
gpm version
# Version: v1.1.0-beta.2

# Development build
gpm version
# Version: v1.1.0-dirty
```

## Platform Information

### Supported Platforms

GPM supports multiple platforms:

* **macOS**: `darwin/amd64`, `darwin/arm64`
* **Linux**: `linux/amd64`, `linux/arm64`
* **Windows**: `windows/amd64`, `windows/arm64`

### Platform Detection

```bash
# Check current platform
gpm version --json | jq '.platform'

# Check architecture
gpm version --json | jq '.arch'

# Check operating system
gpm version --json | jq '.os'
```

## Build Information

### Build Details

* **Commit Hash**: Git commit used for build
* **Build Timestamp**: When the CLI was compiled
* **Go Version**: Go compiler version
* **Build Flags**: Compilation flags used

### Build Examples

```bash
# Development build
gpm version
# Commit: 754da3a
# Built: 2025-09-14_09:39:23

# Release build
gpm version
# Commit: a1b2c3d
# Built: 2025-09-14_10:00:00
```

## Error Handling

### Common Scenarios

* **Version information unavailable**: Build information missing
* **JSON parsing error**: Invalid JSON output
* **Platform detection error**: Unsupported platform

### Troubleshooting

1. **Version information missing**: Rebuild CLI with proper build flags
2. **JSON parsing error**: Check CLI installation and integrity
3. **Platform detection error**: Verify platform compatibility

## Best Practices

### Version Checking

```bash
# Always check version before reporting issues
gpm version

# Include version in bug reports
gpm version --json > version-info.json
```

### Compatibility

```bash
# Check version compatibility
gpm version --json | jq '.version | startswith("v1.")'

# Verify minimum version
gpm version --json | jq '.version | split(".") | .[0] | tonumber'
```

### Documentation

```bash
# Document version in scripts
VERSION=$(gpm version --json | jq -r '.version')
echo "Using GPM version: $VERSION"
```

## Related Commands

* [`gpm whoami`](/cli-reference/cli/authentication/whoami.md) - User information
* [`gpm config`](/cli-reference/cli/configuration/config.md) - Configuration settings
* [`gpm search`](/cli-reference/cli/registry/search.md) - Package search

## See Also

* [CLI Reference](/cli-reference/cli.md) - Complete command documentation
* [Installation](/getting-started/getting-started/installation.md) - Installation guide
* [Troubleshooting](https://github.com/gpm-sh/docs/blob/main/troubleshooting/README.md) - Common issues and solutions


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.gpm.sh/cli-reference/cli/utilities/version.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
