vercel / turborepo

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

[turborepo] Error while trying to run script with filter when filter eliminates all possible workspaces #3918

Closed trappar closed 1 year ago

trappar commented 1 year ago

What version of Turborepo are you using?

1.8.2

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

pnpm

What operating system are you using?

Mac

Describe the Bug

In my project, if I'm sitting in the main branch with a clean working copy and I try to run:

turbo --filter "[main]" lint

I get the following output

• Packages in scope: 
• Running lint in 0 packages
• Remote caching disabled

No tasks were executed as part of this run.

 Tasks:    0 successful, 0 total
Cached:    0 cached, 0 total
  Time:    66ms 

However, if I make a modification to a file in my monorepo's root that is not inside a specific package, and is not an input to any package, such as .gitignore, then I get the following output:

 ERROR  run failed: error preparing engine: Could not find the following tasks in project: lint
Turbo error: error preparing engine: Could not find the following tasks in project: lint

Expected Behavior

I should not be getting this error, and turbo should instead simply run no tasks.

To Reproduce

In a monorepo with turborepo, checkout main/master with a clean working copy, then modify the project's .gitignore and try running turbo --filter "[{branch}]" {script} where {branch} is your main/master branch and {script} is any script configured in the turbo.json pipelines.

I just tested and this can be replicated using the starter monorepo created via npx create-turbo@latest

Reproduction Repo

No response

tknickman commented 1 year ago

Hey @trappar, this should be fixed in 1.8.2 (released today)!

trappar commented 1 year ago

Oops, sorry I was mistaken in the bug report. I'm actually already on 1.8.2, and it's still occurring. I'll update my original issue to reflect that.

% turbo --version             
1.8.2
% turbo --filter "[main]" lint
 ERROR  run failed: error preparing engine: Could not find the following tasks in project: lint
Turbo error: error preparing engine: Could not find the following tasks in project: lint

Just double checked and both my globally installed and locally installed versions are at 1.8.2.

trappar commented 1 year ago

@tknickman could you please reopen? 😅

This appears to be an unfixed edge case of the issue that was fixed in 1.8.2.

tknickman commented 1 year ago

Ah, my fault @trappar, sorry about that! We'll take a look.

tkstang commented 1 year ago

I am experiencing this issue as well. Thanks for taking a look!

mehulkar commented 1 year ago

Thanks for the reporting @trappar and @tkstang! I was able to reproduce and the fix issue in #3951. We should hopefully get a new patch release out shortly (this issue will probably close on merge). The explanation for the bug is essentially the same as in https://github.com/vercel/turbo/issues/3896#issuecomment-1439193366. Apologies for the inconvenience!

mehulkar commented 1 year ago

Just an update: we released 1.8.3 with the fix: https://github.com/vercel/turbo/releases/tag/v1.8.3

Tittoh commented 1 year ago

I just created a new project and quick search on a similar error brought me here.

run failed: error preparing engine: Could not find the following tasks in project: hello
Turbo error: error preparing engine: Could not find the following tasks in project: hello

according to the docs, Understanding turbo.json the expected error is:

task `hello` not found in turbo `pipeline` in "turbo.json".
Are you sure you added it?

dev, lint and `build commands are working as expected.

v: 1.8.3

mehulkar commented 1 year ago

@Tittoh good catch. Could you file a new issue to update the docs? If you don’t get to it I’ll make a note to do this on Monday! The error message did indeed change

arantespp commented 1 year ago

I got this error with v: 1.8.3 and running lint from root (//#lint). My turbo.json config.

image

nathanhammond commented 1 year ago

@arantespp //#lint is how to address that root task.

arantespp commented 1 year ago

It's working now! It didn't work if I updated manually (yarn add -DW turbo), but it worked when I updated via codemod (npx @turbo/codemod update).

rhkdgns95 commented 1 year ago

This issue can be resolved by downgrading the version to 1.10.4.

It's not an ideal solution.

magicspon commented 11 months ago

I'm seeing this issue as well

yarn lint - works turbo run link - works

but when either task is run via lint-staged i get:

✖ turbo run lint:
 ERROR  run failed: error preparing engine: Could not find the following tasks in project: _path_to_repo_/.lintstagedrc.js, _path_to_repo/apps/cms/src/globals/Seo.ts, _path_to_repo/apps/cms/src/seed.ts, _path_to_repo/apps/cms/src/singles/About.ts, _path_to_repo/apps/cms/src/singles/Home.ts, _path_to_repo/apps/web/src/app/page.tsx, _path_to_repo/packages/config/eslint/react-internal.js, _path_to_repo/packages/ui/index.tsx

repo: https://github.com/magicspon/next-payloadcms-mono

mehulkar commented 11 months ago

@magicspon since this is already closed a long time ago, can you please open a new issue (thanks for the repro!)

magicspon commented 11 months ago

@mehulkar done -> https://github.com/vercel/turbo/issues/6358