Skip to content

Setting up Environment Variables

David Refoua edited this page Apr 25, 2019 · 16 revisions

Setting up environment variables

1. How to properly set-up the %CMDER_ROOT% variable?

Many tasks with Cmder will need you to set the correct %CMDER_ROOT% environment variable path in your system.

Follow the instructions below to define it:

  1. Press ⊞ Win + Pause / Break to open the System Preferences, then click on Advanced system settingsEnvironment Variables.
  2. In System variables, look for a variable named CMDER_ROOT. If it's not already defined, click on New… to add a new variable as follows.
    • When you've installed portable Cmder in your user profile, set it under User variables instead.
    • If the variable already exists, only check if the value is correct, replace the value if it's not.
      There is no need to create duplicate variables.
  3. Set the environment variable called CMDER_ROOT to point to the path of your Cmder root installation folder
    (e.g. C:\apps\cmder, C:\Program Files (x86)\Cmder, or wherever you've installed Cmder.)

2. Setting up %ConEmuDir%

Cmder comes with ConEmu as the console emulator. In case %ConEmuDir% is also not defined in your system, you could follow the steps 1-3 from above, and use the following values when creating your variable:

  • Variable Name: %ConEmuDir%
  • Value: [cmder_root]\vendor\conemu-maximus5 e.g.: C:\apps\cmder\vendor\conemu-maximus5

3. Adding to %PATH%

We recommend adding your Cmder installation directory to the path variable. It has the benefit of launching Cmder from the explorer, the terminal, and the start menu.

Here's the quick steps to add Cmder to %PATH%:

  1. Open the system environmental variables (Win + Pause/BreakAdvanced system settingsEnvironment Variables.)

  2. Select PATH in either User variables or System variables, depending on whether you've put Cmder on a user folder (e.g. C:\Users\Samuel\Dropbox\apps\Cmder) or in a system-wide directory (e.g. C:\apps\Cmder).

    cmder_path_variable_selection

  3. Click Edit… to display the PATH variable.

    Depending on your Windows version, you might see different dialogs.
    If you see the following window, simply click New and type in your Cmder directory, example:

    C:\bin\Cmder

    cmder_path_variable

    If you see a single-line field, simply append the Cmder directory, like this:

    ;C:\bin\Cmder

    So that C:\test1;C:\test2 now becomes C:\test1;C:\test2;C:\bin\Cmder.

  4. Hit OK to save the results.

  5. You might need to Sign off and login again in order to make Windows take the new PATH into effect.

For more information, please also read this guide.

4. Making sure that it works

  1. Open a new Cmd terminal.

  2. Type the following:

where cmder.exe

Tip: You can also query any other executable name, such as flute.exe, bash.exe, etc. to find their paths.

  1. Check the results:
  • If the executable is present in any of the %PATH% environment variable paths, you'll get the full path to the executable (multiple if found in more than one paths).

    cmder-path
  • Otherwise, you'll get the following error message:

    INFO: Could not find files for the given pattern(s).
    

 

Description

What is this referring to?

Cmder can be used in a variety of different settings, and supports many external options and configurations to fit with your needs.

When integrating, modding and/or using Cmder, you may often find the need of referring to the absolute path in which the Cmder is installed, e.g.: C:\apps\cmder or C:\Program Files\Cmder. We usually refer to this directory as [cmder_root] as in our documents and the Wiki.

When you set the system %CMDER_ROOT% environment variable, you assign a fixed path to configuration files and avoid correcting the path each time you change the directory -- and if it changes, you only have to modify the variable once, instead of going through different configuration files and changing the values there.

Comparison of both methods

Here's a list of comparison between the two methods:

  • You can skip setting up the %CMDER_ROOT% variable, as long as:

    • the path isn't going to change (e.g. you won't move the directory)
    • you refer to the path by other files only once (or a few times at most)
    • or maybe you are just testing things out before setting it up properly to use alongside your configuration files.
  • The only situation that we advise against setting the environment variable is when you use Cmder on a temporary computer (e.g. launching Cmder from a USB stick on university lab computers).

It is, however, strongly recommended to set a properly defined environment variable to point to the installation directory of Cmder.

Note: As a rule of thumb, if you enable Context-menu integration, you should also make sure that the %CMDER_ROOT% environment variable is also defined.

Examples

You can use %CMDER_ROOT% in place of the [cmder_root] placeholder wherever you see it in the documents and the Wiki. Example:

  "terminal.integrated.shell.windows": "cmd.exe",

  "terminal.integrated.shellArgs.windows": [
      "/k", "[cmder_root]\\vendor\\init.bat"
  ],

becomes:

  "terminal.integrated.shell.windows": "cmd.exe",

  "terminal.integrated.shellArgs.windows": [
      "/k", "%CMDER_ROOT%\\vendor\\init.bat"
  ],