Skip to content

fix(update-check): detect nix and linuxbrew installs on linux - #344

Open
BenyD wants to merge 2 commits into
Infisical:mainfrom
BenyD:fix/linux-update-instructions-nix-linuxbrew
Open

fix(update-check): detect nix and linuxbrew installs on linux#344
BenyD wants to merge 2 commits into
Infisical:mainfrom
BenyD:fix/linux-update-instructions-nix-linuxbrew

Conversation

@BenyD

@BenyD BenyD commented Jul 31, 2026

Copy link
Copy Markdown

Description 📣

On Linux, getUpdateInstructions never inspects the executable path outside the npm check. It falls through to getLinuxPackageManager(), which only probes which package managers happen to exist on the machine, so a Nix install on Debian or Ubuntu is told to run apt-get install infisical for a binary living in the immutable Nix store.

Homebrew-on-Linux hits the same gap, since /home/linuxbrew/.linuxbrew/ does not match the /homebrew/ substring the darwin branch checks for.

This mirrors the existing darwin handling: Nix returns no instruction rather than a wrong one, matching the darwin nix returns empty case already in the tests. Linuxbrew returns the brew command.

Fixes the Linux side of #226. The macOS path in that report already returns no instruction for Nix installs, via the existing darwin nix returns empty handling.

Type ✨

  • Bug fix
  • New feature
  • Improvement
  • Breaking change
  • Documentation

Tests 🛠️

Added two cases to TestGetUpdateInstructions, and two steps to the integration-linux job following the existing /tmp/homebrew and npm patterns.

Worth noting for review: the linux nix returns empty unit case only asserts anything on a machine that actually has a package manager installed. On a dev Mac it passes with or without this change, because getLinuxPackageManager() returns empty there anyway. On the ubuntu runner, where apt-get is present, it fails without the fix. That is why the integration step matters here, and I left a comment above it explaining the same thing.

go test ./packages/util/ -run TestGetUpdateInstructions -v
--- PASS: TestGetUpdateInstructions/linux_nix_returns_empty (0.00s)
--- PASS: TestGetUpdateInstructions/linux_linuxbrew (0.00s)
PASS
ok      github.com/Infisical/infisical-merge/packages/util   0.523s

Verified the new tests are meaningful by stashing the change in check-for-update.go and re-running: linux_linuxbrew fails as expected.


The linux branch of getUpdateInstructions never inspected execPath outside
the npm check, falling through to getLinuxPackageManager(), which only
probes which package managers exist on the machine. A nix install on
Debian or Ubuntu was told to run 'apt-get install infisical' for a binary
in the immutable nix store.

Homebrew-on-Linux hit the same gap, since /home/linuxbrew/.linuxbrew/ does
not match the /homebrew/ substring the darwin branch checks.

Mirrors the existing darwin behaviour: nix returns no instruction rather
than a wrong one. Adds unit cases and integration steps to the
integration-linux job.

Partially addresses Infisical/infisical#226
@infisical-cla-app

infisical-cla-app Bot commented Jul 31, 2026

Copy link
Copy Markdown

CLA satisfied. All contributors have signed the current CLA. The cla/signed check is passing.

@greptile-apps

greptile-apps Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR improves Linux update guidance based on the resolved executable path.

  • Suppresses package-manager instructions for Nix-store installations.
  • Recommends the Homebrew upgrade command for Linuxbrew installations.
  • Adds unit and Linux integration coverage for both installation paths.

Confidence Score: 4/5

The PR appears safe to merge, with a non-blocking opportunity to constrain Linuxbrew detection to an actual path component.

The intended Nix and canonical Linuxbrew paths are handled correctly, but the bare Linuxbrew substring can produce incorrect update guidance for unrelated executable paths containing that text.

Files Needing Attention: packages/util/check-for-update.go

Important Files Changed

Filename Overview
packages/util/check-for-update.go Adds Nix and Linuxbrew path detection; the Linuxbrew match is broader than necessary and can misclassify unrelated paths.
packages/util/check-for-update_test.go Adds focused unit cases for canonical Nix and Linuxbrew executable paths.
.github/workflows/test-update-instructions.yml Adds Linux integration checks proving Nix suppression and Linuxbrew guidance on an apt-enabled runner.

Reviews (1): Last reviewed commit: "fix(update-check): detect nix and linuxb..." | Re-trigger Greptile

Comment thread packages/util/check-for-update.go Outdated
Review feedback: a bare "linuxbrew" substring also classified unrelated
paths such as /opt/linuxbrew-tools as Homebrew installs.

Uses "linuxbrew/" rather than a fully bounded "/linuxbrew/" so both real
layouts still match: the multi-user default (/home/linuxbrew/.linuxbrew)
and the single-user prefix (~/.linuxbrew), where the component is preceded
by a dot rather than a slash.

Adds a single-user case and a negative case for /opt/linuxbrew-tools, plus
a notExpected field on the test table to express the negative assertion.
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.

1 participant