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(flox): set UV_PROJECT_ENVIRONMENT in profile, not [vars] (#64927)

Tom Piccirellof27aee3fd225
diff --git a/.flox/env/manifest.toml b/.flox/env/manifest.toml
index 89b9b3b59790..670b58cde806 100644
--- a/.flox/env/manifest.toml
+++ b/.flox/env/manifest.toml
@@ -75,8 +75,9 @@ DOTENV_FILE = ".env"
OPENSSL_INCLUDE_DIR = "$FLOX_ENV/include"
LDFLAGS="-L$FLOX_ENV/lib"
CPPFLAGS="-I$FLOX_ENV/include"
-UV_PROJECT_ENVIRONMENT = "$FLOX_ENV_CACHE/venv"
RUSTC_WRAPPER = "sccache"
+# UV_PROJECT_ENVIRONMENT is set in the [hook]/[profile] scripts, not here: [vars]
+# are added without expanding $FLOX_ENV_CACHE, so flox drops it on fresh activation.
# The `hook.on-activate` script is run by the *bash* shell immediately upon
# activating an environment, and will not be invoked if Flox detects that the
@@ -107,6 +108,8 @@ bash = '''
export GOMODCACHE="$GOPATH/pkg/mod"
# Ensure flox binaries (especially Node.js) take precedence over system binaries
export PATH="$FLOX_ENV/bin:$PATH"
+ # uv venv path — set here, not in [vars] (which can't expand $FLOX_ENV_CACHE)
+ export UV_PROJECT_ENVIRONMENT="$FLOX_ENV_CACHE/venv"
# Recreate venv if it was deleted (on-activate only runs on first activation)
if [ ! -f "$UV_PROJECT_ENVIRONMENT/bin/activate" ]; then
uv sync
@@ -135,6 +138,8 @@ zsh = '''
export GOMODCACHE="$GOPATH/pkg/mod"
# Ensure flox binaries (especially Node.js) take precedence over system binaries
export PATH="$FLOX_ENV/bin:$PATH"
+ # uv venv path — set here, not in [vars] (which can't expand $FLOX_ENV_CACHE)
+ export UV_PROJECT_ENVIRONMENT="$FLOX_ENV_CACHE/venv"
# Recreate venv if it was deleted (on-activate only runs on first activation)
if [[ ! -f "$UV_PROJECT_ENVIRONMENT/bin/activate" ]]; then
uv sync
@@ -159,6 +164,8 @@ fish = '''
set -gx GOMODCACHE "$GOPATH/pkg/mod"
# Ensure flox binaries (especially Node.js) take precedence over system binaries
fish_add_path -g "$FLOX_ENV/bin"
+ # uv venv path — set here, not in [vars] (which can't expand $FLOX_ENV_CACHE)
+ set -gx UV_PROJECT_ENVIRONMENT "$FLOX_ENV_CACHE/venv"
# Recreate venv if it was deleted (on-activate only runs on first activation)
if not test -f "$UV_PROJECT_ENVIRONMENT/bin/activate.fish"
uv sync
@@ -176,6 +183,8 @@ tcsh = '''
setenv GOMODCACHE "$GOPATH/pkg/mod"
# Ensure flox binaries (especially Node.js) take precedence over system binaries
setenv PATH "$FLOX_ENV/bin:$PATH"
+ # uv venv path — set here, not in [vars] (which can't expand $FLOX_ENV_CACHE)
+ setenv UV_PROJECT_ENVIRONMENT "$FLOX_ENV_CACHE/venv"
# Recreate venv if it was deleted (on-activate only runs on first activation)
if ( ! -f "$UV_PROJECT_ENVIRONMENT/bin/activate.csh" ) then
uv sync
diff --git a/.flox/env/on-activate.sh b/.flox/env/on-activate.sh
index ae72f6f06852..929610b3d471 100755
--- a/.flox/env/on-activate.sh
+++ b/.flox/env/on-activate.sh
@@ -220,6 +220,10 @@ export GOPATH="$FLOX_ENV_CACHE/go"
export GOCACHE="$FLOX_ENV_CACHE/go-build"
export GOMODCACHE="$GOPATH/pkg/mod"
+# uv-managed venv location (mirrors the [profile] scripts; not in [vars], which
+# can't expand $FLOX_ENV_CACHE). Used below for uv sync + the hogli symlink.
+export UV_PROJECT_ENVIRONMENT="$FLOX_ENV_CACHE/venv"
+
# ── Direnv first-time setup (interactive only) ─────────────────────
if [[ "$_interactive" == true ]] && ! command -v direnv >/dev/null 2>&1 && [[ ! -f "$FLOX_ENV_CACHE/.hush-direnv" ]]; then
read -p "$(echo -e "${C_BOLD}direnv${C_RESET} recommended for auto-activation. Set up now? (Y/n) ")" -n 1 -r