mirror of
https://github.com/BillyOutlast/posthog.git
synced 2026-02-04 03:01:23 +01:00
51 lines
2.3 KiB
Bash
51 lines
2.3 KiB
Bash
# Docker Compose project name - forces all containers to use "posthog" namespace
|
|
export COMPOSE_PROJECT_NAME=posthog
|
|
|
|
# Suppress verbose Flox logging only (not PostHog Rust services)
|
|
export RUST_LOG="flox=error,flox_rust_sdk=error,flox_watchdog=error"
|
|
|
|
if command -v flox >/dev/null 2>&1; then # Only activate flox if installed
|
|
# Capture the directory user intended to work in before any Flox operations
|
|
ORIGINAL_PWD="${PWD}"
|
|
|
|
# Use Git to detect if we're in a different working tree (repo or work tree) that should have its own environment
|
|
CURRENT_WORKING_TREE_ROOT=$(git rev-parse --show-toplevel 2>/dev/null || echo "")
|
|
ENV_WORKING_TREE_ROOT=""
|
|
if [[ -n "${FLOX_ENV_PROJECT}" ]]; then
|
|
ENV_WORKING_TREE_ROOT=$(cd "${FLOX_ENV_PROJECT}" && git rev-parse --show-toplevel 2>/dev/null || echo "")
|
|
fi
|
|
|
|
if [ -z "${FLOX_ENV_PROJECT}" ]; then
|
|
# No environment active, safe to activate
|
|
unset VIRTUAL_ENV 2>/dev/null || :
|
|
unset PYTHONPATH 2>/dev/null || :
|
|
unset CONDA_DEFAULT_ENV 2>/dev/null || :
|
|
flox activate
|
|
elif [[ -n "$CURRENT_WORKING_TREE_ROOT" && -n "$ENV_WORKING_TREE_ROOT" && "$CURRENT_WORKING_TREE_ROOT" != "$ENV_WORKING_TREE_ROOT" ]] || \
|
|
[[ -z "$CURRENT_WORKING_TREE_ROOT" && "${PWD}" != "${FLOX_ENV_PROJECT}"* ]]; then
|
|
# Different project environment active, check for nesting
|
|
echo "⚠️ About to activate Flox environment in working tree while already in environment for:"
|
|
echo " ${FLOX_ENV_PROJECT}"
|
|
echo ""
|
|
printf "Continue with nested activation? (y/N): "
|
|
if [ -t 0 ]; then
|
|
read -r REPLY
|
|
else
|
|
echo "Non-interactive shell detected. Defaulting to 'no'."
|
|
REPLY="n"
|
|
fi
|
|
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
|
echo "Skipping Flox activation. To switch environments:"
|
|
echo " 1. Exit current environment: exit"
|
|
echo " 2. Return to your intended directory: cd '${ORIGINAL_PWD}'"
|
|
echo " (Environment will reactivate automatically with direnv)"
|
|
return 0
|
|
fi
|
|
# Clean up conflicting environment variables before activation
|
|
unset VIRTUAL_ENV 2>/dev/null || :
|
|
unset PYTHONPATH 2>/dev/null || :
|
|
unset CONDA_DEFAULT_ENV 2>/dev/null || :
|
|
flox activate
|
|
fi
|
|
fi
|