Environment variables
Editing Windows Environment Variables using Rapid Environment Editor
Environment variables are a crucial part of the Windows operating system, allowing you to store and manage settings that are used by various applications and system components. In this guide, we will walk you through the process of editing Windows environment variables using the Rapid Environment Editor, a powerful and user-friendly tool.
What are Environment Variables?
Environment variables are values that are stored in the Windows registry and are used to configure various aspects of the operating system and applications. They can be thought of as a set of named values that are available to all applications and system components. Environment variables can be used to store settings such as:
- Path to executable files (e.g.,
PATH
) - Temporary directory (e.g.,
TEMP
) - User name and profile directory (e.g.,
USERNAME
,USERPROFILE
) - System directory (e.g.,
SYSTEMROOT
)
What is the PATH Variable?
The PATH
variable is one of the most important environment variables in Windows. It specifies the directories that the system searches for executable files when you run a command or application. The PATH
variable is a list of directories separated by semicolons (;
), and the system searches each directory in the order they are listed.
For example, if you have the following PATH
variable:
C:\Windows\System32;C:\Windows;C:\Program Files\Java\jdk1.8.0_241\bin
The system will search for executable files in the following order:
C:\Windows\System32
C:\Windows
C:\Program Files\Java\jdk1.8.0_241\bin
Editing Environment Variables using Rapid Environment Editor
To edit environment variables using the Rapid Environment Editor, follow these steps:
- Download and install the Rapid Environment Editor from the official website: https://www.rapidee.com/en/about
- Launch the Rapid Environment Editor by searching for it in the Start menu or by running the executable file (
RapidEE.exe
) - In the Rapid Environment Editor, you will see a list of all environment variables on your system, including the
PATH
variable. - To edit the
PATH
variable, select it from the list and click on the “Edit” button. - In the “Edit Variable” dialog box, you can add, remove, or modify directories in the
PATH
variable. For example, you can add a new directory to the end of the list by clicking on the “Add” button and entering the directory path. - Once you have made changes to the
PATH
variable, click on the “OK” button to save the changes.
Restarting the Shell
After editing environment variables, including the PATH
variable, you need to restart your shell for the changes to take effect. This is because the shell caches environment variables when it starts, and changing them does not automatically update the cache.
To restart your shell, follow these steps:
- Close all command prompt or PowerShell windows
- Open a new command prompt or PowerShell window
- Verify that the changes to the
PATH
variable have taken effect by running the commandecho %PATH%
(in Command Prompt) or$env:PATH
(in PowerShell)
Tips and Tricks
- When editing environment variables, be careful not to delete or modify system-critical variables, as this can cause system instability or crashes.
- Use the Rapid Environment Editor to manage environment variables, as it provides a user-friendly interface and automatic syntax checking.
- Remember to restart your shell after editing environment variables to ensure that the changes take effect.
By following this guide, you should now be able to edit Windows environment variables using the Rapid Environment Editor, including the PATH
variable. Remember to restart your shell after making changes to ensure that they take effect.
Editing PATH on Mac
I havn’t found a GUI tool as nice as Rapid Environment Editor on Mac, but then its generally easier to accomplish these kinds of changes from the Mac terminal.
On macOS, the /etc/paths.d directory allows you to add custom paths to the system-wide PATH environment variable without modifying global configuration files directly. Each file in /etc/paths.d
contains a list of paths that are appended to the PATH variable.
Steps to Add New Paths
-
Open Terminal: You can use Terminal to create and edit files in
/etc/paths.d
. -
Create a New File in
/etc/paths.d
:
• Use a text editor to create a new file in the /etc/paths.d
directory.
• Each file in this directory should contain one path per line. The file name can be anything that indicates the purpose of the paths it contains.
For example, to add /usr/local/custom/bin
to your PATH, you can create a file named custom-paths:
sudo touch /etc/paths.d/custom-paths
- Edit the File:
• Open the newly created file with a text editor:
sudo nano /etc/paths.d/custom-paths
• Add the new path, one per line. For example:
/usr/local/custom/bin
/opt/someother/bin
- Save and Exit:
• Save the file (for nano, press CTRL + O to write the changes, and CTRL + X to exit).
- Apply Changes:
• The changes will be applied automatically when a new shell session starts. To apply them immediately, you can close and reopen Terminal, or manually source the updated paths with:
source /etc/profile
Notes
• The order of files in /etc/paths.d
affects the order of paths in the PATH variable. Paths are appended in the order that the files are read.
• Each file should be owned by root and have appropriate permissions to ensure system integrity.
Example
If you want to add multiple custom directories, create multiple files or list all paths in a single file. For instance, to add /usr/local/custom/bin
and /opt/tools/bin
, you could
echo "/usr/local/custom/bin" | sudo tee -a /etc/paths.d/custom-paths
echo "/opt/tools/bin" | sudo tee -a /etc/paths.d/custom-paths
This method keeps your system organized and makes it easier to manage custom paths.
Editing Environment Variables on Mac (not PATH)
To quickly list all current variables you can use the env
command from a terminal, to view the current value of just one variable run the following
echo $VARIABLE_NAME
Temporary variables
If you’re looking to temporarily set a variable you can do so and check it with
export MY_VAR="hello"
echo $MY_VAR # Output: hello
Permanent variables
To permanently set them so they survive reboots you’ll need to edit your shell startup file, if you’re using a recent (Catalina or newer) MacOS this will be ~/.zshrc
Edit your ~/.zshrc file:
nano ~/.zshrc
Add lines like:
export MY_VAR="hello"
export PATH="$PATH:/custom/path"
Save and reload:
source ~/.zshrc
If you’re using an older MacOS (or have elected to use bash) you’ll need to edit ~/.bash_profile
or ~/.bashrc
instead.
Note that these variables are specific to your terminal sessions, if you need to setup system environment variables that apply to all users on your Mac you’ll need to use launchctl
which is beyond the scope of this guide.