[PR #6996] [client] Fix Homebrew install detection for the macOS download URL #30077

Open
opened 2026-08-05 08:10:00 -04:00 by saavagebueno · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbirdio/netbird/pull/6996
Author: @Optic00
Created: 7/30/2026
Status: 🔄 Open

Base: mainHead: codex/fix-macos-homebrew-detection


📝 Commits (2)

  • 97aa28a fix macOS Homebrew update detection
  • 88a57e7 fix macOS Homebrew detection timeout

📊 Changes

2 files changed (+146 additions, -8 deletions)

View changed files

📝 version/url_darwin.go (+35 -8)
version/url_darwin_test.go (+111 -0)

📄 Description

Describe your changes

DownloadUrl passed an entire shell pipeline (list --formula | grep -i netbird) as a single argument to brew, which always failed, so Homebrew installs were never detected and users were always pointed at the pkg installer.

This resolves the brew executable from PATH with fallbacks to the standard Apple Silicon (/opt/homebrew/bin/brew) and Intel (/usr/local/bin/brew) locations, then queries the netbird formula and the netbird-ui cask directly. Homebrew installs now get the install-page URL; non-Homebrew installs keep the architecture-specific pkg URL.

Added tests that stub brew on PATH and cover formula detection, cask detection, and the pkg fallback, asserting the exact arguments passed to brew. Verified with go test -count=1 ./version on macOS.

N/A

Stack

Standalone PR based on main.

Checklist

  • Is it a bug fix
  • Is a typo/documentation fix
  • Is a feature enhancement
  • It is a refactor
  • Created tests that fail without the change (if possible)
  • This change does not modify the public API, gRPC protocols, functionality behavior, CLI / service flags, or introduce a new feature — OR I have discussed it with the NetBird team beforehand (link the issue / Slack thread in the description). See CONTRIBUTING.md.

By submitting this pull request, you confirm that you have read and agree to the terms of the Contributor License Agreement.

Documentation

Select exactly one:

  • I added/updated documentation for this change
  • Documentation is not needed for this change (explain why)

Internal bug fix restoring intended update-URL behavior; no user-facing configuration or documented behavior changes.

Docs PR URL (required if "docs added" is checked)

N/A

Summary by CodeRabbit

  • Bug Fixes

    • Improved macOS download selection for installations made through Homebrew.
    • Correctly recognizes Homebrew formula and cask installations.
    • Preserves architecture-specific package selection when Homebrew is unavailable.
    • Added timeout handling to keep download detection responsive when Homebrew checks are delayed or canceled.
  • Tests

    • Added coverage for Homebrew formula, Homebrew cask, package fallback, architecture selection, and canceled detection scenarios.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbirdio/netbird/pull/6996 **Author:** [@Optic00](https://github.com/Optic00) **Created:** 7/30/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `codex/fix-macos-homebrew-detection` --- ### 📝 Commits (2) - [`97aa28a`](https://github.com/netbirdio/netbird/commit/97aa28a5bdebcc7e1429cce344e2960fa4bcc864) fix macOS Homebrew update detection - [`88a57e7`](https://github.com/netbirdio/netbird/commit/88a57e7d082f0b6ab34097e4c4f5c5ee215ea6cb) fix macOS Homebrew detection timeout ### 📊 Changes **2 files changed** (+146 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `version/url_darwin.go` (+35 -8) ➕ `version/url_darwin_test.go` (+111 -0) </details> ### 📄 Description ## Describe your changes `DownloadUrl` passed an entire shell pipeline (`list --formula | grep -i netbird`) as a single argument to `brew`, which always failed, so Homebrew installs were never detected and users were always pointed at the pkg installer. This resolves the `brew` executable from PATH with fallbacks to the standard Apple Silicon (`/opt/homebrew/bin/brew`) and Intel (`/usr/local/bin/brew`) locations, then queries the `netbird` formula and the `netbird-ui` cask directly. Homebrew installs now get the install-page URL; non-Homebrew installs keep the architecture-specific pkg URL. Added tests that stub `brew` on PATH and cover formula detection, cask detection, and the pkg fallback, asserting the exact arguments passed to `brew`. Verified with `go test -count=1 ./version` on macOS. ## Issue ticket number and link N/A ## Stack <!-- branch-stack --> Standalone PR based on `main`. ### Checklist - [x] Is it a bug fix - [ ] Is a typo/documentation fix - [ ] Is a feature enhancement - [ ] It is a refactor - [x] Created tests that fail without the change (if possible) - [x] This change does **not** modify the public API, gRPC protocols, functionality behavior, CLI / service flags, or introduce a new feature — **OR** I have discussed it with the NetBird team beforehand (link the issue / Slack thread in the description). See [CONTRIBUTING.md](https://github.com/netbirdio/netbird/blob/main/CONTRIBUTING.md#discuss-changes-with-the-netbird-team-first). > By submitting this pull request, you confirm that you have read and agree to the terms of the [Contributor License Agreement](https://github.com/netbirdio/netbird/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT.md). ## Documentation Select exactly one: - [ ] I added/updated documentation for this change - [x] Documentation is **not needed** for this change (explain why) Internal bug fix restoring intended update-URL behavior; no user-facing configuration or documented behavior changes. ### Docs PR URL (required if "docs added" is checked) N/A <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved macOS download selection for installations made through Homebrew. * Correctly recognizes Homebrew formula and cask installations. * Preserves architecture-specific package selection when Homebrew is unavailable. * Added timeout handling to keep download detection responsive when Homebrew checks are delayed or canceled. * **Tests** * Added coverage for Homebrew formula, Homebrew cask, package fallback, architecture selection, and canceled detection scenarios. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
saavagebueno added the pull-request label 2026-08-05 08:10:00 -04:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DYNR/netbird#30077