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.

perf(flox): skip hogli regen, let sandboxed pnpm use its cache (#118807)

Raúl Negrón-Otero853218d22580
diff --git a/.flox/env/on-activate.sh b/.flox/env/on-activate.sh
index d8f9ea844043..325c73329e82 100755
--- a/.flox/env/on-activate.sh
+++ b/.flox/env/on-activate.sh
@@ -9,14 +9,14 @@
set -euo pipefail
# ── Colors & symbols ────────────────────────────────────────────────
-readonly C_RESET='\033[0m'
-readonly C_DIM='\033[2m'
-readonly C_GREEN='\033[32m'
-readonly C_YELLOW='\033[33m'
-readonly C_RED='\033[31m'
-readonly C_CYAN='\033[1;36m'
-readonly C_ITALIC='\033[3m'
-readonly C_BOLD='\033[1m'
+readonly C_RESET=$'\033[0m'
+readonly C_DIM=$'\033[2m'
+readonly C_GREEN=$'\033[32m'
+readonly C_YELLOW=$'\033[33m'
+readonly C_RED=$'\033[31m'
+readonly C_CYAN=$'\033[1;36m'
+readonly C_ITALIC=$'\033[3m'
+readonly C_BOLD=$'\033[1m'
readonly SPINNER_FRAMES=('⠋' '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')
_ACTIVATION_TMPFILES=()
@@ -370,22 +370,32 @@ fi
# Install shell completions for hogli
HOGLI_COMPLETION_DIR="$FLOX_ENV_CACHE/completions"
mkdir -p "$HOGLI_COMPLETION_DIR"
-if [[ -d "$UV_PROJECT_ENVIRONMENT/bin" ]]; then
+# The completions list only the commands in hogli.yaml, so they change only when that file,
+# the manifest loader, or their generator changes.
+if [[ -d "$UV_PROJECT_ENVIRONMENT/bin" ]] && {
+ [[ ! -s "$HOGLI_COMPLETION_DIR/hogli.bash" || ! -s "$HOGLI_COMPLETION_DIR/_hogli" ]] ||
+ [[ "$FLOX_ENV_PROJECT/hogli.yaml" -nt "$HOGLI_COMPLETION_DIR/_hogli" ]] ||
+ [[ "$FLOX_ENV_PROJECT/tools/hogli/src/hogli/manifest.py" -nt "$HOGLI_COMPLETION_DIR/_hogli" ]] ||
+ [[ "$FLOX_ENV_PROJECT/tools/hogli/src/hogli/completion.py" -nt "$HOGLI_COMPLETION_DIR/_hogli" ]]
+}; then
"$UV_PROJECT_ENVIRONMENT/bin/python" \
-m hogli.completion --shell bash > "$HOGLI_COMPLETION_DIR/hogli.bash" 2>/dev/null || true
"$UV_PROJECT_ENVIRONMENT/bin/python" \
-m hogli.completion --shell zsh > "$HOGLI_COMPLETION_DIR/_hogli" 2>/dev/null || true
fi
-# Generate hogli man page into the active environment so `man hogli` works.
+# Generate hogli man page into the active environment so `man hogli` works. The page also
+# documents commands defined in Python, so it is regenerated in the background each time
+# instead of making activation wait for it.
HOGLI_MANPAGE_DIR="$UV_PROJECT_ENVIRONMENT/share/man/man1"
if [[ -d "$UV_PROJECT_ENVIRONMENT/bin" ]]; then
(
mkdir -p "$HOGLI_MANPAGE_DIR"
"$UV_PROJECT_ENVIRONMENT/bin/python" \
"$FLOX_ENV_PROJECT/tools/hogli/scripts/generate_man_page.py" \
- --output "$HOGLI_MANPAGE_DIR/hogli.1" >/dev/null 2>&1
- ) || true
+ --output "$HOGLI_MANPAGE_DIR/hogli.1"
+ ) >/dev/null 2>&1 &
+ disown
fi
# ── Step 1b: Build phrocs from source ─────────────────────────────
@@ -495,7 +505,7 @@ if [[ "$(uname -s)-$(uname -m)" == "Darwin-arm64" && -z "${SDKROOT:-}" ]] && com
if [[ -n "$_lld_sdk" ]]; then
export SDKROOT="$_lld_sdk"
- done_step "macOS SDK ${C_DIM}($(basename "$_lld_sdk") — newest one lld can link against)${C_RESET}"
+ done_step "macOS SDK ${C_DIM}($(basename "$_lld_sdk"), the newest one lld can link against)${C_RESET}"
else
warn_step "No macOS SDK found that lld can link against. Rust builds will fail."
echo -e " ${C_DIM}$(basename "$_active_sdk") has an arm64e.x1 slice that lld cannot parse, or no arm64 slice.${C_RESET}"
diff --git a/bin/dev-sandbox-selftest b/bin/dev-sandbox-selftest
index 0d4a60883201..e0361ef8e7eb 100755
--- a/bin/dev-sandbox-selftest
+++ b/bin/dev-sandbox-selftest
@@ -108,12 +108,12 @@ fi
# 7. Allowlisted toolchain dirs are readable. Only the ones that already exist —
# never create dirs in $HOME as a side effect.
-for d in .cache .npm .cargo "Library/Caches/node-gyp"; do
+for d in .cache .npm .cargo "Library/Caches/node-gyp" "Library/Caches/pnpm"; do
if [[ ! -d "$HOME/$d" ]]; then
echo " -- \$HOME/$d absent, skipping"
continue
fi
- if $SANDBOX "ls -d '$HOME/$d' >/dev/null" 2>/dev/null; then
+ if $SANDBOX "ls '$HOME/$d' >/dev/null" 2>/dev/null; then
pass "readable: \$HOME/$d"
else
die "allowlisted dir not readable: \$HOME/$d"
diff --git a/bin/dev-sandbox.sb b/bin/dev-sandbox.sb
index eca5befefd22..6e3d2c212af5 100644
--- a/bin/dev-sandbox.sb
+++ b/bin/dev-sandbox.sb
@@ -57,6 +57,7 @@
(subpath (string-append (param "HOME") "/.cache")) ; uv, node, flox caches
(subpath (string-append (param "HOME") "/.npm")) ; npm cache
(subpath (string-append (param "HOME") "/Library/Caches/node-gyp")) ; node headers for native builds
+ (subpath (string-append (param "HOME") "/Library/Caches/pnpm")) ; pnpm metadata + lockfile-verified caches
(subpath (string-append (param "HOME") "/.local/share/uv")) ; uv-managed Python interpreters (venv links here)
(subpath (string-append (param "HOME") "/.local/share/flox")) ; flox metadata
(subpath (string-append (param "HOME") "/Library/pnpm")) ; pnpm content-addressed store