-
Notifications
You must be signed in to change notification settings - Fork 394
Open
Labels
containersIssue in vscode-remote containersIssue in vscode-remote containers
Description
The VS Code Extension, when attaching to a running Container, it writes some env. var. to /etc/environment. This breaks sudo and su as the HOME env. var. is no longer set to the appropriate target user's home dir. (or /root for sudo) and cause a lot of issues.
One should NEVER set HOME env. var. on /etc/environment, as it will override that env. var. for everyone in the system. Luckily the env. var. USER is still correct (may be it got set after /etc/environment setting).
- VSCode Version:
Version: 1.106.1 (system setup)
Commit: cb1933bbc38d329b3595673a600fab5c7368f0a7
Date: 2025-11-16T10:20:23.745Z
Electron: 37.7.0
ElectronBuildId: 12781156
Chromium: 138.0.7204.251
Node.js: 22.20.0
V8: 13.8.258.32-electron.0
OS: Windows_NT x64 10.0.26100
- Local OS Version: Windows_NT x64 10.0.26100
- Remote OS Version:
NAME="CentOS Stream"
VERSION="10 (Coughlan)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="10"
PLATFORM_ID="platform:el10"
PRETTY_NAME="CentOS Stream 10 (Coughlan)"
ANSI_COLOR="0;31"
LOGO="fedora-logo-icon"
CPE_NAME="cpe:/o:centos:centos:10"
HOME_URL="https://centos.org/"
VENDOR_NAME="CentOS"
VENDOR_URL="https://centos.org/"
BUG_REPORT_URL="https://issues.redhat.com/"
REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux 10"
REDHAT_SUPPORT_PRODUCT_VERSION="CentOS Stream"
- Remote Extension/Connection Type: Dev Containers
- Logs:
$ cat /etc/environment
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
container="oci"
TERM="xterm"
HOME="/home/etirtara"
USER="etirtara"
HOSTNAME="55455cb8862c"
Steps to Reproduce:
- Prepare a Container Image that has multiple user and can perform
sudoandsu. - Start that Container (I used
podman) on Remote Host. - Ensure the /etc/environment is empty.
- Use VS Code Extension DevContainer
Attach to Running Container. - Check the content of /etc/environment is now populated.
- The modified time stamp of /etc/environment match the time the VS Code server in the Container is started.
- Now do either
suto another user orsudo -ito become root. Then toprintenv, the env. var. HOME is set to/home/etirtarabecause it's overridden by /etc/environment settings.
Does this issue occur when you try this locally?: Yes/No
Does this issue occur when you try this locally and all extensions are disabled?: Yes/No
Metadata
Metadata
Assignees
Labels
containersIssue in vscode-remote containersIssue in vscode-remote containers