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

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"
}

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.0.tar.gz (46.0 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.0-py3-none-any.whl (35.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: envfix-0.5.0.tar.gz
  • Upload date:
  • Size: 46.0 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.0.tar.gz
Algorithm Hash digest
SHA256 a3a062d05bbbbae21fbb689f9529c9a3ff8cd357e03b051d1fffb53a81a7b50e
MD5 d0e22e543469b1c26a90e7b679641c94
BLAKE2b-256 46338395c55e1b1abf67f909c90ee6cdd06d0c6506aea9d78c50807ea495d916

See more details on using hashes here.

File details

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

File metadata

  • Download URL: envfix-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 35.6 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ba4184d4e5058b407af8d541f6294509c61a08497f1985008e6b18b11f471bbb
MD5 e3e56274e0aa277aa07bf5569bd44ce4
BLAKE2b-256 f58bd394df227c4b7833f4e3cf6d37a6c36b1b633bdcf1d09cb8cbd14f8e316e

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