question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`EROFS: read-only file system, chmod '/var/task/generated/prisma-client/runtime/query-engine-rhel-openssl-1.0.x'`

See original GitHub issue

I followed the setup in https://github.com/prisma/prisma2-e2e-tests/tree/master/platforms/netlify (clone, remove .netlify/state.json, yarn install, yarn prisma2 generate, execute commands from build.sh manually (zip does not exist and has to be done manually), get deployed site and function!).

When then calling the function, I get:

{"errorType":"Error","errorMessage":"\nInvalid `prisma.()` invocation in\n/var/task/generated/prisma-client/index.js:323:37\n\n\n\nEROFS: read-only file system, chmod '/var/task/generated/prisma-client/runtime/query-engine-rhel-openssl-1.0.x'","trace":["Error: ","Invalid `prisma.()` invocation in","/var/task/generated/prisma-client/index.js:323:37","","","","EROFS: read-only file system, chmod '/var/task/generated/prisma-client/runtime/query-engine-rhel-openssl-1.0.x'","    at PrismaClientFetcher.request (/var/task/generated/prisma-client/index.js:60:27)"]}

https://goofy-tereshkova-4bf91a.netlify.com/.netlify/functions/index

Theory: Because the the generated client was created on Windows, it is missing the necessary file permission flags.

(index.zip that was uploaded: index.zip)

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:1
  • Comments:35 (15 by maintainers)

github_iconTop GitHub Comments

4reactions
divyenduzcommented, Feb 28, 2020

In my understanding, this issue happens when the build machine is an OS without binary flags (like windows) and the deployment machine is a machine with binary flags.

If you specify a binary provider in your Prisma schema file to download the binary for target platform OS, like in the case of netlify:

binaryTargets = ["native", "rhel-openssl-1.0.x"]

The binary download happens with prisma2 generate on the build OS (windows). But the downloaded binary doesn’t have any executable flag as it is on windows.

When this binary is deployed a Prisma client attempts to run it, it fails. Most likely on this line. This would usually just work but on lambda it doesn’t work because this part of the filesystem is not writeable.


Next steps: We need to validate the above hypothesis and solve this in some way (already have +x flag on binaries in S3 or downloading the files in /tmp (writeable for lambda) adding the +x flag and copying the binary or something else)

3reactions
abelcheecommented, Oct 21, 2020

Copy to tmp folder works for me.

const binaryPath = '/tmp/query-engine-rhel-openssl-1.0.x';
if (!fs.existsSync(binaryPath)) {
  const { spawnSync } = require('child_process');

  spawnSync('cp', [
    `${process.env.LAMBDA_TASK_ROOT}/node_modules/.prisma/client/query-engine-rhel-openssl-1.0.x`,
    '/tmp/',
  ]);

  spawnSync('chmod', [`555`, '/tmp/query-engine-rhel-openssl-1.0.x']);
}

And need an env:

  PRISMA_QUERY_ENGINE_BINARY: /tmp/query-engine-rhel-openssl-1.0.x
Read more comments on GitHub >

github_iconTop Results From Across the Web

Trying to create a file in Android: open failed: EROFS (Read ...
I have tried this with and without the WRITE_INTERNAL_STORAGE permission. There is no WRITE_INTERNAL_STORAGE permission in Android.
Read more >
Chmod error changing permission read only file system
I've faced a similar problem with an SD Card previously used on an Android device and locked in READ ONLY mode.
Read more >
EROFS - Enhanced Read-Only File System
EROFS filesystem stands for Enhanced Read-Only File System. It aims to form a generic read-only filesystem solution for various read-only use cases instead ......
Read more >
Read-only file system - Unix & Linux Stack Exchange
Your filesystem is read-only, probably because it is damaged. This has nothing to do with the file permissions.
Read more >
chmod command fails with "Read-only file system"
Hi all, I'm getting a "Read-only file system" error when I try to do the chmod, mkdir, touch, or rm commands. I suspect...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found