Skip to content

Bug: setup_repository.py uses 'which' for command detection (fails on Windows) #72

Description

@josephwilson8-nhs

Description

check_command_available() in scripts/setup_repository.py uses which to detect whether a command exists:

subprocess.run(
    ["which", cmd],
    capture_output=True,
    check=True,
)

which is a Unix utility and does not exist on Windows. The script already has Windows-aware logic elsewhere (e.g. choosing .venv/Scripts/pip vs .venv/bin/pip), but this function will raise FileNotFoundError on Windows before any of that logic is reached.

Impact

Any user generating a project on Windows who runs setup_repository.py (via make setup or directly) will get an immediate failure when checking for git/uv/conda/python availability.

Fix

Use shutil.which(cmd) from the standard library, which works cross-platform:

import shutil

def check_command_available(cmd: str) -> bool:
    return shutil.which(cmd) is not None

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtemplateChanges to the generated template/project

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions