Newer Version Available

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

Environment Variables

Set environment variables to configure aspects of the sf executable of Salesforce CLI.

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=54.0 sf retrieve metadata --metadata ApexClass
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_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_DISABLE_AUTOUPDATE or SF_AUTOUPDATE_DISABLE (either var works)
Set to true to disable the auto-update feature of Salesforce CLI. By default, the CLI periodically checks for and installs updates.
SF_DISABLE_SOURCE_MEMBER_POLLING
Set to true to disable polling of your org’s SourceMember object when you run the sf deploy|retrieve metadata 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 CI/CD 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 sf deploy|retrieve metadata commands are unreliable, and it’s up to you to synchronize your source.

Warning

SF_DISABLE_TELEMETRY
Set to true to disable Salesforce CLI from collecting usage information, user environment information, and crash reports.
SF_DNS_TIMEOUT
Specifies the number of seconds that the env create commands wait for a response when checking whether an org is connected. If the commands don’t receive a response in that time, they time out. Default value is 3.
SF_DOMAIN_RETRY
Specifies the time, in seconds, that Salesforce 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_LOG_LEVEL
Sets the level of messages that Salesforce 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 means 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_MDAPI_TEMP_DIR
Places the files (in metadata format) in the specified directory when you run some CLI commands, such as sf metadata retrieve. 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_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_ORG_CUSTOM_METADATA_TEMPLATES
Specifies either a local directory or a cloned GitHub repository that contains the default custom code templates used by the sf generate project 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_ORG_CUSTOM_METADATA_TEMPLATES=https://github.com/mygithubacct/salesforcedx-templates
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_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_ORG_METADATA_REST_DEPLOY
Set to true to make Salesforce CLI use the Metadata REST API for deployments. By default, the 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 sf deploy metadata command to keep polling the SourceMember object before the command times out. The sf deploy metadata command polls the SourceMember object to track what's changed between your local source and the org after the deploy completes. The CLI calculates a time-out for each sf deploy metadata 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_TARGET_DEV_HUB
Specifies the username or alias of your default Dev Hub org so you don’t have to use the --target-dev-hub CLI flag. Overrides the value of the target-dev-hub configuration variable.

Example of setting it to an alias:

1SF_TARGET_DEV_HUB=myDevHub

Example of setting it to a username:

1SF_TARGET_DEV_HUB=mydevhuborg@example.com
SF_TARGET_ORG
Specifies the username or alias 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_USE_PROGRESS_BAR
Set to false to disable the progress bar for the sf deploy metadata command.

Example:

1SF_USE_PROGRESS_BAR=false