[Bug] Preset composition fails under isolated installs: scripts run on system python3 but PyYAML lives in the CLI venv
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 55/100
Hướng nghiên cứu
Bắt đầu với .specify/scripts/python/common.py và .specify/scripts/bash/common.sh, đặc biệt là đường dẫn chọn trình thông dịch trong _python3_command(), sau đó so sánh nó với điểm vào CLI và khai báo phụ thuộc trong pyproject.toml. Tái hiện việc hình thành manifest của preset sau một uv tool install hoặc pipx install. Hoàn thành khi cả hai biến thể script đều resolve được PyYAML trong các cài đặt cô lập mà không yêu cầu nó trong trình thông dịch hệ thống.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
Preset template composition fails with PyYAML is required to resolve preset template composition whenever the CLI is installed the recommended way (uv tool install or pipx), because the automation scripts run under the system python3 while pyyaml lives in the CLI's isolated venv.
The better the installation isolation, the more reliably the bug shows up.
The chain
- Command skills instruct the agent to run the script, not the CLI. From
speckit-plan:Run `python3 .specify/scripts/python/setup_plan.py --json` from repo root - That script reaches
common.py, which doesimport yaml(line 391 in v1.0.4) and raisesTemplateResolutionError("PyYAML is required to resolve preset template composition")when apreset.ymlmanifest exists. pyyaml>=6.0is declared inpyproject.tomland is correctly installed — but inside the tool venv created byuv tool install/pipx.- The script is invoked as bare
python3, which resolves to the system interpreter that cannot see that venv.
Reproduction
uv tool install specify-cli
specify init myproj --integration claude --script py
cd myproj
specify preset add <any preset with a preset.yml>
# CLI path — works (runs inside the tool venv):
specify preset resolve plan-template
# Script path — fails (runs under system python3):
python3 .specify/scripts/python/resolve_template.py plan-template --json
# ERROR: PyYAML is required to resolve preset template composition
Same failure with the bash variant (.specify/scripts/bash/resolve-template.sh), since _python3_command() in common.sh only probes python3 on PATH.
Environment
- spec-kit
1.0.4 - macOS 15 (arm64), Homebrew Python 3.14.6
- Reproduced with both
uv tool install specify-cliandpipx install specify-cli
Why the usual workarounds don't apply
--script pydoesn't help: the Python variant is invoked by the same barepython3.- There is no environment variable to point at another interpreter;
_python3_command()only checks PATH. - Installing
pyyamlinto the system interpreter is refused on Homebrew/Debian Python under PEP 668 (externally-managed-environment).uv pip install --python "$(which python3)" pyyamlis refused for the same reason and suggests a venv — but a venv doesn't help, because the skills invoke barepython3with no activation.
The only way out today is bypassing PEP 668 (pip install --user --break-system-packages pyyaml), which asks users to disable a safety mechanism to run a documented feature.
Impact
Any project using a preset with a manifest — i.e. any preset that needs append, prepend or wrap, since the manifest-less path is hardcoded to replace:
except ImportError as exc:
if manifest_path.is_file():
raise TemplateResolutionError("PyYAML is required ...")
return (conventional, "replace") if conventional is not None else None
So composition strategies are unavailable precisely for users who installed the CLI in an isolated environment, which is what the docs recommend.
Suggested fixes
Any one of these would close it:
- Have the scripts resolve the interpreter that ships with spec-kit (record its path at
inittime, similar to how some tools pin the interpreter into generated hooks) instead of assuming barepython3. - Honor an override such as
SPECIFY_PYTHONin_python3_command(). - Vendor a minimal YAML parser for manifest reading, or parse the small, well-known
preset.ymlschema without the dependency. - If none of the above, document the requirement explicitly in the installation guide, since today it surfaces only as a runtime error.
Happy to send a PR for option 2 if that's the direction you'd prefer.
- Ngôn ngữ chính
- Python
- Star
- 138k
- Fork
- 12.4k
- Merge trung bình
- 3 ngày 6 giờ
- Pull request đã merge (30 ngày)
- 136
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của github/spec-kit
-
enhancement needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
enhancement needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
enhancement needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
[Feature]: 给 slug 添加默认值 Đang mởenhancement needs-triage triage-can-wait
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
-
extension-submission triage-can-wait
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Tất cả issue của github/spec-kit
Issue tương tự
-
documentation help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 90/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 90/100
simonw/sqlite-utils#872 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100