Environment Variables
The command-line client and the client bindings use a set of environment variables in order to communicate with the API server and to store state on the current default project and directory. These settings are usually set when you run dx login
and can be later changed through other dx commands. To display the currently used settings in human-readable format, you can use the dx env
command:
To print the bash commands for setting the environment variables to match what dx
is using, you can run the same command with the --bash
flag.
Running a dx
command from the command-line will not (and cannot) overwrite your shell's environment variables, so it stores them in a file at ~/.dnanexus_config/environment
.
Configuration File Prioritization
The following is an ordered list of which DNAnexus utilities load values from configuration sources:
Command line options (if available)
Environment variables already set in the shell
~/.dnanexus_config/environment.json (dx configuration file)
Hardcoded defaults
Overriding the dx Configuration File
Note that the dx
command will always prioritize the environment variables that are currently set in the shell. This means that if you have set your environment variable for DX_SECURITY_CONTEXT and subsequently use dx login
to log in as a different user, it will still use the original environment variable. If not run in a script, it will print a warning to stderr whenever the environment variables and its stored state have a mismatch. To get out of this situation, the best approach is often to run source ~/.dnanexus_config/unsetenv
. Setting environment variables is generally an approach within a shell script or part of a job environment in the cloud.
In the interaction below, environment variables have already been set, but the user then uses dx
to log in which is still overridden by the shell's environment variables.
Clearing dx-set Variables
If you instead want to discard the values which dx has stored, the command dx clearenv
removes the dx
-generated configuration file ~/.dnanexus_config/environment.json
for you.
Command Line Options
Most dx commands have the following additional flags to temporarily override the values of the respective variables.
For example, you can temporarily override the current default project used:
Last updated