forest-express icon indicating copy to clipboard operation
forest-express copied to clipboard

Yarn v2 breaks Schema creation

Open kamiyo opened this issue 4 years ago • 1 comments

Expected behavior

Schema is expected to be created successfully.

Actual behavior

Errors out with EROFS: read-only filesystem, open '/.forestadmin-schema.json'

Failure Logs

Context

  • Package Version: 6.3.0
  • Express Version: 4.17.1
  • Yarn v2

Yarn v2 has introduced a new way of storing dependencies, i.e. not in node_modules, but rather in a cache with dependencies zipped up. This breaks forest-express's getAbsolutePath utility.: https://github.com/ForestAdmin/forest-express/blob/f632e0369d03057372bec04fae13a3da83e319c8/src/utils/project-directory.js#L10

Since the dir no longer has 'node_modules', it is taking the fork return process.cwd(), which is returning '' (not sure why, possibly because it's running from a zipped file?), which causes this: https://github.com/ForestAdmin/forest-express/blob/f632e0369d03057372bec04fae13a3da83e319c8/src/index.js#L35 to return an absolute path that is '/.forestadmin-schema.json'.

The temporary solution is to yarn unplug forest-express, but if Yarn v2 is going to become more widely used, this should probably be fixed.

kamiyo avatar Jul 05 '20 05:07 kamiyo

I agree, we are migrating to yarn 2 and this was a problem for us too! :)

Unplugging it is not working either. If you use the default directory of unplugged modules, it puts the .forestadmin-schema.json file under .yarn/unplugged/forest-express...

But actually, the path, not unplugged, is: path/to/dir/.yarn/cache/forest-express-npm-version.zip/node_modules/forest-express/dist/utils, so it doesn't do process.cwd()

I think an option to set the absolute path would be the best solution (at least for us)

julienfouilhe avatar Sep 14 '20 15:09 julienfouilhe

It's now (for a while) supported. Thank you all for your contributions.

#697

Thenkei avatar Jul 07 '23 12:07 Thenkei