Skip to content

Fix devcontainer check-requirements-linux.sh to handle quoted ID values in /etc/os-release#311182

Open
Jah-yee wants to merge 1 commit intomicrosoft:mainfrom
Jah-yee:fix/devcontainer-rocky-linux-os-id-parsing
Open

Fix devcontainer check-requirements-linux.sh to handle quoted ID values in /etc/os-release#311182
Jah-yee wants to merge 1 commit intomicrosoft:mainfrom
Jah-yee:fix/devcontainer-rocky-linux-os-id-parsing

Conversation

@Jah-yee
Copy link
Copy Markdown

@Jah-yee Jah-yee commented Apr 18, 2026

Good day

Summary

The devcontainer setup script check-requirements-linux.sh fails to parse OS_ID on Rocky Linux 8.5 because it uses quoted values in /etc/os-release (e.g., ID="rocky").

Root Cause

The original grep+sed approach:

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

This only matches unquoted formats (ID=rocky) and returns empty for quoted formats (ID="rocky"), causing the script to exit with code 1.

Fix

Use source /etc/os-release which properly handles both quoted and unquoted values:

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

This runs in a subshell so it doesn't pollute the current shell environment.

Testing

Verified the fix works correctly:

  • Old approach on quoted format: OS_ID='' (empty/fail)
  • New approach on quoted format: OS_ID='rocky'
  • New approach on unquoted format: OS_ID='rocky'

Related

Fixes #232159

Thank you for your attention. If there are any issues or suggestions, please leave a comment and I will address them promptly.

Warmly,
RoomWithOutRoof

…es in /etc/os-release

The script failed to parse OS_ID on Rocky Linux 8.5 where /etc/os-release
uses quoted values (e.g., ID="rocky"). The grep+sed approach only matched
unquoted formats.

Fix by sourcing /etc/os-release directly, which handles both quoted and
unquoted values correctly.

Fixes microsoft#232159
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.

Devcontainer setup ad-hoc parsing fails on Rocky 8.5

2 participants