Add fallback support for '/opt/homebrew/bin' on macOS#49721
Add fallback support for '/opt/homebrew/bin' on macOS#49721froggy-hyun wants to merge 2 commits intospring-projects:mainfrom
Conversation
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 <[email protected]>
| private String getCommandName(String command) { | ||
| int lastSlash = command.lastIndexOf('/'); | ||
| return (lastSlash != -1) ? command.substring(lastSlash + 1) : command; | ||
| } |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Agreed. I reverted the command-name extraction and kept the change focused on adding the additional macOS fallback path only.
- 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 <[email protected]>
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 <[email protected]>
|
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. |
|
@snicoll |
|
I suggest that documentation is added "somewhere", otherwise this change might lead to hard to debug issues when people have installed coreutils. Or the order should be switched around:
|
|
Thanks, @sdavids. Can you expand a bit on the "hard to debug issues" please? I'd like to better understand the problem. Before the text that your link highlights, the coreutils link says that "Commands also provided by macOS […] have been installed with the prefix |
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 whenPATHis restricted or does notinclude that location.
Changes
OPT_HOMEBREW_BINas an additional fallback alongside the existingUSR_LOCAL_BIN.core/spring-boot-docker-composeProcessRunnertest-supportDisabledIfProcessUnavailableConditionbuildpackCredentialHelperCredentialHelperTeststo verify that both fallback candidates are attempted.Why this is low risk
/usr/local/binfallback 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:checkstyleMainAll tests and checks passed.