Skip to content

Commit 9e09d36

Browse files
authored
Update docs for localEnv (devcontainers#370)
* Update docs for `localEnv` I used localEnv today and hit some minor points of confusion. Notably, any local variables need to be set _before_ launching VS Code for them to be picked up (confirmed in this issue: microsoft/vscode-remote-release#3456 (comment)) I also added a macOS example for how to set local variables - I think this might be helpful as a demonstration of use cases for `localEnv` If approved here, i'll also update the spec repo with the same changes * Update json_reference.md
1 parent ac617dd commit 9e09d36

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Diff for: _implementors/json_reference.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ Variables can be referenced in certain string values in `devcontainer.json` in t
164164

165165
| Variable | Properties | Description |
166166
|:------------------|:------------|:------------|
167-
| `${localEnv:VARIABLE_NAME}` | Any | Value of an environment variable on the **host machine** (in this case, called `VARIABLE_NAME`). Unset variables are left blank. For example, this would set a variable to your local home folder on Linux / macOS or the user folder on Windows:<br/> `"remoteEnv": { "LOCAL_USER_PATH": "${localEnv:HOME}${localEnv:USERPROFILE}" }` <br /><br /> A default value for when the environment variable is not set can be given with `${localEnv:VARIABLE_NAME:default_value}`. <br /><br /> ⚠️ For a cloud service, the host is in the cloud rather than your local machine. |
167+
| `${localEnv:VARIABLE_NAME}` | Any | Value of an environment variable on the **host machine** (in the examples below, called `VARIABLE_NAME`). Unset variables are left blank. <br /><br /> ⚠️ Clients (like VS Code) may need to be **restarted** to pick up newly set variables. <br /><br /> ⚠️ For a cloud service, the host is in the cloud rather than your local machine. <br /><br /> **Examples** <br /><br /> **1.** Set a variable containing your local home folder on Linux / macOS or the user folder on Windows:<br/> `"remoteEnv": { "LOCAL_USER_PATH": "${localEnv:HOME}${localEnv:USERPROFILE}" }`. <br /><br /> A default value for when the environment variable is not set can be given with `${localEnv:VARIABLE_NAME:default_value}`. <br /><br /> **2.** In modern versions of macOS, default configurations allow setting local variables with the command `echo 'export VARIABLE_NAME=my-value' >> ~/.zshenv`. |
168168
| `${containerEnv:VARIABLE_NAME}` | `remoteEnv` | Value of an existing environment variable inside the container once it is up and running (in this case, called `VARIABLE_NAME`). For example:<br /> `"remoteEnv": { "PATH": "${containerEnv:PATH}:/some/other/path" }` <br /><br /> A default value for when the environment variable is not set can be given with `${containerEnv:VARIABLE_NAME:default_value}`. |
169169
| `${localWorkspaceFolder}` | Any | Path of the local folder that was opened in the `devcontainer.json` supporting service / tool (that contains `.devcontainer/devcontainer.json`). |
170170
| `${containerWorkspaceFolder}` | Any | The path that the workspaces files can be found in the container. |

0 commit comments

Comments
 (0)