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.

fix(dev): acquire bin/start flock after 1Password re-exec (#59173)

Georgis Andonis6c106ace8107
diff --git a/bin/start b/bin/start
index 0434e873e2dc..7866e70acf83 100755
--- a/bin/start
+++ b/bin/start
@@ -5,6 +5,23 @@ set -e
export REPOSITORY_ROOT=$(realpath "$(dirname "$0")/..")
export LOCK_FILE="$REPOSITORY_ROOT/bin/start.lock"
+# 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
+# bin/start would fail to acquire it.
+if [ -f "$REPOSITORY_ROOT/.env.local" ] && grep -q "op://" "$REPOSITORY_ROOT/.env.local" 2>/dev/null; then
+ if [ -z "$_POSTHOG_OP_RESOLVED" ]; then
+ if command -v op &>/dev/null; then
+ echo "🔐 Resolving secrets from .env.local via 1Password"
+ export _POSTHOG_OP_RESOLVED=1
+ exec op run --env-file="$REPOSITORY_ROOT/.env.local" -- "$0" "$@"
+ else
+ echo "⚠️ .env.local contains 1Password refs (op://) but 'op' CLI not found"
+ echo " Install: brew install 1password-cli"
+ fi
+ fi
+fi
+
cleanup_lock() {
rm -f "$LOCK_FILE"
}
@@ -19,20 +36,6 @@ fi
trap cleanup_lock EXIT INT TERM
-# 1Password: auto-resolve op:// references in .env.local
-if [ -f "$REPOSITORY_ROOT/.env.local" ] && grep -q "op://" "$REPOSITORY_ROOT/.env.local" 2>/dev/null; then
- if [ -z "$_POSTHOG_OP_RESOLVED" ]; then
- if command -v op &>/dev/null; then
- echo "🔐 Resolving secrets from .env.local via 1Password"
- export _POSTHOG_OP_RESOLVED=1
- exec op run --env-file="$REPOSITORY_ROOT/.env.local" -- "$0" "$@"
- else
- echo "⚠️ .env.local contains 1Password refs (op://) but 'op' CLI not found"
- echo " Install: brew install 1password-cli"
- fi
- fi
-fi
-
# Environment variables are defined in:
# .env.services - service connection defaults (shared with containers
# and hobby via docker-compose env_file)