Skip to content

Add fallback support for '/opt/homebrew/bin' on macOS#49721

Closed
froggy-hyun wants to merge 2 commits intospring-projects:mainfrom
froggy-hyun:main
Closed

Add fallback support for '/opt/homebrew/bin' on macOS#49721
froggy-hyun wants to merge 2 commits intospring-projects:mainfrom
froggy-hyun:main

Conversation

@froggy-hyun
Copy link
Copy Markdown
Contributor

@froggy-hyun froggy-hyun commented Mar 24, 2026

Summary

Improve macOS process startup fallback by supporting both Homebrew bin locations:

  • /opt/homebrew/bin (default on Apple Silicon)
  • /usr/local/bin (default on Intel macOS; also common in older or Rosetta-based setups)

Problem

Some macOS code paths retried process startup using only /usr/local/bin.
On Apple Silicon systems, executables installed via Homebrew are typically located under
/opt/homebrew/bin, so process startup could fail when PATH is restricted or does not
include that location.

Changes

  • Added OPT_HOMEBREW_BIN as an additional fallback alongside the existing USR_LOCAL_BIN.
  • Updated macOS fallback handling in:
    • core/spring-boot-docker-compose ProcessRunner
    • test-support DisabledIfProcessUnavailableCondition
    • buildpack CredentialHelper
  • Updated CredentialHelperTests to verify that both fallback candidates are attempted.

Why this is low risk

  • Behavior change is limited to macOS code paths guarded by OS checks.
  • Windows and Linux behavior is unchanged.
  • Existing /usr/local/bin fallback behavior is preserved.

Verification

Executed with JDK 25:

  • :buildpack:spring-boot-buildpack-platform:test --tests org.springframework.boot.buildpack.platform.docker.configuration.CredentialHelperTests
  • :test-support:spring-boot-test-support:test --tests org.springframework.boot.testsupport.process.DisabledIfProcessUnavailableTests
  • :core:spring-boot-docker-compose:test --tests org.springframework.boot.docker.compose.core.ProcessRunnerTests
  • :core:spring-boot-docker-compose:checkstyleMain
  • :test-support:spring-boot-test-support:checkstyleMain
  • :buildpack:spring-boot-buildpack-platform:checkstyleMain

All tests and checks passed.

Add /opt/homebrew/bin as an additional macOS fallback location (alongside
/usr/local/bin) when starting external processes.

The previous fallback assumed /usr/local/bin only, which can fail on Apple
Silicon Homebrew setups in restricted PATH environments (for example IDE or
GUI-launched processes).

Apply the same fallback behavior to:
- docker compose process runner
- DisabledIfProcessUnavailable condition
- docker credential helper startup

Also update CredentialHelperTests to verify both macOS fallback paths are
attempted.

Signed-off-by: 1233day <1233day@naver.com>
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Mar 24, 2026
Comment on lines +107 to +110
private String getCommandName(String command) {
int lastSlash = command.lastIndexOf('/');
return (lastSlash != -1) ? command.substring(lastSlash + 1) : command;
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unrelated to falling back to an additional path. It's also unnecessary as @DisabledIfProcessUnavailable is never used with slashes in the command names as that would likely hurt their portability. Please revert.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. I reverted the command-name extraction and kept the change focused on adding the additional macOS fallback path only.

@wilkinsona wilkinsona added the status: waiting-for-feedback We need additional information before we can continue label Mar 25, 2026
- Remove the helper methods introduced for extracting command/executable names
  and keep this change focused on adding /opt/homebrew/bin as an additional
  macOS fallback path

Signed-off-by: 1233day <1233day@naver.com>
@snicoll snicoll removed status: waiting-for-feedback We need additional information before we can continue labels Mar 26, 2026
@snicoll snicoll changed the title Improve macOS executable fallback for Homebrew paths Add fallback support for '/opt/homebrew/bin' on macOS Apr 3, 2026
@snicoll snicoll self-assigned this Apr 3, 2026
@snicoll snicoll added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Apr 3, 2026
@snicoll snicoll added this to the 4.1.0-RC1 milestone Apr 3, 2026
snicoll pushed a commit that referenced this pull request Apr 3, 2026
Add /opt/homebrew/bin as an additional macOS fallback location when
starting external processes.

The previous fallback assumed /usr/local/bin only, which can fail on
Apple Silicon Homebrew setups in restricted PATH environments (for
example, IDE or UI-launched processes).

Update CredentialHelperTests to verify both macOS fallback paths are
attempted.

See gh-49721

Signed-off-by: 1233day <1233day@naver.com>
@snicoll snicoll closed this in ccfb36c Apr 3, 2026
@snicoll
Copy link
Copy Markdown
Member

snicoll commented Apr 3, 2026

Thanks for this @froggy-hyun - Please note that we couldn't merge your PR as usual because you've added your changes on your main branch rather than creating a dedicated branch for it. Going forward, please create a PR from a separate branch.

@froggy-hyun
Copy link
Copy Markdown
Contributor Author

@snicoll
You’re right, I was in a hurry and made the changes on main.
Thank you :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: enhancement A general enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants