berry icon indicating copy to clipboard operation
berry copied to clipboard

[Bug?]: EISDIR: illegal operation on a directory, read

Open simon04 opened this issue 1 year ago • 2 comments

Self-service

  • [ ] I'd be willing to implement a fix

Describe the bug

yarn add @eaws/[email protected] works.
yarn add @eaws/[email protected] fails with "EISDIR: illegal operation on a directory, read"

# .yarnrc.yml
npmScopes:
  eaws:
    npmRegistryServer: "https://gitlab.com/api/v4/packages/npm/"

To reproduce

> podman run --rm -it node:lts-alpine sh
/ # mkdir foo
/ # cd foo

/foo # cat > package.json
{
  "name": "foo",
  "packageManager": "[email protected]",
  "dependencies": {
    "@eaws/micro-regions_names": "7.0.0"
  }
}

/foo # cat > .yarnrc.yml
npmScopes:
  eaws:
    npmRegistryServer: "https://gitlab.com/api/v4/packages/npm/"
/foo # corepack enable
/foo # yarn
! Corepack is about to download https://repo.yarnpkg.com/4.5.3/packages/yarnpkg-cli/bin/yarn.js
? Do you want to continue? [Y/n] y

➤ YN0065: Yarn will periodically gather anonymous telemetry: https://yarnpkg.com/advanced/telemetry
➤ YN0065: Run yarn config set --home enableTelemetry 0 to disable

➤ YN0000: · Yarn 4.5.3
➤ YN0000: ┌ Resolution step
➤ YN0085: │ + @eaws/micro-regions_names@npm:7.0.0::__archiveUrl=https%3A%2F%2Fgitlab.com%2Fapi%2Fv4%2Fprojects%2F25330421%2Fpackages%2Fnpm%2F%40eaws%2Fmicro-regions_names%2F-%2F%40eaws%2Fmicro-regions_names-7.0.0.tgz
➤ YN0000: └ Completed in 0s 372ms
➤ YN0000: ┌ Fetch step
➤ YN0013: │ A package was added to the project (+ 200.48 KiB).
➤ YN0000: └ Completed in 0s 385ms
➤ YN0000: ┌ Link step
➤ YN0000: └ Completed
➤ YN0000: · Done in 0s 793ms

/foo # yarn add @eaws/[email protected]
➤ YN0000: · Yarn 4.5.3
➤ YN0000: ┌ Resolution step
➤ YN0000: └ Completed
➤ YN0000: ┌ Fetch step
➤ YN0000: └ Completed
➤ YN0000: ┌ Link step
➤ YN0000: └ Completed
➤ YN0000: · Done in 0s 51ms

/foo # yarn add @eaws/[email protected]
➤ YN0000: · Yarn 4.5.3
➤ YN0000: ┌ Resolution step
➤ YN0001: │ Error: @eaws/micro-regions_names@file:::locator=%40eaws%2Fmicro-regions_names%40npm%3A7.0.5%3A%3A__archiveUrl%3Dhttps%253A%252F%252Fgitlab.com%252Fapi%252Fv4%252Fprojects%252F25330421%252Fpackages%252Fnpm%252F%2540eaws%252Fmicro-regions_names%252F-%252F%2540eaws%252Fmicro-regions_names-7.0.5.tgz: EISDIR: illegal operation on a directory, read
    at Nl (/root/.cache/node/corepack/v1/yarn/4.5.3/yarn.js:4:1321)
    at Object.e_e (/root/.cache/node/corepack/v1/yarn/4.5.3/yarn.js:4:1720)
    at Zi.readFileBuffer (/root/.cache/node/corepack/v1/yarn/4.5.3/yarn.js:149:214398)
    at Zi.readFilePromise (/root/.cache/node/corepack/v1/yarn/4.5.3/yarn.js:149:213896)
    at Am.readFilePromise (/root/.cache/node/corepack/v1/yarn/4.5.3/yarn.js:9:5367)
    at ju.readFilePromise (/root/.cache/node/corepack/v1/yarn/4.5.3/yarn.js:9:5367)
    at /root/.cache/node/corepack/v1/yarn/4.5.3/yarn.js:568:3400
    at Object.gZe (/root/.cache/node/corepack/v1/yarn/4.5.3/yarn.js:140:53810)
    at $2 (/root/.cache/node/corepack/v1/yarn/4.5.3/yarn.js:568:3362)
    at async nB.getCandidates (/root/.cache/node/corepack/v1/yarn/4.5.3/yarn.js:568:8162)
➤ YN0000: └ Completed in 0s 549ms
➤ YN0000: · Failed with errors in 0s 562ms
/foo #

Gist: https://gist.github.com/simon04/e108da36e8e793817014fb513113c78a

Environment

System:
    OS: Linux 6.11 Alpine Linux
    CPU: (16) x64 AMD Ryzen 7 PRO 4750G with Radeon Graphics
  Binaries:
    Node: 22.12.0 - /tmp/xfs-f6bbd243/node
    Yarn: 4.5.3 - /tmp/xfs-f6bbd243/yarn
    npm: 10.9.0 - /usr/local/bin/npm

Additional context

No response

simon04 avatar Dec 11 '24 09:12 simon04

The @eaws/micro-regions_names added a dependency on file: in 7.0.1. It is curious why they added it, since a package should be able to resolve itself by name.

That triggers a bug where file:::locator=%40eaws%2Fmicro-regions_names%40npm%3A7.0.5%3A%3A__archiveUrl%3D ... micro-regions_names-7.0.5.tgz is parsed as a dependency to a local tgz file, which in turn causes Yarn to try to load file: from the package (the package directory itself) as a tgz file.

This can be fixed by tweaking the tgz descriptor regex to not recognize that as a local tgz, but I would rather make descriptor/locator parsing more robust to avoid similar problems in the future

In the meantime, if you only have one version of @eaws/micro-regions_names in your project, you can force a resolution in package.json:

"resolutions": {
  "@eaws/micro-regions_names@file:": "npm:7.0.5"
}

clemyan avatar Mar 17 '25 15:03 clemyan

The @eaws/micro-regions_names added a dependency on file: in 7.0.1.

Amazing, thank you so much for debugging this issue as well as providing a workaround. I cannot answer why, but I've fixed this file: dependency in https://gitlab.com/eaws/eaws-regions/-/commit/45ae2fa5de1683d2e0f9613b895777ff4dd2112a.

I'm very happy to close/resolve this issue unless you would like to make changes to the yarn codebase.

simon04 avatar Mar 17 '25 19:03 simon04