:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(hogli): load .env.services for all subcommands, not just hogli run (#59199)
Georgis Andonis1eeaf642dab1
diff --git a/tools/hogli/src/hogli/cli.py b/tools/hogli/src/hogli/cli.pyindex e8cf56ef8df0..0979c0f09d09 100644--- a/tools/hogli/src/hogli/cli.py+++ b/tools/hogli/src/hogli/cli.py@@ -171,6 +171,7 @@ def _auto_update_manifest() -> None:@click.pass_contextdef cli(ctx: click.Context) -> None:"""hogli - YAML-driven developer CLI."""+ _load_default_env_files()# Auto-update manifest on every invocation (but skip for meta:check and git hooks)# Skip during git hooks to prevent manifest modifications during lint-staged executionin_git_hook = os.environ.get("GIT_DIR") is not None or os.environ.get("HUSKY") is not None@@ -283,6 +284,20 @@ def _load_env_file(path: os.PathLike[str], only_if_unset: bool = True) -> None:os.environ[name] = value+def _load_default_env_files() -> None:+ """Load .env.development and .env.services for every hogli subcommand.++ Mirrors bin/start so commands that shell out to manage.py / bin scripts+ (dev:reset, migrations:run, etc.) see the same service connection defaults+ the dev stack uses. Shell vars win; we never overwrite.++ .env.local is intentionally NOT loaded here — it can contain 1Password+ op:// refs that only `hogli run` knows how to resolve via `op run`.+ """+ _load_env_file(REPO_ROOT / ".env.development", only_if_unset=True)+ _load_env_file(REPO_ROOT / ".env.services", only_if_unset=True)++@cli.command(name="run", help="Run a command with resolved environment (1Password + defaults)")@click.argument("command", nargs=-1, required=True)def run_with_env(command: tuple[str, ...]) -> None: