# envdiff

> Snapshots a machine's system info, runtimes, env vars and network config to JSON, diffs snapshots, and validates environments against a YAML file.

Stars: 25 · Language: Go · License: MIT · Categories: Dev Tools

- Repository: https://github.com/GBerghoff/envdiff
- Page: https://www.trmn.sh/tools/envdiff

## Install

- Go install: `go install github.com/GBerghoff/envdiff/cmd/envdiff@latest`
- Install script (Linux/macOS): `curl -fsSL https://raw.githubusercontent.com/GBerghoff/envdiff/main/install.sh | sh`

## Overview

envdiff is a Go command-line tool that captures an environment as a JSON snapshot and compares snapshots to show what differs between machines, such as a local workstation and a CI runner. A snapshot records system info (OS, architecture, kernel, memory, CPU), runtime versions (go, node, python, docker, plus custom-defined tools), environment variables, and network info (/etc/hosts and listening ports). Secrets in environment variables are detected and redacted by default; `--no-redact` includes the values.

The `envdiff compare` command takes two or more snapshots (for example local, CI and staging) and produces a categorized diff, which can be saved with `-o`. `envdiff render` turns a saved snapshot or diff into terminal output or Markdown (`--md`), which can be pasted into a pull request or issue.

For validation, `envdiff init` creates an `envdiff.yaml` template and `envdiff check` tests the current machine against it. The file sets runtime version constraints (e.g. `go: ">= 1.21.0"`), required and expected environment variables, ignore patterns, required system packages, custom runtime probes (command, args, regex), and per-tool fix hints such as `nvm use 20`. `check` only probes the runtimes listed in the file. It supports `--json` and `--quiet` (exit code only), so it can run in CI jobs or hooks. It is aimed at developers and DevOps engineers debugging "works on my machine" problems. It runs on Linux, macOS and Windows.

### Installation

```bash
# via Go install
go install github.com/GBerghoff/envdiff/cmd/envdiff@latest
```

```bash
# via Install script (Linux/macOS)
curl -fsSL https://raw.githubusercontent.com/GBerghoff/envdiff/main/install.sh | sh
```

![envdiff snapshot](https://media.trmn.sh/cached/b7788beb66783a596f76d7844a75395733d554e176d22d2980c323bcaebce9e8.gif)

![envdiff diff](https://media.trmn.sh/cached/6335247dd5826f3ea378d5aeeb71d2d5ddbb85131d844a8fdec4e1daee3b0b2b.gif)

![envdiff check](https://media.trmn.sh/cached/e3452bd67cd90cb9bad0993d192b9746b46114cc2a3903bc85a942f9b234d2fa.gif)

## Alternatives

- [awsesh](https://www.trmn.sh/tools/awsesh.md): TUI and CLI tool for managing AWS SSO sessions with fuzzy search, account switching, and shell integration. (Go, 143 stars)
- [octocov](https://www.trmn.sh/tools/octocov.md): Code metrics toolkit for collecting coverage, code-to-test ratio, test execution time, and custom metrics from multiple report formats (Go, 518 stars)
- [nap](https://www.trmn.sh/tools/nap.md): Code snippet manager with CLI and TUI for creating, organizing, and accessing snippets in the terminal (Go, 2.2k stars)
- [freeze](https://www.trmn.sh/tools/freeze.md): Generate PNG, SVG, and WebP images of code and terminal output with syntax highlighting and customizable styling. (Go, 4.9k stars)
- [Docker CLI](https://www.trmn.sh/tools/docker-cli.md): Source repository for the Docker command-line client, written in Go and built with docker buildx bake, with cross-platform and glibc/musl build targets. (Go, 6.1k stars)

## Guides

- [Find out why it works locally but fails in CI](https://www.trmn.sh/guides/works-locally-fails-in-ci): Snapshot your machine and your CI runner with envdiff, diff runtimes and env vars side by side, and add a check so the same mismatch can't come back.

---

Canonical: https://www.trmn.sh/tools/envdiff
