cli icon indicating copy to clipboard operation
cli copied to clipboard

How to specify the default value with colon for localEnv.

Open huxuan opened this issue 1 year ago • 1 comments

Hi DevContainers Team,

The case for me is to set the index url for pip, so what I do is something like

{
    ...
    "remoteEnv": {
        "PIP_INDEX_URL": "${localEnv:PIP_INDEX_URL:https://pypi.org/simple}"
    }
}

I perfer a default value to handle the cases that PIP_INDEX_URL does not exist. But it turns out that when the env does not exist, the corresponding env in the vscode context will be set to https rather than https://pypi.org/simple. Any clues to make it happen?

Seems it is related to the code here: https://github.com/devcontainers/cli/blob/f7d4c853bf8c284d784173f3e915a34d961b0b55/src/spec-common/variableSubstitution.ts#L85 If I understand correctly, one option could be setting the split limit to 1, and maybe another approach is that we can avoid set the env in the context if the value is empty.

Thanks in advance.

huxuan avatar Jan 16 '24 06:01 huxuan

Any updates? Please let me know if there is anything more I can do.

huxuan avatar May 09 '24 12:05 huxuan