Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/workflows/test-update-instructions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,22 @@ jobs:
output=$($HOME/.npm-global/lib/node_modules/@infisical/cli/bin/update-hint)
echo "Output: $output"
echo "$output" | grep -q "npm update -g @infisical/cli" || (echo "Expected npm instruction, got: $output" && exit 1)

# The runner has apt-get, so without install-source detection this falls
# through to the apt instruction. Asserting empty output is what makes
# this a real regression test for the nix case.
- name: Test nix path detection
run: |
mkdir -p $HOME/nix/store/abc123-infisical-0.0.1/bin
cp update-hint $HOME/nix/store/abc123-infisical-0.0.1/bin/update-hint
output=$($HOME/nix/store/abc123-infisical-0.0.1/bin/update-hint)
echo "Output: $output"
[ -z "$output" ] || (echo "Expected no instruction for nix, got: $output" && exit 1)

- name: Test linuxbrew path detection
run: |
mkdir -p $HOME/linuxbrew/.linuxbrew/bin
cp update-hint $HOME/linuxbrew/.linuxbrew/bin/update-hint
output=$($HOME/linuxbrew/.linuxbrew/bin/update-hint)
echo "Output: $output"
echo "$output" | grep -q "brew update" || (echo "Expected brew instruction, got: $output" && exit 1)
9 changes: 9 additions & 0 deletions packages/util/check-for-update.go
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,15 @@ func getUpdateInstructions(goos string, execPath string) string {
if isNpm {
return "To update, run: npm update -g @infisical/cli"
}
// Nix-managed binaries live in the immutable store. The system package
// manager did not install them and cannot update them, so stay quiet
// rather than print a command that will not work.
if strings.Contains(p, "/nix/store/") {
return ""
}
if strings.Contains(p, "linuxbrew") {
Comment thread
BenyD marked this conversation as resolved.
Outdated
return "To update, run: brew update && brew upgrade infisical"
}
pkgManager := getLinuxPackageManager()
switch pkgManager {
case "apt-get":
Expand Down
12 changes: 12 additions & 0 deletions packages/util/check-for-update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,18 @@ func TestGetUpdateInstructions(t *testing.T) {
execPath: "/home/user/.npm-global/lib/node_modules/@infisical/cli/bin/infisical",
expected: "npm update -g @infisical/cli",
},
{
name: "linux nix returns empty",
goos: "linux",
execPath: "/nix/store/abc123-infisical-0.41.90/bin/infisical",
expectEmpty: true,
},
{
name: "linux linuxbrew",
goos: "linux",
execPath: "/home/linuxbrew/.linuxbrew/bin/infisical",
expected: "brew update && brew upgrade infisical",
},
}

for _, tt := range tests {
Expand Down