Newer Version Available

This content describes an older version of this product. View Latest

Environment Variables

You can set environment variables to configure certain values that Salesforce CLI and Salesforce DX tooling use.

Salesforce CLI Environment Variables

Environment variables override Configuration Variables. To set an environment variable for only the command you’re running, append the variable, like this:

1SF_ORG_API_VERSION=57.0 sf org create scratch -<options>
FORCE_OPEN_URL
Specifies the web page that opens in your browser when you run org open. For example, to open Lightning Experience, set to lightning.

Equivalent to the --path flag of org open.

FORCE_SHOW_SPINNER
Set to true to show a spinner animation on the command line when running asynchronous CLI commands. Default is false.
FORCE_SPINNER_DELAY
Specifies the speed of the spinner in milliseconds. Default is 60.
SF_ACCESS_TOKEN
Specifies an access token when using the org login access-token command. If you don’t set this environment variable, the command prompts you for the access token. Useful for continuous integration (CI) scripts.
SF_ORG_API_VERSION
The API version for a specific project or all projects. Normally, the Salesforce CLI assumes that you’re using the same version of the CLI as your Dev Hub.
SF_APPLY_REPLACEMENTS_ON_CONVERT
Set to true to test string replacement without actually deploying files to the org. Instead, run project convert source to convert the files to metadata API format and then inspect the files to see what will be deployed.

See Replace Strings in Code Before Deploying for details.

SF_AUDIENCE_URL
Overrides the aud (audience) field used for JWT authentication so that it matches the expected value of the authorization server URL for the org you’re logging into. For example, https://MyDomainName.my.salesforce.com or https://login.salesforce.com for a production org, and https://MyDomainName--SandboxName.sandbox.my.salesforce.comor https://test.salesforce.com for a sandbox.

Example:

1SF_AUDIENCE_URL=https://MyDomainName.my.salesforce.com
SF_CODE_COVERAGE_REQUIREMENT
Specifies the code coverage percentages that are displayed in green when you run apex run test or apex get test with the --code-coverage flag.

If the code coverage percentage for an Apex test is equal to or higher than this setting, it’s displayed in green. If the percent is lower, it’s displayed in red. Applies only to human-readable output. Default is 70%.

SF_CONTENT_TYPE
When set to JSON, specifies that all CLI commands output results in JSON format. If you set the environment variable to any other value, or unset it, the CLI commands output their results as specified by the flags.

Example:

1SF_CONTENT_TYPE=JSON
SF_CUSTOM_ORG_METADATA_TEMPLATES
Specifies either a local directory or a cloned GitHub repository that contains the default custom code templates used by the project create command. The GitHub URL points to either the root directory that contains your templates or to a subdirectory on a branch in the repo that contains your templates.

Example:

1SF_CUSTOM_ORG_METADATA_TEMPLATES=https://github.com/mygithubacct/salesforcedx-templates
SF_TARGET_DEV_HUB
Specifies the username of your default Dev Hub org so you don’t have to use the --target-dev-hub flag. Overrides the value of the target-dev-hub configuration value.

Example of setting it to an alias:

1SF_TARGET_DEV_HUB=myDevHub

Example of setting it to an org username:

1SF_TARGET_DEV_HUB=mydevhuborg@example.com
SF_TARGET_ORG
Specifies the username of your default org so you don’t have to use the --target-org flag. Overrides the value of the target-org configuration variable.

Example of setting it to an alias:

1SF_TARGET_ORG=myscratchorg

Example of setting it to a username:

1SF_TARGET_ORG=test-xhquykly9fhl@example.com
SF_DISABLE_AUTOUPDATE or SF_AUTOUPDATE_DISABLE (either var works)
Set to true to disable the auto-update feature of the CLI. By default, the CLI periodically checks for and installs updates.
SF_DISABLE_DNS_CHECK
Set to true to stop the Salesforce CLI commands that require an org to check whether the org is connected. For example, the org create scratch command requires a Dev Hub org. Default value is false (always check.)
This environment variable is useful if you get this error when running certain Salesforce CLI commands.
1DomainNotFound: The org cannot be found
First try setting the SF_DNS_TIMEOUT environment variable to increase the number of seconds that Salesforce CLI waits for a response. If that doesn’t work, try disabling the check entirely with the SF_DISABLE_DNS_CHECK environment variable.
SF_DISABLE_SOURCE_MEMBER_POLLING
Set to true to disable polling of your org’s SourceMember object when you run the project deploy|retrieve commands.

The commands poll the SourceMember object to track what's changed between your local source and the org after the deploy or retrieve completes. If you have a large metadata deployment, however, the polling can take a while, or even time out. Sometimes you don't require source tracking at all, such as in a continuous integration (CI) job. These use cases are good candidates for setting this environment variable.

The environment variable works with both scratch orgs and sandboxes.

When you disable SourceMember polling, the CLI’s internal tracking of what’s changed between your local source and org metadata gets out of sync. As a result, subsequent runs of the project deploy|retrieve commands are unreliable, and it’s up to you to synchronize your source. To reset source tracking, use the project reset tracking command.

Warning

SF_DISABLE_TELEMETRY
Set to true to disable the CLI from collecting usage information, user environment information, and crash reports.
SF_DNS_TIMEOUT
Specifies the number of seconds that Salesforce CLI commands that require an org wait for a response when checking whether the org is connected. For example, the org create scratch command requires a Dev Hub org. If the commands don’t receive a response in that time, they time out. Default value is 3.
This environment variable is useful if you get this error when running certain Salesforce CLI commands.
1DomainNotFound: The org cannot be found
First try setting the SF_DNS_TIMEOUT environment variable to increase the number of seconds that Salesforce CLI waits for a response. If that doesn’t work, try disabling the check entirely with the SF_DISABLE_DNS_CHECK environment variable.
SF_DOMAIN_RETRY
Specifies the time, in seconds, that the CLI waits for the Lightning Experience custom domain to resolve and become available in a newly created scratch org.

The default value is 240 (4 minutes). Set the variable to 0 to bypass the Lightning Experience custom domain check entirely.

SF_HIDE_RELEASE_NOTES
Set to true to silence the automatic display of the release notes when you run sf update. Default value is false.

Example:

1SF_HIDE_RELEASE_NOTES=true
SF_HIDE_RELEASE_NOTES_FOOTER
Set to true to silence the boilerplate footer about displaying the release notes when you run sf update. Default value is false.

Example:

1SF_HIDE_RELEASE_NOTES_FOOTER=true
SF_IMPROVED_CODE_COVERAGE
Scopes Apex test results to the classes entered during a test run when running apex run test and apex get test. Set to true to improve code coverage.
SF_ORG_INSTANCE_URL
The URL of the Salesforce instance that is hosting your org. Default value is https://login.salesforce.com. We recommend that you set this value to the My Domain login URL for your org. You can find the My Domain login URL on the My Domain page in Setup.
SF_JSON_TO_STDOUT
Sends messages when Salesforce CLI commands fail to stdout instead of stderr. Setting this environment variable to true is helpful for scripting use cases.

Example:

1SF_JSON_TO_STDOUT=true
SF_LOG_LEVEL
Sets the level of messages that the CLI writes to the log file.

Example:

1SF_LOG_LEVEL=debug
SF_LOG_ROTATION_PERIOD
Time period after which Salesforce CLI rotates the log file. Rotating the log file refers to making a backup copy of the file and then clearing out the current log file to start afresh. For example, if set to 1d, Salesforce CLI rotates the log file daily at midnight. If set to 2w, the file is rotated every 2 weeks. See the period entry in this table for other time period options. Default value is 1d.

Example:

1SF_LOG_ROTATION_PERIOD=2w
SF_LOG_ROTATION_COUNT
Number of backup files to keep when rotating the log file. Default value is 2. See SF_LOG_ROTATION_PERIOD for more information

Example:

1SF_LOG_ROTATION_COUNT=10
SF_ORG_MAX_QUERY_LIMIT
The maximum number of Salesforce records returned by a CLI command. Default value is 10,000.

Example:

1SF_ORG_MAX_QUERY_LIMIT=200000
SF_MDAPI_TEMP_DIR
Places the files (in metadata format) in the specified directory when you run some CLI commands, such as project retrieve start. Retaining these files can be useful for several reasons. You can debug problems that occur during command execution. You can use the generated package.xml when running subsequent commands, or as a starting point for creating a manifest that includes all the metadata you care about.
1SF_MDAPI_TEMP_DIR=/users/myName/myDXProject/metadata
SF_NPM_REGISTRY
Sets the URL to a private npm server, where all packages that you publish are private. We support only repositories that don’t require authentication.

Example:

1SF_NPM_REGISTRY=http://mypkgs.myclient.com/npm/my_npm_pkg

Verdaccio is an example of a lightweight private npm proxy registry.

SF_PRECOMPILE_ENABLE
Set to true to enable Apex pre-compile before the tests are run. This variable works with the apex run test command. Default is false.

The duration of an Apex test pre-compilation can be inconsistent. As a result, runs of the same Apex tests are sometimes quick and other times they time out. We recommend that you set this variable to true only if your Apex tests (without pre-compile) activate multiple concurrent Apex compilations that consume many system resources.

Important

SF_PROJECT_AUTOUPDATE_DISABLE_FOR_PACKAGE_CREATE
For package create, disables automatic updates to the sfdx-project.json file.
SF_PROJECT_AUTOUPDATE_DISABLE_FOR_PACKAGE_VERSION_CREATE
For package version create, disables automatic updates to the sfdx-project.json file.
SF_ORG_METADATA_REST_DEPLOY
Set to true to make Salesforce CLI use the Metadata REST API for deployments. By default, Salesforce CLI uses SOAP. Deployments using REST aren’t bound by the 39-MB .zip file size limit that applies to SOAP deployments.
SF_SOURCE_MEMBER_POLLING_TIMEOUT
Set to the number of seconds you want the project deploy start command to keep polling the SourceMember object before the command times out. The project deploy start command polls the SourceMember object to track what's changed between your local source and the org after the deploy completes. Salesforce CLI calculates a time-out for each project deploy start command run based on the number of components it deploys. Use this environment variable to override the calculated time-out.

For example, if the deploy times out after 3 minutes, try setting a time-out of 5 minutes (300 seconds):

1SF_SOURCE_MEMBER_POLLING_TIMEOUT=300
SF_SOURCE_TRACKING_BATCH_SIZE
Sets the source-tracked file batch size during a deploy or retrieve. Default value is 8,000 (Windows) or 15,000 (Linux/macOS).

This environment variable is useful when deploying or retrieving a large project that contains many source-tracked files, and you exceed your operating system open file limit. While the deploy or retrieve likely complete successfully, source-tracking can run into errors in this case. Either increase your open file limit, such as with the ulimit -Hn <number> command (Linux/macOS), or set the SF_SOURCE_TRACKING_BATCH_SIZE environment variable to a number significantly lower than the output of ulimit -Hn.

SF_USE_GENERIC_UNIX_KEYCHAIN
(Linux and macOS only) Set to true if you want to use the generic UNIX keychain instead of the Linux libsecret library or macOS keychain. Specify this variable when using Salesforce CLI with ssh or "headless" in a CI environment.
SF_USE_PROGRESS_BAR
For project deploy start set to false to disable the progress bar.

Examples:

SF_USE_PROGRESS_BAR=false.

General Environment Variables

HTTP_PROXY
If you receive an error when you install or update the Salesforce CLI on a computer that’s behind a firewall or web proxy, set this environment variable. Use the URL and port of your company proxy, for example:
1http://username:pwd@proxy.company.com:8080
HTTPS_PROXY
If you receive an error when you install or update the Salesforce CLI on a computer that’s behind a firewall or web proxy, set this environment variable. Use the URL and port of your company proxy, for example:
1http://username:pwd@proxy.company.com:8080
NODE_EXTRA_CA_CERTS
Installs your self-signed certificate. Indicate the fully qualified path to the certificate file name. Then run sf update.

See NODE_EXTRA_CA_CERTS=file for more details.

NODE_TLS_REJECT_UNAUTHORIZED
To allow Node.js to use the self-signed certificate in the certificate chain, indicate 0.