From 4a03fc0ba22a7aa4198e754ac6e4e898c21b6933 Mon Sep 17 00:00:00 2001 From: Chili Palmer Date: Mon, 6 Jul 2026 21:06:37 +0200 Subject: [PATCH] fix: added homebrew to path for git --- lib/bds/git.ex | 12 +++++++++++- test/bds/git_test.exs | 3 +++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/bds/git.ex b/lib/bds/git.ex index 0b11b38..9dc0795 100644 --- a/lib/bds/git.ex +++ b/lib/bds/git.ex @@ -429,11 +429,21 @@ defmodule BDS.Git do env: %{ "GIT_TERMINAL_PROMPT" => "0", "GCM_INTERACTIVE" => "never", - "GIT_SSH_COMMAND" => ssh_command + "GIT_SSH_COMMAND" => ssh_command, + "PATH" => git_path() } ] end + # A macOS app launched from Finder inherits a minimal PATH and never sources + # the login shell, so Homebrew tools like git-lfs (called from git hooks) are + # not found. Prepend the standard Homebrew bin dirs to the inherited PATH. + defp git_path do + ["/opt/homebrew/bin", "/usr/local/bin", System.get_env("PATH") || ""] + |> Enum.reject(&(&1 == "")) + |> Enum.join(":") + end + defp upstream_branch(project_dir, opts) do case run_git( project_dir, diff --git a/test/bds/git_test.exs b/test/bds/git_test.exs index f4d7491..6f37e5a 100644 --- a/test/bds/git_test.exs +++ b/test/bds/git_test.exs @@ -193,6 +193,9 @@ defmodule BDS.GitTest do assert fetch_opts[:env]["GIT_TERMINAL_PROMPT"] == "0" assert fetch_opts[:env]["GCM_INTERACTIVE"] == "never" assert fetch_opts[:env]["GIT_SSH_COMMAND"] =~ "BatchMode=yes" + # git hooks (e.g. git-lfs pre-push) must find Homebrew tools even when the + # app is launched from Finder with a minimal PATH. + assert fetch_opts[:env]["PATH"] =~ "/opt/homebrew/bin" end test "fetch returns structured auth errors with provider guidance", %{project: project} do