composer-patches-plugin icon indicating copy to clipboard operation
composer-patches-plugin copied to clipboard

Does not support Windows

Open TheDevMinerTV opened this issue 3 years ago • 1 comments

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.

TheDevMinerTV avatar Dec 01 '21 10:12 TheDevMinerTV

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 avatar Dec 22 '21 12:12 CybotTM

@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 in composer.json could also be a way. as there is no "sub-namespace" in patches, 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.

c33s avatar Dec 13 '22 19:12 c33s

Thank you @c33s , #44 is merged.

CybotTM avatar Dec 20 '22 13:12 CybotTM