composer-patches-plugin
composer-patches-plugin copied to clipboard
Does not support Windows
Installation of this package under Windows fails with this error:
Maintaining patches
'which' is not recognized as an internal or external command,
operable program or batch file.
[Netresearch\Composer\Patches\Exception]
Cannot find the 'patch' executable command - use your o/s package manager like 'sudo yum install patch'
There is an alternative to which
in PowerShell: Get-Command
.
To get the path to a program this command could be used: (Get-Command patch).Source
.
Though, patch
does not exist under Windows so that could be an issue as well.
A OS independent implementation could be used, for example xdiff_file_patch
.
Please check yourself for a possible solution from our network, and create MR if one of those fixes your problem:
- https://github.com/zVPS/composer-patches-plugin/commit/559e55e554ef2a384345695e63b6bab4c7aac52e
- https://github.com/MartijnHarte/composer-patches-plugin/commit/fe3e404877096090eefe1c6fa991a8edcbd8fb00
- https://github.com/dimdimych/composer-patches-plugin/commit/22daabcf1e79597afb84e884811beac35b493b4f
- https://github.com/zeyus/composer-patches-plugin/commit/332e5a9d5d65ffff3befecf35f363e0312e5f36f
- https://github.com/zeyus/composer-patches-plugin/commit/11fbacb4b4995a01610b0454655b28da695a2fa1
@CybotTM
my proposed fix/MR for the problem is #44. my MR adds the which/where bridge and also tries to simply run patch
without running where before.
to collect the information to have everything on one place:
MR #17 introduced this bug as it requires to have the which
binary which results in a path which is checkable with is_executable
. on windows which
returns a "linux" path like /usr/bin/patch
if which
was installed with git for windows. is_executable
returns false for this path.
so enhancing the error message introduced a break on all systems which have no which
command. as far as i see most of the solutions @CybotTM mentioned will fix the problem. from my point of view the which
/ where
bridge solutions are the better than the others.
- so the easiest fix is the simply remove the change introduced with #17
- to keep the change but also allow to run it on windows the which/where bridge is a simple solution.
- to allow to config the path to
patch
incomposer.json
could also be a way. as there is no "sub-namespace" inpatches
, the fastest way would be to add the config to the info for each patch. which is quite uncool from DX but it would work. - good addition would be to simply try to run
patch
and only if that fails try to locate it with which/where.
Thank you @c33s , #44 is merged.