Skip to content

fix: parse OS_ID from /etc/os-release correctly on Rocky Linux 8.5 and similar distros - #328629

Open
0x5t4l1n wants to merge 1 commit into
microsoft:mainfrom
0x5t4l1n:fix/check-requirements-rocky-os-id-quotes
Open

fix: parse OS_ID from /etc/os-release correctly on Rocky Linux 8.5 and similar distros#328629
0x5t4l1n wants to merge 1 commit into
microsoft:mainfrom
0x5t4l1n:fix/check-requirements-rocky-os-id-quotes

Conversation

@0x5t4l1n

@0x5t4l1n 0x5t4l1n commented Aug 2, 2026

Copy link
Copy Markdown

Summary\n\nFixes #232159check-requirements-linux.sh used grep -Eo 'ID=([^\"]+)' to parse OS_ID from /etc/os-release. This pattern only matches unquoted values (ID=rocky). Rocky Linux 8.5 ships ID=\"rocky\" (with surrounding double-quotes), which the grep did not match, leaving OS_ID empty. The script then exited with code 1, aborting devcontainer setup.\n\nFix: Replace the ad-hoc grep | sed pipeline with . /etc/os-release && echo \"${ID:-}\" in a subshell. POSIX source (. file) correctly handles all value formats defined by the os-release spec — quoted, unquoted, and escaped.\n\ndiff\n-OS_ID=\"$(cat /etc/os-release | grep -Eo 'ID=([^\"]+)' | sed -n '1s/ID=//p')\"\n+OS_ID=\"$(. /etc/os-release && echo \"${ID:-}\")\"\n\n\n## Test plan\n- [ ] Rocky Linux 8.5 container: devcontainer setup completes without exit code 1\n- [ ] Ubuntu / Debian / Alpine: OS_ID still resolves correctly\n- [ ] NixOS: early exit still triggers\n- [ ] /etc/os-release absent: OS_ID is empty (unchanged behaviour)\n\n🤖 Generated with Claude Code

Resolves microsoft#232159. The script used grep -Eo 'ID=([^"]+)' which requires
the value to be unquoted. Rocky Linux 8.5 ships ID="rocky" (with
double-quotes), so the grep matched nothing, OS_ID was empty, and the
script exited with code 1 preventing devcontainer setup.

Fix: replace the ad-hoc grep/sed pipeline with `source /etc/os-release`
in a subshell. The shell assignment strips surrounding quotes and handles
all conformant /etc/os-release formats as specified by man os-release.
Copilot AI review requested due to automatic review settings August 2, 2026 19:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants