How do I change the working directory for my program

Trying out the Clion EAP on the Mac. How does one change the current working directory for a launched program? It appears to be set to the output directory of the binaries.


This can be changed via the Run -> Edit Configurations... dialog, just like Idea.

The mix of needing to make changes to CMakeLists.txt for so much of the configuration just threw me, and I've been hunting for a way to change it there, but this bit at least is consistent with the other IDEs, which is good.

Hopefully they'll improve the rest of the Project Settings in a similar fashion.


The "Working Directory" is where the executable starts. Modifying the "Working Directory" in the Configurations setting tells Clion to change to the "Working Directory" after the executable starts execution.

If you want to change where the executable starts execution you will need to add a line to the CMakesLists.txt file.

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})

add_executable(TimeServer ${SOURCE_FILES})

Position in the cmakes file is important. If you add the set command after the add_executable it will not work. It must come before.


These answers are relatively old. Not sure when the feature was added but there's a very nice UI way to set the current working directory now.

I made a YouTube tutorial for my COSC1030 (Beginning C++) students but the solution is the same for everyone: https://youtu.be/dTtZEAfh_LM

If you know your CLion fairly well and don't need a demo, here's a short-hand version: Edit Configurations (from drop-down menu at top right of screen), enter the directory you want to use in Working Directory or select via "..." pop-up.