-
Notifications
You must be signed in to change notification settings - Fork 64
Set workspace specific environment variables
This small tutorial will help you to create a workspace-specific environment, allowing you to set and/or modify environment variables for your project (e.g: put the needed toolchain in front of your PATH
).
This is particularly useful when working on remote machines in order to avoid modifying the environment globally just to work on a given project.
To successfully complete this tutorial, you must do the following:
-
Install Visual Studio Code.
-
Install the Ada extension for VS Code. You can install the Ada extension by searching for 'adacore' in the Extensions view (
Ctrl+Shift+X
). -
Have a an installed GNAT toolchain for your platform (see here for more information on how to install it).
Basically you just need to specify your environment variables and their associated values via the terminal.integrated.env.*
VS Code settings in your workspace file (or your settings.jso
n file), like in the following example:
// Set a workspace-specific environment for Linux/OSX platforms.
"terminal.integrated.env.linux": {
// Set MAIN_NUMBER scenario variable to MAIN_2 directly from the environment
"MAIN_NUMBER": "MAIN_2",
// Set custom GPR_PROJECT_PATH
"GPR_PROJECT_PATH": ".\\imported;${env:GPR_PROJECT_PATH}:"
},
// Set a workspace-specific environment for Windows
"terminal.integrated.env.windows": {
// Set MAIN_NUMBER scenario variable to MAIN_2 directly from the environment
"MAIN_NUMBER": "MAIN_2",
// Set custom GPR_PROJECT_PATH
"GPR_PROJECT_PATH": ".\\imported;${env:GPR_PROJECT_PATH}:"
}
You can check the Custom Env code sample in this repository. This code sample shows how to edit the needed VS Code settings in order to set custom environment variables that are specific to your workspace.