vscode-remote-release
vscode-remote-release copied to clipboard
Allow localEnv in feature environment variables.
Part of the feature spec is a containerEnv property (note - for features, not the devcontainer.json property). It would be nice if it was possible to use the localEnv reference here, so that people who use my feature aren't required to define the environment variable themselves.
Example devcontainer-feature.json
{
"name": "Some Feature",
"id": "some-feature",
"version": "1.0.0",
"description": "A Feature.",
"containerEnv": {
// Currently fails because the substitution isn't performed.
"DISPLAY": "${localEnv:DISPLAY}",
},
// X-11 socket, for window control
{
"source": "/tmp/.X11-unix",
"target": "/tmp/.X11-unix",
"type": "bind"
},
"installsAfter": [
"ghcr.io/devcontainers/features/common-utils",
]
}
This would be great. Hope to see this soon 😁
Sorry but any plan about this? Just ran into this issue:
ERROR: failed to solve: failed to process "\"${localEnv:WAYLAND_DISPLAY}\"": unsupported modifier (W) in substitution
@Clockwork-Muse @fightingsleep The following works for me:
{
"image": "mcr.microsoft.com/devcontainers/base:jammy",
"containerEnv": {
"LOCAL_PATH": "${localEnv:PATH}"
}
}
@hellodword The error looks like you might be using this in something other than a devcontainer.json, e.g., a docker-compose.yml.
@Clockwork-Muse @fightingsleep The following works for me:
{ "image": "mcr.microsoft.com/devcontainers/base:jammy", "containerEnv": { "LOCAL_PATH": "${localEnv:PATH}" } }@hellodword The error looks like you might be using this in something other than a
devcontainer.json, e.g., adocker-compose.yml.
I know I can do that in a devcontainer.json, that's not what I want to do.
I want to be able to reference local environment variables in features, so a .devcontainer/some feature/devcontainer-feature.json file.
Presumably that's what @hellodword tried when they got that error.
Yeah, it's about the devcontainer-feature.json.
Thanks, I was reading too quickly. :)
Since the original example is for DISPLAY: The X11 display is automatically forwarded into the container when DISPLAY is set locally when using the Dev Containers extension. Not as a container env variable, but as part of VS Code's process in the container.
It is now, sure (and the relevant socket mapped too). It was not at the time of writing.
This feature was intended to be more generally useful.
I am now in a situation where a feature installs a binary and when a dev-container with this feature is started, the binary needs to be called and passed the username of the host (WSL in my case). So I would need to set a environment variable to ${localEnv:USER}. This needs currently needs to be done from the devcontainer.json file but it would be nicer to be able to set that in the devcontainer-feature.json file.