Environment variables

You can configure certain properties for your DFINITY Canister SDK execution environment using environment variables.

This section lists the environment variables that are currently supported with examples of how to use them. In most cases, you can set environment variables for a session by executing an command in the terminal or by adding a line similar to the following to your .profile file:

export DFX_TELEMETRY_DISABLED=1

CANISTER_CANDID_PATH_{canister.name}

Use environment variables with the CANISTER_CANDID_PATH prefix to reference the path to the Candid description file for the canisters that are listed as dependencies in the dfx.json file for your project.

For example, if you have a whoami_assets canister that lists whoami under the dependencies key, you could use the CANISTER_CANDID_PATH_whoami_assets environment variable to refer to the location of the whoami.did file, which for local development might be:

$PROJECT_ROOT/.dfx/local/canisters/whoami/whoami.did

CANISTER_ID_{canister.name}

Use environment variables with the CANISTER_ID prefix to reference the canister identifier for each canister in the dfx.json file for your project.

For example, if you have a linkedup project that consists of the linkedup and connectd canisters, you could use the CANISTER_ID_linkedup and CANISTER_ID_connectd environment variables to refer to the canister identifiers—for example ryjl3-tyaaa-aaaaa-aaaba-cai and rrkah-fqaaa-aaaaa-aaaaq-cai—created for your project.

DFX_CONFIG_ROOT

Use the DFX_CONFIG_ROOT environment variable to specify a different location for storing the .cache and .config subdirectories for dfx.

By default, the .cache and .config directories are located in the home directory for your development environment. For example, on macOS the default location is in the /Users/<YOUR-USER-NAME> directory. Use the DFX_CONFIG_ROOT environment variable to specify a different location for these directories.

DFX_CONFIG_ROOT=~/ic-root

DFX_INSTALLATION_ROOT

Use the DFX_INSTALLATION_ROOT environment variable to specify a different location for the dfx binary if you are not using the default location for your operating system.

The .cache/dfinity/uninstall.sh script uses this environment variable to identify the root directory for your DFINITY Canister SDK installation.

DFX_TELEMETRY_DISABLED

Use the DFX_TELEMETRY_DISABLED environment variable to opt-out of having data collected about dfx usage.

By default, dfx is configured to collect anonymous—that is, no identifying information such as IP addresses or user information—data about dfx command activity and errors. Collecting anonymous data is enabled by default in an effort to improve the developer experience based on usage patterns and behavior.

If you want to prevent the collection of data about dfx usage, however, you can explicitly opt-out by setting the DFX_TELEMETRY_DISABLED environment variable to one.

DFX_TELEMETRY_DISABLED=1

DFX_VERSION

Use the DFX_VERSION environment variable to identify a specific version of the DFINITY Canister SDK that you want to install.

DFX_VERSION=0.6.26 sh -ci "$(curl -fsSL https://sdk.dfinity.org/install.sh)"