Skip to content

: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.

chore(dev): pin compose project name so local infra readiness doesn't drift (#72292)

Thiago Salvatored9198fd8febc
diff --git a/bin/start b/bin/start
index 6d637f1fd408..754e1ad9820b 100755
--- a/bin/start
+++ b/bin/start
@@ -5,6 +5,13 @@ set -e
export REPOSITORY_ROOT=$(realpath "$(dirname "$0")/..")
export LOCK_FILE="$REPOSITORY_ROOT/bin/start.lock"
+# All worktrees share one infra stack under the "posthog" compose project. Pin it
+# here so it never silently falls back to the worktree folder name when direnv
+# hasn't exported it (.envrc) — that mismatch makes wait-for-docker query the wrong
+# project and report db/redis/clickhouse/kafka as "missing" while docker ps shows
+# them running. An explicit override still wins.
+export COMPOSE_PROJECT_NAME="${COMPOSE_PROJECT_NAME:-posthog}"
+
# 1Password: auto-resolve op:// references in .env.local.
# Must run before lock acquisition: `exec op run ...` keeps the bash fds open
# in the op-run process, so if we held fd 9's flock here the re-exec'd child
@@ -140,6 +147,24 @@ if [[ -z "${HOGLI_SKIP_ZOMBIE_CHECK:-}" ]] && command -v hogli &>/dev/null; then
hogli doctor:zombies --yes || true
fi
+# Warn about a duplicate infra stack under a different compose project. It binds the
+# same host ports as "$COMPOSE_PROJECT_NAME", so our clickhouse/kafka can't start and
+# get stuck in "Created" — the "database missing" hang. Advisory only (never fail).
+foreign_stacks=$(docker ps --filter 'label=com.docker.compose.service=clickhouse' \
+ --format '{{.Label "com.docker.compose.project"}}' 2>/dev/null \
+ | grep -vx "$COMPOSE_PROJECT_NAME" | sort -u || true)
+if [[ -n "$foreign_stacks" ]]; then
+ echo "⚠️ Another dev infra stack is running under a different compose project:"
+ while IFS= read -r stack; do
+ [[ -n "$stack" ]] && echo " • $stack"
+ done <<< "$foreign_stacks"
+ echo " It holds the same host ports as '$COMPOSE_PROJECT_NAME', so clickhouse/kafka"
+ echo " here may fail to start and get reported as 'missing'. Tear it down with:"
+ while IFS= read -r stack; do
+ [[ -n "$stack" ]] && echo " docker compose -p $stack -f docker-compose.dev.yml down --remove-orphans"
+ done <<< "$foreign_stacks"
+fi
+
# Geo files
./bin/download-mmdb
diff --git a/bin/wait-for-docker b/bin/wait-for-docker
index dfc92598ed0c..fe6381336616 100755
--- a/bin/wait-for-docker
+++ b/bin/wait-for-docker
@@ -66,6 +66,11 @@ compose() {
local compose_file
local separator
+ # Pin the project so `ps` targets the same stack the up command created under
+ # (see generator.py). Without -p, compose derives it from COMPOSE_PROJECT_NAME
+ # or the worktree folder name, which drifts from "posthog" when direnv is off.
+ local project="${COMPOSE_PROJECT_NAME:-posthog}"
+
if [ -n "${COMPOSE_FILE:-}" ]; then
separator="${COMPOSE_PATH_SEPARATOR:-:}"
IFS="$separator" read -r -a compose_files <<< "$COMPOSE_FILE"
@@ -74,9 +79,9 @@ compose() {
compose_args+=(-f "$compose_file")
fi
done
- env -u COMPOSE_FILE docker compose ${compose_args[@]+"${compose_args[@]}"} "$@"
+ env -u COMPOSE_FILE docker compose -p "$project" ${compose_args[@]+"${compose_args[@]}"} "$@"
else
- docker compose -f "$DEFAULT_COMPOSE_FILE" "$@"
+ docker compose -p "$project" -f "$DEFAULT_COMPOSE_FILE" "$@"
fi
}