loft-sh / devpod

Codespaces but open-source, client-only and unopinionated: Works with any IDE and lets you use any cloud, kubernetes or just localhost docker.
https://devpod.sh
Mozilla Public License 2.0
9.45k stars 342 forks source link

Container env vars not updated by features while setting up #1354

Open Benjamin-Etheredge opened 1 week ago

Benjamin-Etheredge commented 1 week ago

What happened?
When using base devcontainers and features to install additional tooling, the environment variables set by the features are not correctly set for other features and commands. If a feature defines a new containerEnv, it will work. But if it extends an existing environment variable, it is not updated. I suspect this breaks a TON of features if one depends on another.

What did you expect to happen instead?
Environment variable adjustment from features to work for other features and commands

How can we reproduce the bug? (as minimally and precisely as possible)

My devcontainer.json:

{
    "image": "mcr.microsoft.com/devcontainers/base:noble",
    "features": {
        "ghcr.io/devcontainers/features/python:1": {},
        "ghcr.io/devcontainers/features/rust:1": {}
    },
    "postStartCommand": "env"
}

The following will show PYTHON_PATH and other variables set by the feature show up correctly, but PATH is not updated to the correct version for subsequent features or commands. At the start of features, it shows the correct values, but in the features, the path is incorrect as shown by the rust feature printing out PATH during setup.

Local Environment:

DevPod Provider:

Anything else we need to know?
The variables are set correctly in the terminal after starting the devcontainer. The issue is only present during feature setup and commands like postCreateCommand.

bkneis commented 1 day ago

Thanks @Benjamin-Etheredge for reporting this issue! I can confirm the problematic behaviour, I'll try get around to fixing this soon