fix: replace uv tool install with bash shim for reliable config resolution

Config and assets were not found when running hate_crack from outside the
repo directory. The shim uses `uv run --directory` to always execute from
the repo root, and _candidate_roots() now includes _repo_root and
_package_path as fallback search locations.
This commit is contained in:
Justin Bollinger
2026-03-17 12:45:19 -04:00
parent d8c009c334
commit a1b81ec01d
4 changed files with 38 additions and 15 deletions
+12 -5
View File
@@ -97,10 +97,20 @@ install: submodules
fi
@command -v uv >/dev/null 2>&1 || { echo "uv not found. Installing uv..."; curl -LsSf https://astral.sh/uv/install.sh | sh; }
@UV_BIN=$$(command -v uv 2>/dev/null || echo "$$HOME/.local/bin/uv"); \
"$$UV_BIN" tool install -e .
"$$UV_BIN" sync
@mkdir -p "$${XDG_BIN_HOME:-$$HOME/.local/bin}"
@printf '#!/usr/bin/env bash\nset -euo pipefail\nexec uv run --directory %s python -m hate_crack "$$@"\n' "$(CURDIR)" \
> "$${XDG_BIN_HOME:-$$HOME/.local/bin}/hate_crack"
@chmod +x "$${XDG_BIN_HOME:-$$HOME/.local/bin}/hate_crack"
@echo "Installed hate_crack shim to $${XDG_BIN_HOME:-$$HOME/.local/bin}/hate_crack"
update: submodules
@uv tool install -e . --force --reinstall
@uv sync
@mkdir -p "$${XDG_BIN_HOME:-$$HOME/.local/bin}"
@printf '#!/usr/bin/env bash\nset -euo pipefail\nexec uv run --directory %s python -m hate_crack "$$@"\n' "$(CURDIR)" \
> "$${XDG_BIN_HOME:-$$HOME/.local/bin}/hate_crack"
@chmod +x "$${XDG_BIN_HOME:-$$HOME/.local/bin}/hate_crack"
@echo "Updated hate_crack shim at $${XDG_BIN_HOME:-$$HOME/.local/bin}/hate_crack"
reinstall: uninstall install
@@ -146,9 +156,6 @@ check: lint
uninstall:
@echo "Detecting OS and uninstalling dependencies..."
@uv tool uninstall hate_crack || true
@data_home="$${XDG_DATA_HOME:-$$HOME/.local/share}"; \
rm -rf "$$data_home/uv/tools/hate-crack" "$$data_home/uv/tools/hate_crack"
@bin_home="$${XDG_BIN_HOME:-$$HOME/.local/bin}"; \
rm -f "$$bin_home/hate_crack"
@if [ "$(shell uname)" = "Darwin" ]; then \