facebook / flipper

A desktop debugging platform for mobile developers.
https://fbflipper.com/
MIT License
13.31k stars 954 forks source link

'yarn build' fails at genMercurialRevision when hg is missing on the build machine #2922

Open atommarvel opened 2 years ago

atommarvel commented 2 years ago

🐛 Bug Report

My goal was to build a flipper app with custom plugins bundled in the app so that less technical team members can utilize flipper more easily.

In desktop/scripts/build-release.ts, if I replace const hgRevision = await genMercurialRevision(); with const hgRevision = null; everything works fine. Seems like genMercurialRevision isn't failing gracefully as intended when hg is missing.

➜  desktop git:(597cb6b1d) ✗ yarn build --mac --version 0.112.0
yarn run v1.22.11
$ yarn build:tsc && yarn rm-dist && yarn build:themes
$ tsc -b tsc-root/tsconfig.json && ./ts-node ./scripts/compute-package-checksum.ts -d ./babel-transformer -o ./lib/checksum.txt
$ rimraf ../dist
$ lessc --js themes/light.less static/themes/light.css && lessc --js themes/dark.less static/themes/dark.css
$ cross-env NODE_ENV=production ./ts-node scripts/build-release.ts $@ --mac --version 0.112.0
Creating build directory
Created build directory /var/folders/yz/byklhmfj6fz4xhyrzwz7m_j80000gn/T/flipper-build--94379-4M3ySHH9DYYl
⚙️  Compiling main bundle...
Writing bundle output to: /Users/araiff/Workspace/sports/flipper/desktop/static/main.bundle.js
Writing sourcemap output to: /Users/araiff/Workspace/sports/flipper/desktop/static/main.bundle.map
Done writing sourcemap output
Done writing bundle output
✅  Compiled main bundle.
⚙️  Preparing default plugins (isInsidersBuild=false)...
Updating /Users/araiff/Workspace/sports/flipper/desktop/static/main.bundle.js to remove sourceMapURL= comment.
⚙️  Generating entry points for 18 bundled plugins...
✅  Generated bundled plugin entry points.
✅  Prepared default plugins.
⚙️  Copying static package with dependencies...
✅  Copied static package with dependencies.
⚙️  Compiling renderer bundle...
Writing bundle output to: /var/folders/yz/byklhmfj6fz4xhyrzwz7m_j80000gn/T/flipper-build--94379-4M3ySHH9DYYl/bundle.js
Writing sourcemap output to: /var/folders/yz/byklhmfj6fz4xhyrzwz7m_j80000gn/T/flipper-build--94379-4M3ySHH9DYYl/bundle.map
Done writing bundle output
Done writing sourcemap output
✅  Compiled renderer bundle.
⚙️  Moving source maps...
⏭  Removing source maps.
/Users/araiff/Workspace/sports/flipper/desktop/node_modules/metro-hermes-compiler/src/emhermesc.js:77
          throw ex;
          ^

RuntimeError: abort(Error: spawn ENOTDIR). Build with -s ASSERTIONS=1 for more info.
    at process.abort (/Users/araiff/Workspace/sports/flipper/desktop/node_modules/metro-hermes-compiler/src/emhermesc.js:440:13)
    at process.emit (events.js:400:28)
    at process.emit (domain.js:470:12)
    at process.emit (/Users/araiff/Workspace/sports/flipper/desktop/node_modules/source-map-support/source-map-support.js:495:21)
    at processEmit [as emit] (/Users/araiff/Workspace/sports/flipper/desktop/node_modules/signal-exit/index.js:161:32)
    at processPromiseRejections (internal/process/promises.js:245:33)
    at processTicksAndRejections (internal/process/task_queues.js:96:32)
error Command failed with exit code 7.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

To Reproduce

Run yarn build --mac --version 0.112.0 on a machine that does not have hg set up.

Environment

passy commented 2 years ago

Good find! Would that be something you'd be interested in fixing? Unfortunately, I currently don't have the bandwidth for this.

atommarvel commented 2 years ago

Same boat in terms of bandwidth basically, but there's a small chance I may be able to write a fix before the end of 2021 :)

I'll post to this issue when I start. If someone else reading this wants to fix it before I post though feel free.

lblasa commented 2 years ago

This one is interesting. I ran a local test which replaced 'hg' with a known missing command and spawn failed gracefully.

The issue was reported on macOS, same as my test environment.

The output I got, as expected, is: { errno: -2, code: 'ENOENT', syscall: 'spawn hg_invalid', path: 'hg_invalid', spawnargs: [ 'log', '-r', '.', '-T', '{node}' ] }

The reported error is different though: ENOTDIR.