composer-patches: Requires GNU patch 2.7 for correct behavior, but `composer-patches` does not warn the user about this!

@cweagans holy shit, the need for brew install gpatch took me many hours to figure out, because for a particular project TravisCI builds were succeeding but local builds were failing. 😬 Can we make cweagans/composer-patches detect the patch version, and explicitly warn the user that any version below 2.7 may result in silent failures?

_Originally posted by @wimleers in https://github.com/cweagans/composer-patches/issues/172#issuecomment-674860594_

The solution:

brew install gpatch (you’ll need Homebrew installed for that to work (https://brew.sh))

_Originally posted by @cweagans in https://github.com/cweagans/composer-patches/issues/172#issuecomment-587147692_

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 20 (5 by maintainers)

Commits related to this issue

Most upvoted comments

This is still a problem. A colleague of mine wasted another hour on this.

To answer your question about detecting GNU patch:

$ which patch
/usr/local/bin/patch
$ /usr/bin/patch --version
patch 2.5.8
Copyright (C) 1988 Larry Wall
Copyright (C) 2002 Free Software Foundation, Inc.

This program comes with NO WARRANTY, to the extent permitted by law.
You may redistribute copies of this program
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.

written by Larry Wall and Paul Eggert
$ /usr/local/bin/patch --version
GNU patch 2.7.6
Copyright (C) 2003, 2009-2012 Free Software Foundation, Inc.
Copyright (C) 1988 Larry Wall

License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Larry Wall and Paul Eggert

(/usr/bin/patch ships with macOS, /usr/local/bin/patch was installed by brew install gpatch.)

→ I am pretty sure that you could do something like preg_match('/^GNU patch/', …) on the output of patch --version.