MacOS and Composer patches
After purchasing a 2025 Mac, projects using Composer and cweagans/composer-patches are no longer working correctly. Patches working in other environments are no longer applied.
What is composer-patches?
It's an optional Composer component that enables automated and standardized application of patches to projects. It's widely used with more advanced Drupal 10/11 projects.
What's the problem?
macOS comes with a proprietary version of patch (Apple-flavored). This version is used by default in the terminal and other utilities (like Composer), and it's not compatible with cweagans/composer-patches.
which patch
> /usr/bin/patch
patch -v
> patch 2.0-12u11-Apple
How to fix the problem?
To solve the problem, you need to install gpatch, the most widely used version of the patch utility. The g in gpatch refers to GNU (a collection of open software widely used on Linux).
Installing gpatch
To install this Composer-compatible version, the easiest way is to use Homebrew. Simply follow the official instructions.
- Install Homebrew : https://brew.sh/
- Install
gpatch: https://formulae.brew.sh/formula/gpatch
Loading gpatch automatically instead of the macOS version.
In the .zprofile file, make sure that Homebrew is loaded correctly:
# Set PATH, MANPATH, etc., for Homebrew.
eval "$(/opt/homebrew/bin/brew shellenv)"