bench set-config
The bench set-config command allows you to add or update configuration values for a Frappe site. It can modify either a site’s site_config.json file or the bench-wide common_site_config.json, depending on the options used.
This command provides a convenient way to manage configuration settings without manually editing JSON files.
Usage
bench set-config [OPTIONS] KEY VALUE
How It Works
When executed, Bench updates the specified configuration key with the provided value.
- By default, the configuration is stored in the site’s
site_config.json. - Using the
--globalflag stores the configuration in the bench-levelcommon_site_config.json, making it available to all sites unless overridden.
If the same configuration key exists in both common_site_config.json and site_config.json, the value defined in site_config.json takes precedence.
Available Flags
| Flag | Description |
|---|---|
-g, --global |
Stores the configuration in the bench’s common_site_config.json instead of the current site’s configuration file. |
-p, --parse |
Parses the supplied value as JSON instead of treating it as a plain string. This is useful for storing dictionaries, lists, booleans, and other structured values. |
Examples
Enable Tests for a Specific Site
Add the allow_tests configuration to a single site’s site_config.json.
bench --site {site} set-config allow_tests true
Enable Tests for All Sites Individually
Update the site_config.json file of every site on the bench with the specified configuration.
bench --site all set-config allow_tests true
After running this command, each site’s configuration will contain:
{
"allow_tests": true
}
Set a Global Configuration
Store the configuration in the bench-wide common_site_config.json so that it applies to all sites by default.
bench set-config -g allow_tests true
This adds the following entry to common_site_config.json:
{
"allow_tests": true
}
Individual sites can still override this value by defining their own allow_tests setting in site_config.json.
Store a Dictionary Value
Use the --parse flag to save structured JSON data instead of a simple string.
bench --site {site} set-config backup '{"includes": ["Not", "ToDo"]}' --parse
After saving, the value can be accessed in Frappe using:
frappe.conf.backup.get("includes")
Use the --parse flag whenever you need to store JSON objects, arrays, or boolean values. Without it, the value is stored as plain text.