pypa / pypa/hatch

"env show --json" fails with an error if some plugin is not installed

Open
#2,011 12 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement good first issue
Dominant language
Python
Stars
7.2k
Forks
462
Avg merge
19h 36m
Merged PRs (30d)
10

Description

I am working on integrating Hatch in PyCharm and encountered an issue with the --json flag, which breaks our integration.

steps to reproduce:
  1. hatch-container plugin is not installed

  2. git clone https://github.com/ofek/hatch-showcase

  3. ➜ hatch-showcase git:(master) hatch env show --json
    Environment all.py3.7 has unknown type: container

  4. hatch-showcase git:(master) hatch env show
    Standalone
    ┏━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┓
    ┃ Name ┃ Type ┃ Dependencies ┃ Scripts ┃
    ┡━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━┩
    │ default │ virtual │ coverage[toml]>=6.5 │ cov │
    │ │ │ pytest │ cov-report │
    │ │ │ │ test │
    │ │ │ │ test-cov │
    ├─────────┼─────────┼─────────────────────┼────────────┤
    │ lint │ virtual │ black>=22.10.0 │ all │
    │ │ │ mypy>=0.991 │ fmt │
    │ │ │ ruff>=0.0.166 │ style │
    │ │ │ │ typing │
    └─────────┴─────────┴─────────────────────┴────────────┘
    Matrices
    ┏━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┓
    ┃ Name ┃ Type ┃ Envs ┃ Dependencies ┃ Scripts ┃
    ┡━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━┩
    │ all │ container │ all.py3.7 │ coverage[toml]>=6.5 │ cov │
    │ │ │ all.py3.8 │ pytest │ cov-report │
    │ │ │ all.py3.9 │ │ test │
    │ │ │ all.py3.10 │ │ test-cov │
    │ │ │ all.py3.11 │ │ │
    └──────┴───────────┴────────────┴─────────────────────┴────────────┘

Expected Behaviour:

Hatch shows environments in json format, at least available ones

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the failure with hatch env show --json in the hatch-showcase repository while the hatch-container plugin is absent, then compare it with hatch env show. Trace the CLI path that formats environments as JSON; done means available environments are emitted in JSON without failing because an unavailable plugin-defined environment exists.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.