DataGrip 2023.1 Help

Path variables

Use path variables to define absolute paths to resources that are not part of a specific project. These external resources may be located in different places on the computers of your teammates. This is why user-defined custom path variables are not stored as project settings, but as global IDE settings. Once configured, such path variables will have the same value for any project that you open with your instance of DataGrip.

Create a new path variable

  1. Press Control+Alt+S to open the IDE settings and select Appearance & Behavior | Path Variables.

    Path Variables dialog
  2. Click the Add button, enter the name and value of the variable, and click OK to apply the changes.

You can use path variables to specify paths and command-line arguments for external tools and in some run configurations.

For example, you can define a path variable that points to the location of some data source (like a CSV file) that is not stored in your project. If you use this path variable in a run configuration that you share with your project, others can define the correct value for this path variable in their environment and be sure that the run configuration will work for them.

Another example is defining a path variable for the attached directory that you use in your project. On another machine, the directory might be stored in a different location. To make sure your project with the attached directory can be shared and used on another machine, use path variables to define the location of attached directory.

Refer to the variable as $var_name$ in fields and configuration files that accept path variables.

DataGrip also has the following built-in path variables:

$USER_HOME$

The current user's home directory.

$PROJECT_DIR$

The current project's root directory.

Ignore path variables

Whenever you open or update a project, DataGrip checks for unresolved path variables. If the IDE detects any, it will ask you to define values for them. If you are not going to use files or directories with the unresolved path variables, you can add them to the list of ignored variables.

You can also use the list of ignored variables when a program argument passed to the run/debug configuration has the same format as a path variable (for example, an environment variable).

  1. Press Control+Alt+S to open the IDE settings and select Appearance & Behavior | Path Variables.

  2. Add the names that DataGrip shouldn't consider to be path variables to the Ignored Variables field.

  3. Click OK to apply the changes.

Example: creating a new path variable

You may have an attached directory that is located outside your project directory. This directory is attached to your project, and the path to this library is included in the .iml file of your project. However, this path should not be absolute, because the location on this directory may be different on your teammates' computers. In this case, you can create the PATH_TO_ATT_DIR variable:

  1. Press Control+Alt+S to open the IDE settings and select Appearance & Behavior | Path Variables.

  2. Click the Add button.

  3. In the Add Variable dialog, type the PATH_TO_ATT_DIR variable, and its value that points to the library location on your disk.

  4. Share the .iml file through your version control system.

  5. After your teammates update their projects from VCS, they will change the PATH_TO_ATT_DIR variable value so that it points to the library location on their computers.

Last modified: 16 January 2023