vercel / turborepo

Build system optimized for JavaScript and TypeScript, written in Rust
https://turbo.build/repo/docs
MIT License
26.45k stars 1.84k forks source link

turbo-ignore throw an error if there is a symlink in the packages folder #8625

Open fveauvy opened 4 months ago

fveauvy commented 4 months ago

Verify canary release

Link to code that reproduces this issue

https://github.com/fveauvy/turbo-ignore-issue

What package manager are you using / does the bug impact?

Yarn v1

What operating system are you using?

Mac

Which canary version will you have in your reproduction?

turbo@2.0.6-canary.0

Describe the Bug

Context

In our project, we have a knowledge root folder where we centralize all project-related documentation. We use symbolic links to reference this documentation in relevant places within the repository.

Example structure:

./
├── apps/
│  ├── apps-a/
│  ├── apps-b/
│  └── README.md -> ../knowledge/apps_README.md # Symlink
├── knowledge/
│  └── apps_README.md # the doc we want to display in `apps/` folder.
├── package.json
├── packages/
│  ├── pkg-a/
│  ├── pkg-b/
│  └── tooling-config/
├── README.md
├── turbo.json
└── yarn.lock

This method enhances discoverability for newcomers and simplifies documentation maintenance by centralizing all knowledge in one place and distributing it via symlinks to relevant locations.

The issue

Due to our structure (symlinks within one of the workspace folders), we encounter an error when using turbo-ignore.

The command npx turbo-ignore <app-name> fails with the following error:

npm error code ENOTDIR npm error syscall open npm error path /Users//my-turborepo/apps/README.md/package.json npm error errno -20 npm error ENOTDIR: not a directory, open '/Users//my-turborepo/apps/README.md/package.json'

It appears that turbo-ignore mistakenly identifies the README.md symlink as a directory and attempts to locate a package.json file within it.

Expected Behavior

npx turbo-ignore <app-name> should not throw an error when encountering a symlink to a file within a Yarn workspace folder.

To Reproduce

  1. git clone git@github.com:fveauvy/turbo-ignore-issue.git
  2. cd turbo-ignore-issue && yarn install
  3. npx turbo-ignore app-b

Additional context

No response

chris-olszewski commented 4 months ago

This is not turbo-ignore, but NPM itself. It can be reproduced by using any package not installed locally via npx:

[0 olszewski@chriss-mbp] /tmp/turbo-ignore-issue $ npx is-even
npm ERR! code ENOTDIR
npm ERR! syscall open
npm ERR! path /private/tmp/turbo-ignore-issue/apps/README.md/package.json
npm ERR! errno -20
npm ERR! ENOTDIR: not a directory, open '/private/tmp/turbo-ignore-issue/apps/README.md/package.json'

npm ERR! A complete log of this run can be found in: /Users/olszewski/.npm/_logs/2024-07-01T19_57_40_578Z-debug-0.log

I'm unsure of where in the NPM stack this path is getting opened.