Skip to content

fix: preserve HAB_AUTH_TOKEN through sudo and fix Windows hab PATH#46

Open
Nik08 wants to merge 1 commit intomainfrom
fix/grype-sudo-preserve-env-and-windows-path
Open

fix: preserve HAB_AUTH_TOKEN through sudo and fix Windows hab PATH#46
Nik08 wants to merge 1 commit intomainfrom
fix/grype-sudo-preserve-env-and-windows-path

Conversation

@Nik08
Copy link
Copy Markdown

@Nik08 Nik08 commented Apr 2, 2026

Problem

Linux/macOS

sudo hab pkg install was dropping the HAB_AUTH_TOKEN environment variable because sudo does not preserve env vars by default. The token was correctly set via export, but the hab process running under sudo never received it, resulting in 401 Unauthorized from Builder.

Windows

The hab binary is installed to C:\ProgramData\Habitat but that directory was never added to GITHUB_PATH in the Configure Habitat step, causing subsequent steps to fail with hab is not recognized.

Fix

  • Linux/macOS: Changed all three sudo hab pkg install invocations to sudo -E hab pkg install so the environment (including HAB_AUTH_TOKEN) is preserved across the sudo boundary.
  • Windows: Added C:\ProgramData\Habitat to GITHUB_PATH in the Configure Habitat (Windows) step so the hab binary is available in subsequent steps.

Files Changed

  • .github/workflows/grype-hab-package-scan.yml

@Nik08 Nik08 added the ai-assisted Changes made with AI assistance label Apr 2, 2026
Linux/macOS: `sudo hab pkg install` was dropping the HAB_AUTH_TOKEN
environment variable because sudo does not preserve env vars by default.
The token was correctly set via `export`, but the hab process running
under sudo never received it, resulting in 401 Unauthorized from Builder.

Fix: use `sudo -E` to preserve the environment across all three
`sudo hab pkg install` invocations (Linux build install, Linux download,
macOS download).

Windows: hab binary was installed to C:\ProgramData\Habitat but that
directory was never added to GITHUB_PATH in the Configure Habitat step,
causing subsequent steps to fail with 'hab is not recognized'.

Fix: add C:\ProgramData\Habitat to GITHUB_PATH.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Nikita Mathur <nikita.mathur@progress.com>
@Nik08 Nik08 force-pushed the fix/grype-sudo-preserve-env-and-windows-path branch from 980d7f3 to 6e14877 Compare April 2, 2026 10:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-assisted Changes made with AI assistance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants