Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Metro crashing on every build with EPERM error #1047

Closed
3 of 4 tasks
TatuUlmanen opened this issue May 13, 2022 · 12 comments · Fixed by #1466
Closed
3 of 4 tasks

🐛 Metro crashing on every build with EPERM error #1047

TatuUlmanen opened this issue May 13, 2022 · 12 comments · Fixed by #1466
Labels
🐛 bug Something isn't working

Comments

@TatuUlmanen
Copy link

TatuUlmanen commented May 13, 2022

What were you trying to do?

When running npx react-native run-android, the build process starts normally and spawns Metro bundler into another window. The build processes normally, until the task :react-native-vision-camera:compileDebugKotlin is reached. The build continues, but at this point Metro crashes with the error message below:

C:\Users\myname\myapp\app\node_modules\metro-hermes-compiler\src\emhermesc.js:77
          throw ex;
          ^

Error: EPERM: operation not permitted, lstat 'C:\Users\myname\myapp\app\node_modules\react-native-vision-camera\android\build\intermediates\cxx\Debug\3e183j45\obj\armeabi-v7a\libVisionCamera.so.tmp22a6dbd'
Emitted 'error' event on NodeWatcher instance at:
    at C:\Users\myname\myapp\app\node_modules\metro\node_modules\jest-haste-map\build\watchers\NodeWatcher.js:275:14
    at FSReqCallback.oncomplete (node:fs:198:21) {
  errno: -4048,
  code: 'EPERM',
  syscall: 'lstat',
  path: 'C:\\Users\\tatuu\\jemma\\app\\node_modules\\react-native-vision-camera\\android\\build\\intermediates\\cxx\\Debug\\3e183j45\\obj\\armeabi-v7a\\libVisionCamera.so.tmp22a6dbd'
}

From what I understand, Metro is watching some temporary build files in the react-native-vision-camera build folder, and when these are cleaned up, Metro crashes with a "operation not permitted" error.

I didn't find any other issues regarding this problem, even though this is the third machine this happens in.

Is this a react-native-vision-camera problem or a Metro configuration issue? How can I run the build process in a way that doesn't trigger the EPERM error in Metro?

Reproduceable Code

No response

What happened instead?

Metro crashes.

Relevant log output

No response

Device

Android emulator

VisionCamera Version

2.13.2

Additional information

@TatuUlmanen TatuUlmanen added the 🐛 bug Something isn't working label May 13, 2022
@TatuUlmanen TatuUlmanen changed the title 🐛 Metro crashing on every build with ENOENT error 🐛 Metro crashing on every build with EPERM error May 13, 2022
@Zero-Xiong
Copy link

I hit the same issue, but my problem is not related with the package react-native-vision-camera because I dont use. I dont know what's the root cause, please help!

@chai00xxdd
Copy link

any solution?

@Martinocom
Copy link

The only solution I found for now is to just relaunch Metro after this error happens. Pretty annoying but kinda works.

@reznik99
Copy link

reznik99 commented Sep 5, 2022

I am having this issue as well but the error mentions 'C:\Users\myname\myapp\app\node_modules\react-native-reanimated\...

I tried everything and I can't get metro not to crash.

@sahibprashant
Copy link

I am facing this same issue, Not finding any proper solution!

Anyone found solution for this?

@reznik99
Copy link

reznik99 commented Sep 9, 2022

Solution that worked for me:

1 - Build first:
npx react-native run-android
This will crash with the same error but that's ok.

2 - Run metro separately:
npx react-native start or npm start

This works for me (live reload etc..)

I think the issue is metro starts watching files while the npx react-native run-android is still building/accessing files, and the two interfere with each other.

@mhackeras
Copy link

mhackeras commented Sep 14, 2022

Best solution for now is to run (not really best but at least you won't have to run metro fast after a successful build) :
adb reverse tcp:8081 tcp:8081 tcp:8081

So you can now build the app once and you don't need to run it again to connect to the metro. You can start metro later and app will connect to it.

@Meijer-A
Copy link

Meijer-A commented Feb 2, 2023

I'm experiencing the same issue with vision camera version 2.15.4

@krmao
Copy link

krmao commented Apr 16, 2023

  • same error
RuntimeError: abort(Error: EPERM: operation not permitted, lstat 'E:\Workspace\xxx\example\android\app\build\intermediates\cxx\Debug\6n1z393a\obj\arm64-v8a\libappmodules.so.tmp05deaa0'). Build with -s ASSERTIONS=1 for more info.
    at process.abort (E:\xxx\rn_addtoapp_bridge\example\node_modules\metro-hermes-compiler\src\emhermesc.js:402:15)
    at process.emit (node:events:520:28)
    at processEmit [as emit] (E:\Workspace\xxx\example\node_modules\signal-exit\index.js:199:34)
    at emit (node:internal/process/promises:133:20)
    at processPromiseRejections (node:internal/process/promises:260:27)
    at processTicksAndRejections (node:internal/process/task_queues:97:32)
error Command failed with exit code 1.

@krmao
Copy link

krmao commented Apr 16, 2023

  • same error
RuntimeError: abort(Error: EPERM: operation not permitted, lstat 'E:\Workspace\xxx\example\android\app\build\intermediates\cxx\Debug\6n1z393a\obj\arm64-v8a\libappmodules.so.tmp05deaa0'). Build with -s ASSERTIONS=1 for more info.
    at process.abort (E:\xxx\rn_addtoapp_bridge\example\node_modules\metro-hermes-compiler\src\emhermesc.js:402:15)
    at process.emit (node:events:520:28)
    at processEmit [as emit] (E:\Workspace\xxx\example\node_modules\signal-exit\index.js:199:34)
    at emit (node:internal/process/promises:133:20)
    at processPromiseRejections (node:internal/process/promises:260:27)
    at processTicksAndRejections (node:internal/process/task_queues:97:32)
error Command failed with exit code 1.

already fix the error

metro.config.js

// noinspection JSUnresolvedFunction,JSCheckFunctionSignatures,JSUnusedGlobalSymbols,NpmUsedModulesInstalled

const path = require('path');
const escape = require('escape-string-regexp');
const exclusionList = require('metro-config/src/defaults/exclusionList');
const pak = require('../package.json');
const root = path.resolve(__dirname, '..');
const modules = Object.keys({ ...pak.peerDependencies });

const originBlackListRE = exclusionList(modules.map((m) => new RegExp(`^${escape(path.join(root, 'node_modules', m))}\\/.*$`)));

//region for widows RuntimeError: abort(Error: EPERM: operation not permitted, lstat 'E:\Workspace\xxx\example\android\app\build\intermediates\cxx\Debug\6n1z393a\obj\arm64-v8a\libappmodules.so.tmp05deaa0'). Build with -s ASSERTIONS=1 for more info.
// https://stackoverflow.com/a/9213411/4348530
// https://github.com/mrousavy/react-native-vision-camera/issues/1047#issuecomment-1510030983
// https://github.com/expo/expo-cli/issues/2021#issuecomment-1239989633
const extraBlackListRE = new RegExp("(.*\\android\\.*|.*__fixtures__\\.*|node_modules\\\\react\\\\dist\\\\.*|website\\node_modules\\.*|heapCapture\\bundle\.js|.*__tests__\\.*)$");
const finalBlackListRE = new RegExp("(" + originBlackListRE.source + ")|(" + extraBlackListRE.source + ")")
console.log("metro.config.js originBlackListRE=", originBlackListRE)
console.log("metro.config.js extraBlackListRE=", extraBlackListRE)
console.log("metro.config.js finalBlackListRE=", finalBlackListRE)
// originBlackListRE /(^E:\\Workspace\\rn_addtoapp_bridge\\node_modules\\react\\.*$|^E:\\Workspace\\rn_addtoapp_bridge\\node_modules\\react-native\\.*$|\\__tests__\\.*)$/
// extraBlackListRE /(.*\android\.*|.*\__fixtures__\.*|node_modules[\\]react[\\]dist[\\].*|website\node_modules\.*|heapCapture\bundle.js|.*\__tests__\.*)$/
// finalBlackListRE /((^E:\\Workspace\\rn_addtoapp_bridge\\node_modules\\react\\.*$|^E:\\Workspace\\rn_addtoapp_bridge\\node_modules\\react-native\\.*$|\\__tests__\\.*)$)|((.*\android\.*|.*\__fixtures__\.*|node_modules[\\]react[\\]dist[\\].*|website\node_modules\.*|heapCapture\bundle.js|.*\__tests__\.*)$)/
// exit();
//endregion

const metroConfig = {
  projectRoot: __dirname,
  watchFolders: [root],

  // We need to make sure that only one version is loaded for peerDependencies
  // So we block them at the root, and alias them to the versions in example's node_modules
  resolver: {
    blacklistRE: finalBlackListRE,

@Dhiraj-j
Copy link

Same Error have to start metro again after build

mrousavy added a commit that referenced this issue Sep 1, 2023
See #1376

## Breaking Changes

* Frame Processors are now **synchronous**. Previously they ran on a
separate Thread. If you want to run something on a separate Thread now,
use `runAsync` inside a Frame Processor
* Frame Processor Plugins are no longer in the global object with the
`__` prefix, but rather stored directly in the `FrameProcessorPlugins`
object exported by react-native-vision-camera. (e.g. replace
`__scanQRCodes(frame)` with `FrameProcessorPlugins.scanQRCodes(frame)`)
* `frameProcessorFps` no longer exists. Use `runAtTargetFps` inside a
Frame Processor to throttle some calls.
* `onFrameProcessorPerformanceSuggestionAvailable` no longer exists. Use
the FPS display (`enableFpsGraph={true}`) to see how your Frame
Processor performs over time. This is more in-line with how React Native
works (Dev Tools / Perf Monitor)
* VisionCamera V3 will not work on RN 0.70 or below. You need to use RN
0.71. This is because the build script got way simpler and smaller,
making it faster to build and way less error prone. Backwards
compatibility is just too complex here.
* Reanimated is no longer used as a Worklet Runtime. Instead,
VisionCamera now uses
[react-native-worklets-core](https://github.com/margelo/react-native-worklets-core).

## Progress

You can test the latest V3 release by creating a new RN project with RN
0.71 and installing VisionCamera + RNWorklets:

```sh
yarn add react-native-vision-camera@3.0.0-rc.5
yarn add react-native-worklets-core
yarn add @shopify/react-native-skia
```

Things to test:

* TensorFlow Lite plugin to load any `.tflite` model!! ✨ (see [this PR
for more
info](#1633),
will be a separate library soon)
* Drawing onto a Frame using Skia!! 🎉 
* Using `frame.toArrayBuffer()` to get the Frame's byte content in JS
* New Android build script. This should drastically speed up the build
time! 💨
* New Worklet library. This replaces Reanimated Worklets. Should be
faster and more stable :)
* New synchronous Frame Processors. Should be faster :)
* `runAtTargetFps` and `runAsync` in Frame Processors
* Using HostObjects or HostFunctions (like models from PyTorch) inside a
Frame Processor. This will probably require a few native bindings on
PyTorch's end to make the integration work (cc @raedle)

Overall V3 is close to completion. I have a few things to do the coming
days so not sure how much work I can put into this. **If anyone wants to
support the development of v3, I'd appreciate donations / sponsors:
https://github.com/sponsors/mrousavy** ❤️ :)


## Related issues 

features

- resolves
#1376
- fixes
#281
- resolves
#211
- resolves
#130
- resolves
#117
- fixes #76
- resolves
#75
- resolves
#562
- resolves
#565
- fixes
#570
- fixes
#287
- resolves
#311
- fixes
#315
- resolves
#323
- fixes
#340
- fixes
#354
- resolves
#420
- fixes
#434
- fixes
#452
- fixes
#496
- fixes
#497
- resolves
#499
- fixes
#516
- fixes
#527
- fixes
#542
- fixes
#548
- fixes
#561
- fixes
#740
- fixes
#770


...and then pretty much every Android issue lol

- fixes
#1675
(**maybe**, please test @PrernaBudhraja)
- fixes
#1671

.. maybe also (not tested):

- fixes
#1698
- fixes
#1687
- fixes
#1685
- fixes
#1681
- fixes
#1650
- fixes
#1646
- fixes
#1635
- fixes
#1631
- fixes
#1621
- fixes
#1615
- fixes
#1612
- fixes
#1605
- fixes
#1599
- fixes
#1585
- fixes
#1581
- fixes
#1569
- fixes
#1568
- fixes
#1565
- fixes
#1561
- fixes
#1558
- fixes
#1554
- fixes
#1551
- fixes
#1547
- fixes
#1543
- fixes
#1538
- fixes
#1536
- fixes
#1534
- fixes
#1528
- fixes
#1520
- fixes
#1498
- fixes
#1489
- fixes
#1477
- fixes
#1474
- fixes
#1463
- fixes
#1462
- fixes
#1449
- fixes
#1443
- fixes
#1437
- fixes
#1431
- fixes
#1429
- fixes
#1427
- fixes
#1423
- fixes
#1416
- fixes
#1407
- fixes
#1403
- fixes
#1402
- fixes
#1398
- fixes
#1396
- fixes
#1395
- fixes
#1379
- fixes
#1377
- fixes
#1374
- fixes
#1373
- fixes
#1365
- fixes
#1356
- fixes
#1353
- fixes
#1352
- fixes
#1351
- fixes
#1343
- fixes
#1340
- fixes
#1334
- fixes
#1330
- fixes
#1322
- fixes
#1296
- fixes
#1283
- fixes
#1260
- fixes
#1253
- fixes
#1251
- fixes
#1245
- fixes
#1238
- fixes
#1227
- fixes
#1226
- fixes
#1225
- fixes
#1222
- fixes
#1211
- fixes
#1208
- fixes
#1193
- fixes
#1191
- fixes
#1184
- fixes
#1164
- fixes
#1143
- fixes
#1128
- fixes
#1122
- fixes
#1120
- fixes
#1110
- fixes
#1097
- fixes
#1081
- fixes
#1080
- fixes
#1064
- fixes
#1053
- fixes
#1047
- fixes
#1044
- fixes
#1032
- fixes
#1026
- fixes
#1023
- fixes
#1015
- fixes
#1012
- fixes
#997
- fixes
#960
- fixes
#959
- fixes
#954
- fixes
#946
- fixes
#945
- fixes
#922
- fixes
#908
- fixes
#907
- fixes
#868
- fixes
#855
- fixes
#834
- fixes
#793
- fixes
#779
- fixes
#746
- fixes
#740
- fixes
#727
- fixes
#671
- fixes
#613
- fixes
#595
- fixes
#588
- fixes
#570
- fixes
#569
- fixes
#542
- fixes
#516
- fixes
#515
- fixes
#434
- fixes
#354
- fixes
#323
- fixes
#315
- fixes
#281
- fixes
#211
- fixes #76
@FelipeACP
Copy link

The issue remains on version 3.6.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.