How to use Relative Paths in Run/Debug Configurations?

Is it possible to use Relative Paths in Run/Debug configurations? For example, Mocha test configurations seem to require Absolute paths which means if you move or copy the project all the test configurations break. I'd like to:

1) Define the location of the Mocha tool relative to the working directory. This is important when using different mocha versions and --compilers on the project level. Otherwise, for ES2015 you have to create long options paths to Babel, etc.

2) Define the location of the test file itself relative to the working directory

I've tried various formats:


What is the proper way to specify tool location and test file location relative to the current project's working directory?

Thanks for any help with this.

Comment actions Permalink

No, you can't enter relative paths there.

In .xml file that stores Mocha run configuration, path to tests dir, etc. is stored relative to project root, using $PROJECT_DIR$ macro:



so the tests path doesn't change when you move/copy your project to different location

Path to mocha  package is unfortunately saved as an absolute path, but WebStorm detects Mocha package in project dir, if any, and offers it in paths dropdown in 'Mocha package' field

Comment actions Permalink

Now (2019.1) it is possible to use relative path for working directory in run/debug configurations in Linux. It looks like "foo/bar_test". Will it also possible in Windows?

Also, it is possible to use relative path there for VM options in Linux. It looks like "./foo/bar_test". Will it possible in Windows?

Comment actions Permalink

This is a big limitation when you want to share a project. The path in my machine is not the same as other developers.
For instance, to the mvnw wrapper, I create a shell script run configuration, but I'm forced to provide the absolute path to the script, despite there is a working directory field.  Using the $PROJECT_DIR$ doesn't work.

Any recommendations for this use case?

Comment actions Permalink

>Using the $PROJECT_DIR$ doesn't work.


what do you mean saying this doesn't work? as it's written above, absolute paths specified in UI are stored using $PROJECT_DIR$  in .xml files so the configuration is actually shareable

Comment actions Permalink

I got it now. My confusion was because I can't use the $PROJECT_DIR$ macro on the UI. But when I select a script file form the project dir, the absolute path is replaced by that macro on workspace.xml. Thanks.

<option name="SCRIPT_PATH" value="$PROJECT_DIR$/mvnw" />
<option name="SCRIPT_WORKING_DIRECTORY" value="$PROJECT_DIR$" />
Comment actions Permalink

how can i save absolute path?

I set <option name="EXE_PATH" value="C:/Program Files (x86)/IIS Express/iisexpress.exe" />

but it always change to <option name="EXE_PATH" value="$PROJECT_DIR$/../../../../Program Files (x86)/IIS Express/iisexpress.exe" />



Comment actions Permalink

is EXE_PATH a new path variable (Settings | Appearance & Behavior | Path Variables)? they are always saved with absolute paths for me...


Please sign in to leave a comment.