Skip to main content

CLI tool that diagnoses and auto-fixes Python/ML environment errors using a local LLM.

Project description

envfix ๐Ÿ› ๏ธ

envfix wraps any failing shell command, asks a local AI model what went wrong, and proposes a one-click fix โ€” fully offline, no API key, no cloud.

without envfix                          with envfix
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€  โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
$ python train.py                       $ envfix run python train.py

ModuleNotFoundError:                    โœ— Command Failed
  No module named 'torch'              โ”‚ ModuleNotFoundError: No module named 'torch'

โ†“ Google the error                      ๐Ÿค– Asking Ollama (llama3.1:8b)โ€ฆ
โ†“ Stack Overflow rabbit hole
โ†“ Try three different pip commands      โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ envfix Suggestion โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ†“ Wrong CUDA version                    โ”‚ DIAGNOSIS                                โ”‚
โ†“ Try again                             โ”‚ PyTorch is not installed in this env.    โ”‚
                                        โ”‚                                          โ”‚
~20 minutes later:                      โ”‚ FIX                                      โ”‚
$ python -m pip install torch           โ”‚ python -m pip install torch              โ”‚
                                        โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

                                        Run this fix? [y/n] (n): y
                                        โœ“ Success! The fix resolved the issue.
                                        (total time: ~30 seconds)

โš ๏ธ Early / experimental. Works best for common Python, Node.js, and package-manager errors. See Known limitations.


Prerequisites

Requirement Version Why
Python โ‰ฅ 3.10 f-strings, match syntax
Ollama latest (Optional) runs the local AI model
API Keys (Optional) GROQ_API_KEY or GEMINI_API_KEY for cloud models
RAM โ‰ฅ 8 GB for local llama3.1:8b โ€” or โ‰ฅ 4 GB for qwen2.5:3b

Install

Step 1 โ€” Choose your AI provider

envfix supports local and cloud models.

Option A (Default): Local Ollama Download from ollama.com/download (Windows, macOS, Linux).

On Linux you can also run:

curl -fsSL https://ollama.com/install.sh | sh

Step 2 โ€” Pull a model

# Recommended (needs ~8 GB RAM free)
ollama pull llama3.1:8b

# Lighter alternatives if you have โ‰ค 4 GB free RAM
ollama pull qwen2.5:3b
ollama pull llama3.2:3b

Option B: Groq API (Cloud)

  1. Get a free API key from console.groq.com.
  2. Set it in your terminal:
    # Windows PowerShell
    $env:GROQ_API_KEY="your-key-here"
    # Linux/macOS
    export GROQ_API_KEY="your-key-here"
    

Option C: Gemini API (Cloud)

  1. Get a free API key from Google AI Studio.
  2. Set it in your terminal:
    # Windows PowerShell
    $env:GEMINI_API_KEY="your-key-here"
    # Linux/macOS
    export GEMINI_API_KEY="your-key-here"
    

Step 3 โ€” Start Ollama

ollama serve

Windows tip: The Ollama installer adds a system-tray icon that starts the service automatically on login โ€” you may be able to skip this step. (Skip this step if you are using Groq or Gemini).

Step 4 โ€” Install envfix

git clone https://github.com/LOVEKUSH-rgb/deepproblemsolver.git
cd deepproblemsolver
pip install -e .

Why -e? Editable mode means changes to the source code take effect immediately without reinstalling. For a "permanent" install just use pip install . instead.

Verify the install:

envfix --help

Usage

envfix run <your failing command>

Common examples

# Missing Python module
envfix run python -m non_existent_module

# Broken requirements file
envfix run python -m pip install -r requirements.txt

# Node / npm error
envfix run npm run build --category node

# CUDA / GPU error
envfix run python train.py --gpu 0

# Use a lighter model on a low-RAM machine
envfix run python train.py --model qwen2.5:3b

# Use a cloud provider instead of local Ollama
envfix run npm install --provider groq
envfix run npm install --provider gemini

# Check your fix history
envfix history
envfix history --last 5

What you'll see

โ–ถ Running: python -m pip install -r requirements.txt

โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ โœ— Command Failed โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ ERROR: Could not find a version that     โ”‚
โ”‚ satisfies the requirement bogus-pkg      โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

๐Ÿค– Asking Ollama (llama3.1:8b) for a diagnosisโ€ฆ

โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ envfix Suggestion โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ DIAGNOSIS                                โ”‚
โ”‚ The package 'bogus-pkg' does not exist   โ”‚
โ”‚ on PyPI.                                 โ”‚
โ”‚                                          โ”‚
โ”‚ FIX                                      โ”‚
โ”‚ python -m pip install <correct-name>     โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

๐Ÿ“‹ What this will do: Installs a package from PyPI

Run this fix? [y/n] (n): y

If the same (or very similar) error has appeared before, envfix skips the model call entirely and shows the cached suggestion instead:

โšก Found a previously verified fix (97% match) โ€” skipping model call.

If the suggested fix contains a destructive command (rm -rf, sudo, delete, etc.), envfix shows an explicit warning and requires you to type yes in full:

โš ๏ธ DANGEROUS COMMAND DETECTED
This command may delete files, change permissions, or execute remote code.
Type 'yes' to run this fix (no):

Command reference

Command What it does
envfix run <cmd> Run a command; diagnose + suggest fix on failure
envfix run <cmd> --provider <name> Select AI provider (ollama [default], groq, gemini)
envfix run <cmd> --model <tag> Use a specific model tag/name for the chosen provider
envfix run <cmd> --category <eco> Hint the ecosystem (python, node, docker โ€ฆ)
envfix history Show the last 20 attempts
envfix history --last N Show last N attempts

How it works

envfix run <cmd>
     โ”‚
     โ–ผ
 subprocess: run the command, capture stderr
     โ”‚
  succeeded? โ”€โ”€Yesโ”€โ”€โ–บ โœ“ Nothing to fix
     โ”‚
    No
     โ–ผ
 Check per-user log (envfix_log_<username>.json) for similar past error
     โ”‚
  Cache hit โ”€โ”€Yesโ”€โ”€โ–บ Show cached fix (skip Ollama)
     โ”‚
    No
     โ–ผ
 Build structured prompt โ†’ POST to local Ollama service
     โ”‚
     โ–ผ
 Parse DIAGNOSIS + FIX from model response
     โ”‚
     โ–ผ
 Dry-run description for non-obvious commands
 Destructive guard for dangerous commands (requires "yes" in full)
     โ”‚
     โ–ผ
 User approves โ†’ apply fix โ†’ re-run original command
     โ”‚
     โ–ผ
 Log result to envfix_log_<username>.json

Supported Ecosystems

envfix automatically detects and diagnoses errors in:

  • Python: pip, pytest, python scripts
  • Node.js: npm, yarn, node scripts
  • Rust (Cargo): rustc compilation, missing crates
  • Go: go modules, compiler errors
  • Java: Maven, Gradle, JVM stack traces
  • Docker: Dockerfile build steps
  • General CLI: bash, powershell, missing binaries, permission issues

When you run envfix, it isolates code snippets from the stack trace and feeds them into the local model for a targeted diagnosis.

# Python
envfix run "pytest tests/" --category python

# Rust
envfix run "cargo build" --category rust

# Go
envfix run "go run main.go" --category go

# Docker
envfix run "docker build -t my-app ." --category docker

Per-user history

Every attempt is logged to envfix_log_<username>.json in the directory where you run envfix. Each user on the same machine gets their own separate file โ€” no shared state, no accounts.

The file is excluded from git by .gitignore so your personal history never gets committed.

Sample entry:

{
  "timestamp": "2026-07-26T08:00:00Z",
  "original_command": "python train.py",
  "error_text": "ModuleNotFoundError: No module named 'torch'",
  "diagnosis": "PyTorch is not installed in this environment.",
  "fix_command": "python -m pip install torch",
  "user_approved": true,
  "fix_worked": true,
  "source": "ollama",
  "category": "python",
  "context_included": false,
  "provider": "ollama"
}

Opt-In Team Telemetry

envfix supports sending optional, anonymous telemetry to a centralized team dashboard (if configured) so that engineering leads can view aggregated metrics like the most frequent errors and overall AI success rate.

By default, telemetry is OFF. envfix runs fully offline and does not send any data to any external server.

To enable telemetry, provide your team's API key and backend URL using environment variables:

export ENVFIX_TEAM_API_KEY="your-team-api-key"
export ENVFIX_BACKEND_URL="http://your-backend-domain.com"

Alternatively, these can be set in the ~/.envfix/config.toml file (team_api_key and backend_url).

If configured, envfix will send a non-blocking background request to the backend with the following minimal usage statistics:

  • error_type: A short summary of the error (e.g. ZeroDivisionError). No private code or logs are sent.
  • provider_used: The AI provider queried (e.g. groq, ollama).
  • was_cache_hit: true if the local cache handled the fix without a model call.
  • fix_applied: true if the user approved running the fix.
  • fix_worked: true if the retry was successful.

If the network request fails, envfix will silently swallow the error to guarantee zero interruptions to your workflow.


Security & Data Redaction

Before any error text, stack trace, or code snippet is logged locally or sent to an AI provider (Ollama, Groq, Gemini), envfix runs it through a best-effort Secret Redaction Layer.

This layer aggressively searches for and redacts:

  • AWS Access Keys
  • JWT Tokens
  • Database Connection URLs (the password segment is masked)
  • Private Key Blocks (e.g. RSA / ECDSA keys)
  • Generic Secrets (strings > 20 characters assigned to variables named API_KEY, SECRET, TOKEN, PASSWORD, etc.)

Any detected secrets are replaced with placeholders like [REDACTED:AWS_KEY].

Note: This is purely pattern-based matching and is not a guarantee. You should always avoid committing secrets to code or printing them in logs in the first place.


Known limitations

  • Model quality varies. envfix is only as good as the local model you pull. Smaller models (qwen2.5:3b, llama3.2:3b) sometimes produce vague or wrong diagnoses for complex errors. llama3.1:8b is the recommended minimum.
  • Works best for common errors. Highly project-specific errors (e.g. a bug in your custom C extension) will likely produce generic suggestions.
  • Windows path assumptions. The tool normalises pip install โ†’ python -m pip install because pip is often not on the Windows PATH. On macOS/Linux both forms work but the normalisation is harmless.
  • Single fix per failure. envfix proposes one fix at a time. If the first fix doesn't work, run envfix run <cmd> again โ€” the model may suggest something different.
  • Needs Ollama running. If ollama serve is not active, envfix exits with a clear error message rather than a cryptic timeout.
  • Still early. Prompt engineering and cache fuzzy-matching were tuned for Python/ML and Node errors. Other ecosystems (Rust, Docker, CMake โ€ฆ) will work but with less accuracy.

Running the tests

# No Ollama needed โ€” all tests are offline
python -m pytest tests/ -v

67 tests across three files covering the AI parser, subprocess runner, JSON logger, two-tier cache, dry-run preview, safety guardrails, and per-category matching.


Troubleshooting

Symptom Fix
Error reaching Ollama: Connection refused Run ollama serve in a separate terminal
model "llama3.1:8b" not found Run ollama pull llama3.1:8b
envfix: command not found Run pip install -e . from the repo root
Fix runs but original still fails The model diagnosis was wrong โ€” run again or fix manually
Model returns garbled output Try --model qwen2.5:3b
Always shows cached (wrong) fix Cache threshold is 0.85; if the fix is wrong, say n and re-run โ€” Ollama will be called fresh

Contributing

See CONTRIBUTING.md for the module map, ground rules, and how to submit a fix.


License

This project is licensed under the Business Source License 1.1 (BSL 1.1). It requires a commercial license for enterprise/managed service use. See the LICENSE file for complete details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

envfix-0.5.2.tar.gz (66.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

envfix-0.5.2-py3-none-any.whl (53.7 kB view details)

Uploaded Python 3

File details

Details for the file envfix-0.5.2.tar.gz.

File metadata

  • Download URL: envfix-0.5.2.tar.gz
  • Upload date:
  • Size: 66.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for envfix-0.5.2.tar.gz
Algorithm Hash digest
SHA256 5a896469141b50386519ee3953320c4b120876eb572ff419dc84b87628dc7257
MD5 73de4e9aa5a50a07967b70db71fb4fe4
BLAKE2b-256 bd6327d1cdde0364a211b485f05579b96c709a055343a3052ffc12dc12ff998e

See more details on using hashes here.

File details

Details for the file envfix-0.5.2-py3-none-any.whl.

File metadata

  • Download URL: envfix-0.5.2-py3-none-any.whl
  • Upload date:
  • Size: 53.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for envfix-0.5.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f28ef23c9bd1d81397a47d6c8b798d148a3c984c7590879ef12382d0b50cafce
MD5 cca1987996f4c2b41e751c90240e2578
BLAKE2b-256 bba6d057ca856a76c2b4f984b897eeb171dc12ee46f18e13e32286bea5b61593

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page