Skip to content

shells inside devcontainers do not have remoteEnv environment variables set #49199

@gilesknap

Description

@gilesknap

Reproduction steps

  1. Launch zed and open a project with the following snippet in it's devcontainer.json
    "remoteEnv": {
        // Allow X11 apps to run inside the container
        "DISPLAY": "${localEnv:DISPLAY}",
        // Put things that allow it in the persistent cache
        "PRE_COMMIT_HOME": "/cache/pre-commit",
        "UV_CACHE_DIR": "/cache/uv",
        "UV_PYTHON_CACHE_DIR": "/cache/uv-python",
        // Make a venv that is specific for this workspace path as the cache is shared
        "UV_PROJECT_ENVIRONMENT": "/cache/venv-for${localWorkspaceFolder}",
        // Do the equivalent of "activate" the venv so we don't have to "uv run" everything
        "VIRTUAL_ENV": "/cache/venv-for${localWorkspaceFolder}",
        "PATH": "/cache/venv-for${localWorkspaceFolder}/bin:${containerEnv:PATH}"
    },
  1. project: open remote --> connect to devcontainer --> default
  2. launch a terminal
  3. env | grep UV_
  4. result is no match
  5. for an example that exhibits this issue see https://github.com/gilesknap/2ndBrain

Current vs. Expected behavior

Current: no environment variables from the remoteEnv configuration are available inside the devcontainer
Expected: all the env vars should be available

I believe the problem is that the zed server is being started with docker (or podman) exec, at least that is what it looks like here:

let mut docker_args = vec!["exec".to_string()];
for env_var in ["RUST_LOG", "RUST_BACKTRACE", "ZED_GENERATE_MINIDUMPS"] {
if let Some(value) = std::env::var(env_var).ok() {
docker_args.push("-e".to_string());
docker_args.push(format!("{}='{}'", env_var, value));
}
}
docker_args.extend([
"-u".to_string(),
self.connection_options.remote_user.to_string(),
"-w".to_string(),
self.remote_dir_for_server.clone(),
"-i".to_string(),
self.connection_options.container_id.to_string(),
]);
let val = remote_binary_relpath
.display(self.path_style())
.into_owned();
docker_args.push(val);
docker_args.push("proxy".to_string());
docker_args.push("--identifier".to_string());
docker_args.push(unique_identifier);
if reconnect {
docker_args.push("--reconnect".to_string());
}
let mut command = util::command::new_command(self.docker_cli());
command
.kill_on_drop(true)
.stdin(Stdio::piped())
.stdout(Stdio::piped())
.stderr(Stdio::piped())
.args(docker_args);

I can reproduce this issue with the devcontainer CLI and no zed as follows:

devcontainer up --docker-path podman
podman exec container_name bash
env | grep UV_ # no matches

Whereas using the devcontainer cli to launch a shell in the container gets the correct environment:

devcontainer up --docker-path podman
devcontainer exec --docker-path podman bash
env | grep UV_ # matches!!

Zed version and system specs

Zed: v0.223.3+stable.152.59dfdea1697030fd39de6c92172ff192d013a984 (Zed)
OS: Linux Wayland ubuntu 25.10
Memory: 30.3 GiB
Architecture: x86_64
GPU: NVIDIA GeForce RTX 3090 || NVIDIA || 590.48.01

Attach Zed log file

2026-02-14T22:46:01+00:00 INFO [zed] ========== starting zed version 0.223.3+stable.152.59dfdea1697030fd39de6c92172ff192d013a984, sha 59dfdea ==========
2026-02-14T22:46:01+00:00 INFO [crashes] spawning crash handler process
2026-02-14T22:46:01+00:00 INFO [extension_host] extensions updated. loading 4, reloading 0, unloading 0
2026-02-14T22:46:01+00:00 INFO [gpui::platform::linux::platform] activate is not implemented on Linux, ignoring the call
2026-02-14T22:46:01+00:00 INFO [auto_update] Auto Update: checking for updates
2026-02-14T22:46:01+00:00 WARN [project::agent_server_store] Registry agent 'github-copilot' not found in ACP registry
2026-02-14T22:46:01+00:00 INFO [workspace::persistence] Got 1 breakpoints from database at path: /home/giles/code/2ndBrain/src/brain/agents/router.py
2026-02-14T22:46:01+00:00 INFO [workspace::persistence] Got 1 breakpoints from database at path: /home/giles/code/2ndBrain/tests/test_cli.py
2026-02-14T22:46:01+00:00 INFO [workspace::persistence] Got 1 breakpoints from database at path: /home/giles/code/2ndBrain/tests/test_migrate.py
2026-02-14T22:46:01+00:00 INFO [client] set status on client 0: Authenticating
2026-02-14T22:46:01+00:00 INFO [gpui::platform::blade::blade_renderer] Initializing Blade pipelines for surface SurfaceInfo { format: Bgra8Unorm, alpha: PreMultiplied }
2026-02-14T22:46:01+00:00 INFO [workspace] Rendered first frame
2026-02-14T22:46:01+00:00 INFO [crashes] connected to crash handler process after 100ms
2026-02-14T22:46:01+00:00 INFO [crashes] crash handler registered
2026-02-14T22:46:01+00:00 INFO [util] set environment variables from shell:/usr/bin/zsh, path:/home/giles/bin:/home/giles/.local/bin:/home/giles/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin
2026-02-14T22:46:01+00:00 INFO [zed::zed] Using GPU: GpuSpecs { is_software_emulated: false, device_name: "NVIDIA GeForce RTX 3090", driver_name: "NVIDIA", driver_info: "590.48.01" }
2026-02-14T22:46:01+00:00 WARN [language] unrecognized capture name 'function_name' in Python injections TreeSitter query (suppress this warning by prefixing with '')
2026-02-14T22:46:01+00:00 WARN [language] unrecognized capture name 'comment' in Python injections TreeSitter query (suppress this warning by prefixing with '
')
2026-02-14T22:46:01+00:00 INFO [node_runtime] Node runtime install_if_needed
2026-02-14T22:46:02+00:00 WARN [node_runtime] using Zed managed Node.js at /home/giles/.local/share/zed/node/node-v24.11.0-linux-x64 since checking system Node.js failed with error: node at /usr/bin/node is too old. want: 22.0.0, got: 20.19.4
2026-02-14T22:46:02+00:00 INFO [client] set status on client 633681: Authenticated
2026-02-14T22:46:02+00:00 INFO [lsp] starting language server process. binary path: "/home/giles/.local/share/zed/node/node-v24.11.0-linux-x64/bin/node", working directory: "/home/giles/code/2ndBrain", args: ["/home/giles/.local/share/zed/languages/json-language-server/node_modules/vscode-langservers-extracted/bin/vscode-json-language-server", "--stdio"]
2026-02-14T22:46:02+00:00 INFO [lsp] starting language server process. binary path: "/home/giles/.local/share/zed/node/node-v24.11.0-linux-x64/bin/node", working directory: "/home/giles/code/2ndBrain", args: ["/home/giles/.local/share/zed/languages/basedpyright/node_modules/basedpyright/langserver.index.js", "--stdio"]
2026-02-14T22:46:03+00:00 INFO [lsp] starting language server process. binary path: "/home/giles/.local/share/zed/languages/ruff/ruff-0.15.1/ruff-x86_64-unknown-linux-gnu/ruff", working directory: "/home/giles/code/2ndBrain", args: ["server"]
2026-02-14T22:46:03+00:00 INFO [project::lsp_store] language server 1: unregistered workspace/DidChangeWatchedFiles capability with id 16b...2636
2026-02-14T22:46:04+00:00 INFO [recent_projects::remote_servers] SSH: Watching User Config at: "/home/giles/.ssh/config"
2026-02-14T22:46:04+00:00 INFO [recent_projects::remote_servers] SSH: Watching Global Config at: "/etc/ssh/ssh_config"
2026-02-14T22:46:07+00:00 INFO [dev_container::devcontainer_api] find_devcontainer_configs: Found 1 configurations
2026-02-14T22:46:08+00:00 INFO [dev_container::devcontainer_api] Found devcontainer cli on $PATH, using it
2026-02-14T22:46:08+00:00 INFO [dev_container::devcontainer_api] Running full devcontainer up command: "devcontainer" "--docker-path" "podman" "up" "--workspace-folder" "/home/giles/code/2ndBrain" "--config" "/home/giles/code/2ndBrain/.devcontainer/devcontainer.json"
2026-02-14T22:46:11+00:00 INFO [remote::transport::docker] Remote platform discovered: Some(RemotePlatform { os: Linux, arch: X86_64 })
2026-02-14T22:46:11+00:00 INFO [remote::transport::docker] $SHELL is not set, checking passwd for user
2026-02-14T22:46:11+00:00 INFO [remote::transport::docker] Remote shell discovered: /bin/bash
2026-02-14T22:46:12+00:00 INFO [remote_server] (remote server) starting up with PID 112:
pid_file: "/root/.local/share/zed/server_state/workspace-25/server.pid", log_file: "/root/.local/share/zed/logs/server-workspace-25.log", stdin_socket: "/root/.local/share/zed/server_state/workspace-25/stdin.sock", stdout_socket: "/root/.local/share/zed/server_state/workspace-25/stdout.sock", stderr_socket: "/root/.local/share/zed/server_state/workspace-25/stderr.sock"
2026-02-14T22:46:12+00:00 INFO [crashes] (remote server) spawning crash handler process
2026-02-14T22:46:12+00:00 INFO [util] (remote server) updating SHELL environment variable to value from passwd entry: "/bin/bash"
2026-02-14T22:46:12+00:00 INFO [remote_server] (remote server) gpui app started, initializing server
2026-02-14T22:46:12+00:00 INFO [util] (remote server) set environment variables from shell:/bin/bash, path:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
2026-02-14T22:46:12+00:00 INFO [remote_server] (remote server) accepting new connections
2026-02-14T22:46:12+00:00 INFO [remote_server] (remote server) accepted new connections
2026-02-14T22:46:12+00:00 INFO [zed::zed] Using GPU: GpuSpecs { is_software_emulated: false, device_name: "NVIDIA GeForce RTX 3090", driver_name: "NVIDIA", driver_info: "590.48.01" }
2026-02-14T22:46:12+00:00 INFO [remote_server] (remote server) Got new node settings: NodeBinarySettings { path: None, npm_path: None, ignore_system_version: false }
2026-02-14T22:46:12+00:00 INFO [project::lsp_store] stopping language server json-language-server
2026-02-14T22:46:12+00:00 INFO [project::lsp_store] stopping language server basedpyright
2026-02-14T22:46:12+00:00 INFO [project::lsp_store] stopping language server ruff
2026-02-14T22:46:12+00:00 WARN [project.json-schema] Schema request failed: LSP store has been dropped
2026-02-14T22:46:12+00:00 ERROR [lsp] Server reset connection for a request "textDocument/diagnostic" id 11
2026-02-14T22:46:12+00:00 WARN [project::lsp_store] Get diagnostics via json-language-server failed: Server reset the connection
2026-02-14T22:46:12+00:00 ERROR [crates/project/src/lsp_store.rs:4364] pulling diagnostics

Caused by:
Get diagnostics via json-language-server failed: Server reset the connection
2026-02-14T22:46:12+00:00 INFO [crashes] (remote server) connected to crash handler process after 100ms
2026-02-14T22:46:12+00:00 INFO [crashes] (remote server) crash handler registered
2026-02-14T22:46:13+00:00 INFO [extension_host::headless_host] (remote server) failed to load extension: html, No extension manifest found for extension html
2026-02-14T22:46:13+00:00 INFO [extension_host] Uploading extension html to RemotePathBuf { style: Posix, string: "/root/.local/share/zed/remote_extensions/uploads/html" }
2026-02-14T22:46:13+00:00 INFO [extension_host] Finished uploading extension html
2026-02-14T22:46:13+00:00 INFO [extension_host::headless_host] (remote server) Loaded language server: vscode-html-language-server

Relevant Zed settings

settings are almost entirely default except

use_podman: true

Relevant Keymap

keymap.json

(for AI issues) Model provider details

No response

If you are using WSL on Windows, what flavor of Linux are you using?

None

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:dev containersFeedback for Dev Containersfrequency:commonBugs that happen for at least a third of the users across all platforms and kinds of usageplatform:linux/waylandLinux Waylandpriority:P2Average run-of-the-mill bugs

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions