Search code examples
angularangular-materialmaterial-components

Building Material Components Repo Locally - patch' is not recognized as an internal or external command


I have forked Angular Material repo from https://github.com/angular/components, and cloned it. I have Yarn, Node and Bazel installed per DEV_ENVIRONMENT.md in the repo.

I have also installed MSYS2 following instructions. If I run yarn run-dev, I get this error:

'patch' is not recognized as an internal or external command,
operable program or batch file.
Error: exec: 'patch' is not recognized as an internal or external command,
operable program or batch file.

    at Object.error (E:\ONEMLI\MASAUSTU\Material\c2\components\node_modules\shelljs\src\common.js:110:27)
    at execSync (E:\ONEMLI\MASAUSTU\Material\c2\components\node_modules\shelljs\src\exec.js:120:12)
    at String._exec (E:\ONEMLI\MASAUSTU\Material\c2\components\node_modules\shelljs\src\exec.js:223:12)
    at String.<anonymous> (E:\ONEMLI\MASAUSTU\Material\c2\components\node_modules\shelljs\src\common.js:335:23)
    at applyPatch (E:\ONEMLI\MASAUSTU\Material\c2\components\tools\postinstall\apply-patches.js:119:26)
    at applyPatches (E:\ONEMLI\MASAUSTU\Material\c2\components\tools\postinstall\apply-patches.js:56:3)
    at main (E:\ONEMLI\MASAUSTU\Material\c2\components\tools\postinstall\apply-patches.js:43:5)

with exit code: 1

If I debug, I see that

function applyPatch(patchFile) {
  if (isFilePatched(patchFile)) {
    console.info('Patch: ' + patchFile + ' has been applied already. Skipping..');
    return;
  }

  shelljs.cat(patchFile).exec('patch -p0');
  captureFileAsPatched(patchFile);
}

this function throws an error.

On this line which throws error,

 shelljs.cat(patchFile).exec('patch -p0');

pathFile has this value  `"E:\\ONEMLI\\MASAUSTU\\Material\\c2\\components\\tools\\postinstall\\devmode-es2020-bazel.patch".`

It seems like problem has something to do with Bazel. I tried installing it directly, with Chocolatey and Bazelisk. But the problem remains.

What can I do to solve this problem?


Solution

  • What worked for me is Git for Windows: https://git-scm.com/download/win It has patch.exe in Git\usr\bin folder. Just add it to your path will work!