Overview
Bench recognizes several environment variables that modify its behavior. These variables can be used to customize bench operations, enable development features, or configure specific behaviors in CI/CD environments.Development Variables
BENCH_DEVELOPER
Purpose: Suppress editable install warnings during development. Type: Boolean (any non-empty value) Default: Not set Usage:BENCH_DEVELOPER=1 suppresses this warning.
Location: bench/cli.py:72
Example:
Only use this variable during bench development. For production installations, always install bench from PyPI.
DEV_SERVER
Purpose: Indicates development server is running. Type: String Set by: Bench internally when runningbench start
Location: bench/utils/system.py:156
This variable is set automatically by bench and shouldn’t be set manually.
BENCH_VERBOSE
Purpose: Enable verbose logging output. Type: Boolean Default: Not set Usage:-v or --verbose flag:
Build and Installation Variables
FRAPPE_DOCKER_BUILD
Purpose: Indicates bench is being built/run in a Docker container. Type: Boolean (any non-empty value) Default: Not set Usage:- Skips certain host-specific configurations
- Modifies dependency installation behavior
- Adjusts process management settings
bench/utils/__init__.py:144bench/utils/bench.py:260bench/utils/bench.py:322bench/bench.py:369
This variable is primarily used by the official Frappe Docker repository and should not be set manually unless you’re building a custom Docker image.
PIP_VERSION
Purpose: Specify pip version to install in virtual environment. Type: String (version number) Default: Latest pip version Usage:bench/bench.py:428
BENCH_DISABLE_UV
Purpose: Disable UV package manager and use pip instead. Type: Boolean (“true”, “1”, “yes” to disable) Default: Not set (UV is used if available) Usage:bench/utils/__init__.py:45
Bench can use UV, a fast Python package installer. Set this variable to force using pip instead.
CI/CD Variables
CI
Purpose: Indicates code is running in a Continuous Integration environment. Type: Boolean (any non-empty value) Default: Not set Usage:- Suppresses editable install warnings (like
BENCH_DEVELOPER) - Skips file watching in Procfile generation
- May skip interactive prompts
- Modifies test behavior
bench/cli.py:72bench/config/procfile.py:14bench/tests/test_base.py:35bench/tests/test_base.py:96bench/tests/test_setup_production.py:77
- GitHub Actions
- GitLab CI
- Jenkins
- Travis CI
- CircleCI
PYTHONUNBUFFERED
Purpose: Disable Python output buffering. Type: String (“true”) Set by: Bench internally Usage: Set automatically by bench during execution Location:bench/utils/system.py:154
This ensures Python output appears immediately in logs rather than being buffered.
Production Variables
NO_SERVICE_RESTART
Purpose: Prevent automatic service restarts in production. Type: Boolean (any non-empty value) Default: Not set Usage:bench/config/production_setup.py:84
Useful when you want to manually control service restarts during production setup or updates.
BENCH_SERVICE_MANAGER
Purpose: Specify custom service manager. Type: String (service manager name) Default: Auto-detected (supervisor or systemd) Usage:bench/config/production_setup.py:124
Valid values:
supervisorsystemd
BENCH_SERVICE_MANAGER_COMMAND
Purpose: Specify custom service manager command. Type: String (command path) Default: Standard commands for detected service manager Usage:bench/config/production_setup.py:127
System Variables
HOME
Purpose: User home directory. Type: String (directory path) Default: System-provided Modified by: Bench when switching to frappe user Location:bench/cli.py:186
Bench may modify this when changing to the frappe user in production setups.
Usage Examples
Development Setup
Typical environment variables for development:CI/CD Pipeline
Typical environment variables for CI/CD:Docker Build
Typical environment variables for Docker:Production Deployment
Typical environment variables for production:Setting Environment Variables
Temporary (Current Session)
Permanent (User Profile)
Add to~/.bashrc, ~/.zshrc, or ~/.profile:
One-Time Use
System-Wide (All Users)
Add to/etc/environment (requires sudo):
Checking Environment Variables
View All Environment Variables
View Specific Variable
Check if Variable is Set
Best Practices
Development vs Production
Development vs Production
Use different environment variables for development and production:Development:
- Set
BENCH_DEVELOPER=1 - Enable verbose logging
- Don’t set
BENCH_DEVELOPER - Use
NO_SERVICE_RESTARTfor controlled deployments
Document Custom Variables
Document Custom Variables
If you use custom environment variables in your deployment scripts, document them clearly:
Security
Security
Never commit sensitive values to version control:Use tools like:
- Environment-specific config files
- Secret management systems
- Docker secrets
CI/CD Consistency
CI/CD Consistency
Ensure CI environment matches production:
Troubleshooting
Variable Not Taking Effect
-
Check if variable is set:
-
Reload shell configuration:
- Check for typos in variable name
-
Verify variable is exported:
Conflicts Between Variables
Some variables may conflict. For example:BENCH_DEVELOPER=1and production setupBENCH_DISABLE_UV=1with caching enabled
Related Resources
Configuration Files
Learn about bench configuration files
Contributing
Development environment setup
Production Setup
Production deployment guide
Architecture
How bench works internally