fix: preserve HAB_AUTH_TOKEN through sudo and fix Windows hab PATH#46
Open
fix: preserve HAB_AUTH_TOKEN through sudo and fix Windows hab PATH#46
Conversation
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>
980d7f3 to
6e14877
Compare
sean-sype-simmons
approved these changes
Apr 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Linux/macOS
sudo hab pkg installwas dropping theHAB_AUTH_TOKENenvironment variable becausesudodoes not preserve env vars by default. The token was correctly set viaexport, 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\Habitatbut that directory was never added toGITHUB_PATHin the Configure Habitat step, causing subsequent steps to fail withhab is not recognized.Fix
sudo hab pkg installinvocations tosudo -E hab pkg installso the environment (includingHAB_AUTH_TOKEN) is preserved across the sudo boundary.C:\ProgramData\HabitattoGITHUB_PATHin the Configure Habitat (Windows) step so thehabbinary is available in subsequent steps.Files Changed
.github/workflows/grype-hab-package-scan.yml