Microsoft/vscode

Devcontainer setup ad-hoc parsing fails on Rocky 8.5

Open

#232.159 geöffnet am 24. Okt. 2024

Auf GitHub ansehen
 (20 Kommentare) (0 Reaktionen) (1 zugewiesene Person)TypeScript (10.221 Forks)batch import
buggood first issuelinuxremote

Repository-Metriken

Stars
 (74.848 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 11h 43m) (1.000 gemergte PRs in 30 T)

Beschreibung

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version: 1.92.0 (Commit: b1c0a14de1414fcdaa400695b4db1c0799bc3124)
  • OS Version: Rocky Linux 8.5

The check-requirements-linux.sh script that runs as part of a devcontainer setup wants to parse the OS version from /etc/os-release. That file "is a newline-separated list of environment-like shell-compatible variable assignments" (see man os-relase on Linux). The script tries to parse the value it wants here, by running:

OS_ID="$(cat /etc/os-release | grep -Eo 'ID=([^"]+)' | sed -n '1s/ID=//p')"

This looks for a key-value pair of the form ID=value and strips out the ID= part. It assumes the pair is not of the form ID="value", which appears to be permitted by the file format, and appears in the wild in Rocky 8.5 where the relevant line reads:

ID="rocky"

In that case the grep command will fail to match the line and the value of OS_ID will be empty, resulting in a non-zero exit code of 1.

This could be fixed by changing the variable assignment to:

OS_ID=$(source /etc/os-release && echo $ID)

This will run a subshell in which the values in the file get assigned to environment variables, which removes any surrounding " marks. Since this runs in a subshell the current shell's environment will not pick up these variables.

Steps to Reproduce:

  1. Start a devcontainer built from Rocky 8.5.

Contributor Guide