Set workspace specific environment variables - AdaCore/ada_language_server GitHub Wiki
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.
Prerequisites
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).
How to set environment variables
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.json
file), like in the following example:
// Set a workspace-specific environment for OSX platforms.
"terminal.integrated.env.osx": {
// Set MAIN_NUMBER scenario variable to MAIN_2 directly from the environment
"MAIN_NUMBER": "MAIN_2",
// Set custom GPR_PROJECT_PATH
"GPR_PROJECT_PATH": "${workspaceFolder}/imported:${env:GPR_PROJECT_PATH}:"
},
// Set a workspace-specific environment for Linux 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": "${workspaceFolder}/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": "${workspaceFolder}\\imported;${env:GPR_PROJECT_PATH}:"
}
Example
You can check the Custom Env code sample in this repository to have an example of workspace that sets a custom environment.