WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.52k stars 4.21k forks source link

Build: `npm install` fails on CI because of `react-native-gesture-handler` #34377

Closed gziolo closed 3 years ago

gziolo commented 3 years ago

Description

Any change to the lock file breaks most of the CI jobs, example:

https://github.com/WordPress/gutenberg/pull/34350/checks?check_run_id=3442150008

Related PR: #34350, #34373.

Screen Shot 2021-08-30 at 09 43 40

Full error:

npm ERR! prepareGitDep 1> 
5
npm ERR! prepareGitDep > husky@0.14.3 install /home/runner/.npm/_cacache/tmp/git-clone-c8a4c747/node_modules/husky
6
npm ERR! prepareGitDep > node ./bin/install.js
7
npm ERR! prepareGitDep 
8
npm ERR! prepareGitDep husky
9
npm ERR! prepareGitDep CI detected, skipping Git hooks installation
10
npm ERR! prepareGitDep 
11
npm ERR! prepareGitDep > core-js@2.6.12 postinstall /home/runner/.npm/_cacache/tmp/git-clone-c8a4c747/node_modules/react-native-web/node_modules/core-js
12
npm ERR! prepareGitDep > node -e "try{require('./postinstall')}catch(e){}"
13
npm ERR! prepareGitDep 
14
npm ERR! prepareGitDep 
15
npm ERR! prepareGitDep > react-native-gesture-handler@1.10.1-wp prepare /home/runner/.npm/_cacache/tmp/git-clone-c8a4c747
16
npm ERR! prepareGitDep > bob build
17
npm ERR! prepareGitDep 
18
npm ERR! prepareGitDep ℹ Building target commonjs
19
npm ERR! prepareGitDep ℹ Cleaning up previous build at lib/commonjs
20
npm ERR! prepareGitDep ℹ Compiling 47 files in src with babel
21
npm ERR! prepareGitDep ✔ Wrote files to lib/commonjs
22
npm ERR! prepareGitDep ℹ Building target module
23
npm ERR! prepareGitDep ℹ Cleaning up previous build at lib/module
24
npm ERR! prepareGitDep ℹ Compiling 47 files in src with babel
25
npm ERR! prepareGitDep ✔ Wrote files to lib/module
26
npm ERR! prepareGitDep ℹ Building target typescript
27
npm ERR! prepareGitDep ℹ Cleaning up previous build at lib/typescript
28
npm ERR! prepareGitDep ℹ Generating type definitions with tsc
29
npm ERR! prepareGitDep src/web/GestureHandler.ts:470:22 - error TS7022: 'key' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.
30
npm ERR! prepareGitDep 
31
npm ERR! prepareGitDep 470               const [key, value] = argMapping[index];
32
npm ERR! prepareGitDep                          ~~~
33
npm ERR! prepareGitDep 
34
npm ERR! prepareGitDep 
35
npm ERR! prepareGitDep Found 1 error.
36
npm ERR! prepareGitDep 
37
npm ERR! prepareGitDep ✖ Failed to build definition files.
38
npm ERR! prepareGitDep 
39
npm ERR! prepareGitDep 2> npm WARN install Usage of the `--dev` option is deprecated. Use `--also=dev` instead.
40
npm ERR! prepareGitDep npm WARN deprecated deep-assign@3.0.0: Check out `lodash.merge` or `merge-options` instead.
41
npm ERR! prepareGitDep npm WARN deprecated core-js@2.6.12: core-js@<3.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.
42
npm ERR! prepareGitDep npm WARN deprecated sane@4.1.0: some dependency vulnerabilities fixed, support for node < 10 dropped, and newer ECMAScript syntax/features added
43
npm ERR! prepareGitDep npm WARN deprecated core-js@1.2.7: core-js@<3.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.
44
npm ERR! prepareGitDep npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
45
npm ERR! prepareGitDep npm WARN deprecated fsevents@1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
46
npm ERR! prepareGitDep npm WARN deprecated uglify-es@3.3.9: support for ECMAScript is superseded by `uglify-js` as of v3.13.0
47
npm ERR! prepareGitDep npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
48
npm ERR! prepareGitDep npm WARN deprecated left-pad@1.3.0: use String.prototype.padStart()
49
npm ERR! prepareGitDep npm WARN deprecated request-promise-native@1.0.9: request-promise-native has been deprecated because it extends the now deprecated request package, see https://github.com/request/request/issues/3142
50
npm ERR! prepareGitDep npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
51
npm ERR! prepareGitDep npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
52
npm ERR! prepareGitDep npm WARN deprecated har-validator@5.1.5: this library is no longer supported
53
npm ERR! prepareGitDep bob build
54
npm ERR! prepareGitDep 
55
npm ERR! prepareGitDep build files for publishing
56
npm ERR! prepareGitDep 
57
npm ERR! prepareGitDep Options:
58
npm ERR! prepareGitDep   --help     Show help                                                 [boolean]
59
npm ERR! prepareGitDep   --version  Show version number                                       [boolean]
60
npm ERR! prepareGitDep 
61
npm ERR! prepareGitDep Error: Failed to build definition files.
62
npm ERR! prepareGitDep     at build (/home/runner/.npm/_cacache/tmp/git-clone-c8a4c747/node_modules/react-native-builder-bob/lib/targets/typescript.js:112:11)
63
npm ERR! prepareGitDep     at processTicksAndRejections (internal/process/task_queues.js:95:5)
64
npm ERR! prepareGitDep     at async Object.handler (/home/runner/.npm/_cacache/tmp/git-clone-c8a4c747/node_modules/react-native-builder-bob/lib/cli.js:381:9)
65
npm ERR! prepareGitDep npm ERR! code ELIFECYCLE
66
npm ERR! prepareGitDep npm ERR! errno 1
67
npm ERR! prepareGitDep npm ERR! react-native-gesture-handler@1.10.1-wp prepare: `bob build`
68
npm ERR! prepareGitDep npm ERR! Exit status 1
69
npm ERR! prepareGitDep npm ERR! 
70
npm ERR! prepareGitDep npm ERR! Failed at the react-native-gesture-handler@1.10.1-wp prepare script.
71
npm ERR! prepareGitDep npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
72
npm ERR! prepareGitDep 
73
npm ERR! prepareGitDep npm ERR! A complete log of this run can be found in:
74
npm ERR! prepareGitDep npm ERR!     /home/runner/.npm/_logs/2021-08-27T10_26_49_438Z-debug.log
75
npm ERR! prepareGitDep 
76
npm ERR! premature close

Step-by-step reproduction instructions

  1. Update any dependency in the package.json file and run npm i.
  2. Open PR.
  3. Observe CI jobs and check errors reported.

I guess it runs npm ci on CI and that might be the main difference why I don't see it locally.

Screenshots, screen recording, code snippet

No response

Environment info

No response

Pre-checks

senadir commented 3 years ago

This seems to happen for new installs as well, @nielslange was trying to setup the repo locally and couldn’t install it.

nielslange commented 3 years ago

I went ahead and set up a brand new Mac Mini, installed brew and nvm, cloned the Gutenberg repo locally and run npm i. This lead to the following output:

$ npm i                                                                                                                              ✔ 

⸨            ░░░░░░⸩ ⠙ extract:react-native: sill extract react-native@0.64.0 extracted to /Users/nielslange/Plugins/gutenberg/node_modules/.staging/react-native-bffnpm ERR! prepareGitDep 1> 
npm ERR! prepareGitDep > fsevents@1.2.13 install /Users/nielslange/.npm/_cacache/tmp/git-clone-6191d2c4/node_modules/@jest/core/node_modules/fsevents
npm ERR! prepareGitDep > node install.js
npm ERR! prepareGitDep 
npm ERR! prepareGitDep   SOLINK_MODULE(target) Release/.node
npm ERR! prepareGitDep   CXX(target) Release/obj.target/fse/fsevents.o
npm ERR! prepareGitDep   SOLINK_MODULE(target) Release/fse.node
npm ERR! prepareGitDep 
npm ERR! prepareGitDep > fsevents@1.2.13 install /Users/nielslange/.npm/_cacache/tmp/git-clone-6191d2c4/node_modules/@jest/environment/node_modules/fsevents
npm ERR! prepareGitDep > node install.js
npm ERR! prepareGitDep 
npm ERR! prepareGitDep   SOLINK_MODULE(target) Release/.node
npm ERR! prepareGitDep   CXX(target) Release/obj.target/fse/fsevents.o
npm ERR! prepareGitDep   SOLINK_MODULE(target) Release/fse.node
npm ERR! prepareGitDep 
npm ERR! prepareGitDep > fsevents@1.2.13 install /Users/nielslange/.npm/_cacache/tmp/git-clone-6191d2c4/node_modules/@jest/reporters/node_modules/fsevents
npm ERR! prepareGitDep > node install.js
npm ERR! prepareGitDep 
npm ERR! prepareGitDep   SOLINK_MODULE(target) Release/.node
npm ERR! prepareGitDep   CXX(target) Release/obj.target/fse/fsevents.o
npm ERR! prepareGitDep   SOLINK_MODULE(target) Release/fse.node
npm ERR! prepareGitDep 
npm ERR! prepareGitDep > fsevents@1.2.13 install /Users/nielslange/.npm/_cacache/tmp/git-clone-6191d2c4/node_modules/@jest/test-sequencer/node_modules/fsevents
npm ERR! prepareGitDep > node install.js
npm ERR! prepareGitDep 
npm ERR! prepareGitDep   SOLINK_MODULE(target) Release/.node
npm ERR! prepareGitDep   CXX(target) Release/obj.target/fse/fsevents.o
npm ERR! prepareGitDep   SOLINK_MODULE(target) Release/fse.node
npm ERR! prepareGitDep 
npm ERR! prepareGitDep > fsevents@1.2.13 install /Users/nielslange/.npm/_cacache/tmp/git-clone-6191d2c4/node_modules/jest-config/node_modules/fsevents
npm ERR! prepareGitDep > node install.js
npm ERR! prepareGitDep 
npm ERR! prepareGitDep   SOLINK_MODULE(target) Release/.node
npm ERR! prepareGitDep   CXX(target) Release/obj.target/fse/fsevents.o
npm ERR! prepareGitDep   SOLINK_MODULE(target) Release/fse.node
npm ERR! prepareGitDep 
npm ERR! prepareGitDep > fsevents@1.2.13 install /Users/nielslange/.npm/_cacache/tmp/git-clone-6191d2c4/node_modules/jest-runner/node_modules/fsevents
npm ERR! prepareGitDep > node install.js
npm ERR! prepareGitDep 
npm ERR! prepareGitDep   SOLINK_MODULE(target) Release/.node
npm ERR! prepareGitDep   CXX(target) Release/obj.target/fse/fsevents.o
npm ERR! prepareGitDep   SOLINK_MODULE(target) Release/fse.node
npm ERR! prepareGitDep 
npm ERR! prepareGitDep > fsevents@1.2.13 install /Users/nielslange/.npm/_cacache/tmp/git-clone-6191d2c4/node_modules/jest-runtime/node_modules/fsevents
npm ERR! prepareGitDep > node install.js
npm ERR! prepareGitDep 
npm ERR! prepareGitDep   SOLINK_MODULE(target) Release/.node
npm ERR! prepareGitDep   CXX(target) Release/obj.target/fse/fsevents.o
npm ERR! prepareGitDep   SOLINK_MODULE(target) Release/fse.node
npm ERR! prepareGitDep 
npm ERR! prepareGitDep > husky@0.14.3 install /Users/nielslange/.npm/_cacache/tmp/git-clone-6191d2c4/node_modules/husky
npm ERR! prepareGitDep > node ./bin/install.js
npm ERR! prepareGitDep 
npm ERR! prepareGitDep husky
npm ERR! prepareGitDep setting up Git hooks
npm ERR! prepareGitDep done
npm ERR! prepareGitDep 
npm ERR! prepareGitDep 
npm ERR! prepareGitDep > core-js@2.6.12 postinstall /Users/nielslange/.npm/_cacache/tmp/git-clone-6191d2c4/node_modules/react-native-web/node_modules/core-js
npm ERR! prepareGitDep > node -e "try{require('./postinstall')}catch(e){}"
npm ERR! prepareGitDep 
npm ERR! prepareGitDep 
npm ERR! prepareGitDep > react-native-gesture-handler@1.10.1-wp prepare /Users/nielslange/.npm/_cacache/tmp/git-clone-6191d2c4
npm ERR! prepareGitDep > bob build
npm ERR! prepareGitDep 
npm ERR! prepareGitDep ℹ Building target commonjs
npm ERR! prepareGitDep ℹ Cleaning up previous build at lib/commonjs
npm ERR! prepareGitDep ℹ Compiling 47 files in src with babel
npm ERR! prepareGitDep ✔ Wrote files to lib/commonjs
npm ERR! prepareGitDep ℹ Building target module
npm ERR! prepareGitDep ℹ Cleaning up previous build at lib/module
npm ERR! prepareGitDep ℹ Compiling 47 files in src with babel
npm ERR! prepareGitDep ✔ Wrote files to lib/module
npm ERR! prepareGitDep ℹ Building target typescript
npm ERR! prepareGitDep ℹ Cleaning up previous build at lib/typescript
npm ERR! prepareGitDep ℹ Generating type definitions with tsc
npm ERR! prepareGitDep src/web/GestureHandler.ts:470:22 - error TS7022: 'key' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.
npm ERR! prepareGitDep 
npm ERR! prepareGitDep 470               const [key, value] = argMapping[index];
npm ERR! prepareGitDep                          ~~~
npm ERR! prepareGitDep 
npm ERR! prepareGitDep 
npm ERR! prepareGitDep Found 1 error.
npm ERR! prepareGitDep 
npm ERR! prepareGitDep ✖ Failed to build definition files.
npm ERR! prepareGitDep 
npm ERR! prepareGitDep 2> npm WARN install Usage of the `--dev` option is deprecated. Use `--also=dev` instead.
npm ERR! prepareGitDep npm WARN deprecated deep-assign@3.0.0: Check out `lodash.merge` or `merge-options` instead.
npm ERR! prepareGitDep npm WARN deprecated core-js@2.6.12: core-js@<3.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.
npm ERR! prepareGitDep npm WARN deprecated sane@4.1.0: some dependency vulnerabilities fixed, support for node < 10 dropped, and newer ECMAScript syntax/features added
npm ERR! prepareGitDep npm WARN deprecated core-js@1.2.7: core-js@<3.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.
npm ERR! prepareGitDep npm WARN deprecated fsevents@1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
npm ERR! prepareGitDep npm WARN deprecated left-pad@1.3.0: use String.prototype.padStart()
npm ERR! prepareGitDep npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm ERR! prepareGitDep npm WARN deprecated request-promise-native@1.0.9: request-promise-native has been deprecated because it extends the now deprecated request package, see https://github.com/request/request/issues/3142
npm ERR! prepareGitDep npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
npm ERR! prepareGitDep npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm ERR! prepareGitDep npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm ERR! prepareGitDep npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm ERR! prepareGitDep npm WARN deprecated uglify-es@3.3.9: support for ECMAScript is superseded by `uglify-js` as of v3.13.0
npm ERR! prepareGitDep bob build
npm ERR! prepareGitDep 
npm ERR! prepareGitDep build files for publishing
npm ERR! prepareGitDep 
npm ERR! prepareGitDep Options:
npm ERR! prepareGitDep   --help     Show help                                                 [boolean]
npm ERR! prepareGitDep   --version  Show version number                                       [boolean]
npm ERR! prepareGitDep 
npm ERR! prepareGitDep Error: Failed to build definition files.
npm ERR! prepareGitDep     at build (/Users/nielslange/.npm/_cacache/tmp/git-clone-6191d2c4/node_modules/react-native-builder-bob/lib/targets/typescript.js:112:11)
npm ERR! prepareGitDep     at processTicksAndRejections (internal/process/task_queues.js:95:5)
npm ERR! prepareGitDep     at async Object.handler (/Users/nielslange/.npm/_cacache/tmp/git-clone-6191d2c4/node_modules/react-native-builder-bob/lib/cli.js:381:9)
npm ERR! prepareGitDep npm ERR! code ELIFECYCLE
npm ERR! prepareGitDep npm ERR! errno 1
npm ERR! prepareGitDep npm ERR! react-native-gesture-handler@1.10.1-wp prepare: `bob build`
npm ERR! prepareGitDep npm ERR! Exit status 1
npm ERR! prepareGitDep npm ERR! 
npm ERR! prepareGitDep npm ERR! Failed at the react-native-gesture-handler@1.10.1-wp prepare script.
npm ERR! prepareGitDep npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! prepareGitDep 
npm ERR! prepareGitDep npm ERR! A complete log of this run can be found in:
npm ERR! prepareGitDep npm ERR!     /Users/nielslange/.npm/_logs/2021-08-30T13_48_09_937Z-debug.log
npm ERR! prepareGitDep 
npm ERR! premature close

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/nielslange/.npm/_logs/2021-08-30T13_48_36_596Z-debug.log
nerrad commented 3 years ago

With a fresh clone of Gutenberg, I'm getting the same error using npm install. Using Node 14 and NPM 6.

gwwar commented 3 years ago

🤔 is this still reproducible? A fresh install seemed to finish for me. For anyone that can repro, we could maybe try setting "types" or "typeRoots" to an allow list of types to use https://www.typescriptlang.org/tsconfig#types. Not sure why this defaults to pulling in 3rd party deps as visible but 🤷‍♀️

{
  "compilerOptions": {
    "types": []
  }
}
guarani commented 3 years ago

🤔 is this still reproducible?

I just tried a fresh clone and npm i completed successfully on the laest trunk commit at time of writing, b72adf8aaa24afd1b1777c641806ad738c523486.

I'm not sure if the issue was fixed, or I don't have the correct steps to reproduce.

ciampo commented 3 years ago

Experiencing this same CI fails in #34330 (see example CI check)

nerrad commented 3 years ago

Still happening for me on latest trunk with npm install:

❯ node --version && npm --version
v14.17.0
6.14.13

I'm executing on Mac OSX native terminal. Fresh clone of GB trunk.

For anyone that can repro, we could maybe try setting "types" or "typeRoots" to an allow list of types to use https://www.typescriptlang.org/tsconfig#types. Not sure why this defaults to pulling in 3rd party deps as visible but 🤷‍♀️

typeRoots already specifies a list of types but my node_modules never gets past these installations:

CleanShot 2021-08-31 at 05 59 12@2x
nerrad commented 3 years ago

Since the error appears to be happening in a tmp folder, eg:

/Users/username/.npm/_cacache/tmp/git-clone-adc72902

I tried deleting this tmp folder before attempting npm install again. Still no dice. I suspect for folks this is installing fine with it's because you may have something in your npm cache that bypasses the error. I'm guessing this is only happening for people that haven't updated GB trunk in a while (like myself) or new folks installing GB who haven't yet.

WunderBart commented 3 years ago

I'm not sure if the issue was fixed, or I don't have the correct steps to reproduce.

I was able to repro locally after nuking the npm cache. These are the steps to repro that worked for me, @guarani:

rm -rf node_modules
nvm use
npm cache clean --force
npm ci
scinos commented 3 years ago

Can repro as well with latest trunk (35e16bbad1) and rm -fr **/node_modules && npm install

scinos commented 3 years ago

Using git bisect, looks like this has been a problem since b4623e3a83:

File test.sh:

#!/bin/bash

set -e
rm -fr **/node_modules
npm install

Command: git bisect run ./test.sh

Log:

git bisect start
# good: [4f37c09393eeaa4b6df419e4e30ec1c35b975582] compose: Simplify `compose` fn docs and point to lodash docs for it (#32324)
git bisect good 4f37c09393eeaa4b6df419e4e30ec1c35b975582
# bad: [35e16bbad16afb7209fb0e19b87d3a6f4108dd22] Eslint: Add no-unsafe-wp-apis to rules list in the docs (#34416)
git bisect bad 35e16bbad16afb7209fb0e19b87d3a6f4108dd22
# bad: [e4dd9b394ae9b48a3345d6292066c02a06ee7ac4] Documentation: Remove withState HOC references part 2 (#33222)
git bisect bad e4dd9b394ae9b48a3345d6292066c02a06ee7ac4
# bad: [4ed6fd302bc6fe1ad1ce1a30e578c86da63d226a] update the block toolbar ESnext code. (#32422)
git bisect bad 4ed6fd302bc6fe1ad1ce1a30e578c86da63d226a
# good: [b24efa29194d4a47141919baf082d5a68642091b] Card: refactor subcomponents folder structure (#32557)
git bisect good b24efa29194d4a47141919baf082d5a68642091b
# good: [7428d7e6a898b9232c01e8fe90a5b68ee6361191] Use rendered title and excerpt
git bisect good 7428d7e6a898b9232c01e8fe90a5b68ee6361191
# good: [8d986c9a188c99b4b44e78247c07340c13dc72e0] [RNMobile] Android Only - Fix Gboard enter detection in EnterPressedWatcher (#32471)
git bisect good 8d986c9a188c99b4b44e78247c07340c13dc72e0
# bad: [242da279d6ee551eab39295f613470a721a8a0e1] [RNMobile] Add 1.55.0 section to react-native-editor changelog (#32760)
git bisect bad 242da279d6ee551eab39295f613470a721a8a0e1
# bad: [a4e3977aa2ed12d61515828d95001e531521eb51] Absorb block manager within blocks preferences (#32166)
git bisect bad a4e3977aa2ed12d61515828d95001e531521eb51
# bad: [4f9097daf6868669c7b4e77fa1f45fb41a94288a]  Fix: RNMobile borderRadius value setting (#32717)
git bisect bad 4f9097daf6868669c7b4e77fa1f45fb41a94288a
# good: [e0d70221a88b4969e7b8819843e3a16842992572] Revert fix/slug-to-classname (#32742)
git bisect good e0d70221a88b4969e7b8819843e3a16842992572
# bad: [b4623e3a83ef801f2de3071172fe92ae89305210] [RNMobile] Upgrade to RN 0.64 (#29118)
git bisect bad b4623e3a83ef801f2de3071172fe92ae89305210
# first bad commit: [b4623e3a83ef801f2de3071172fe92ae89305210] [RNMobile] Upgrade to RN 0.64 (#29118)
SeanMcMillan commented 3 years ago

I get the same error trying to build on Windows 10. Clearing the npm cache didn't help.

nerrad commented 3 years ago

I bumped the priority on this. It's a significant blocker to contributing to the repository right now.

scinos commented 3 years ago

I may have a theory of what is going on:

So react-native-gesture-handler fails to install because it runs prepare script. This script does yarn tsc. And why does it runs prepare? NPM docs says (https://docs.npmjs.com/cli/v7/using-npm/scripts):

NOTE: If a package being installed through git contains a prepare script, its dependencies and devDependencies will be installed, and the prepare script will be run, before the package is packaged and installed.

(We consume that package from git+https://github.com/wordpress-mobile/react-native-gesture-handler.git#1.10.1-wp, so the above point should apply.)

However, package-lock.json doesn't seem to pin the devDependencies of react-native-gesture-handler. So my theory is that either it will use a new version of some of those libraries, or use a version already present in the repo that may have changed recently. In any case, react-native-gesture-handler fails to build when using those "unpinned" dependencies.

That would explain why cloning git+https://github.com/wordpress-mobile/react-native-gesture-handler.git and running yarn (which also runs prepare) works: in this scenario it does have devDependencies pinned in yarn.lock.

If the theory is correct, a potential solution would be to publish git+https://github.com/wordpress-mobile/react-native-gesture-handler.git to NPM (including the built files) and consume it from NPM.


Edit: as an experiment, I've published @scinos/react-native-gesture-handler@1.10.1-wp to NPM, and used it to replace react-native-gesture-handler. I can now run rm -fr **/node_modules && npm install and it works.

ceyhun commented 3 years ago

Thanks for investigating @scinos 🙇 I hope this issue will be fixed by https://github.com/WordPress/gutenberg/pull/34422.

gziolo commented 3 years ago

Let's see if #34422 helps :)

nerrad commented 3 years ago

Can confirm this fixes things for me 👏🏻

gziolo commented 3 years ago

Most of the CI jobs pass now, but there are still some issues that might be related to caching. I restarted a few jobs to check it that helps, related commits:

scinos commented 3 years ago

While pinning the typescript dependency upstream helps, personally I think that's paliating the symptoms and not fixing the root cause. It is totally legit for any upstream dependency to specify version ranges.

IMO the root problem is that Gutenberg is taking the job of building an upstream dependency (which introduces a delay when running npm ci/i). As long as we continue to have git urls this will eventually break again.

gziolo commented 3 years ago

After restarting failed jobs for 4813ac8, everything turned green 🎉

Thank you all so much for fixing the issue 🙇🏻

As long as we continue to have git urls this will eventually break again.

This strategy has also other drawbacks. There are some incompatibilities between npm 6 and 7. Ideally, we should use only original npm packages.