turborepo: v2 global installation does not infer 1.x installed in repository

Verify canary release

  • I verified that the issue exists in the latest Turborepo canary release.

Link to code that reproduces this issue

https://github.com/4leite/my-turborepo

https://github.com/4leite/my-turborepo/actions/runs/9378148823/job/25820887745

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

npm

What operating system are you using?

Linux

Which canary version will you have in your reproduction?

n/a

Describe the Bug

Existing github actions using: npx -y turbo build --dry-run=json --filter=...[$1] will pull the latest version v2.x and fails to parse the existing json due to breaking changes.

Expected Behavior

Not sure, but I’m documenting the workaround here, because it was not immediately obvious that a new release had happened or why my build stopped working.

To Reproduce

Any v1 json running: npx -y turbo build --dry-run=json

Additional context

Workaround is to pin the version of turbo at v1 npx -y turbo@1 build --dry-run=json

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 4
  • Comments: 35 (12 by maintainers)

Commits related to this issue

Most upvoted comments

What would have been useful is an error saying “This turbo config is for v1 and is not compatible with v2 of turbo, please update your configuration” or something similar.

I just solved the problem by moving my dependency to turbo from devDependencies to dependencies:

{
  "name": "<redacted>-monorepo",
  "private": true,
  "scripts": {
    "build": "turbo build",
    "dev": "turbo dev",
    "lint": "turbo lint",
    "format": "prettier --write \"**/*.{ts,tsx,md}\""
  },
  "devDependencies": {
    "@repo/eslint-config": "*",
    "@repo/typescript-config": "*",
    "prettier": "^3.2.5"
  },
  "dependencies": {
    "turbo": "^2.0.3"
  },
  "engines": {
    "node": "20",
    "yarn": "1.22"
  },
  "packageManager": "yarn@1.22.19",
  "workspaces": [
    "apps/*",
    "packages/@<redacted1>/*",
    "packages/@<redacted2>/*"
  ]
}

I had this issue today but it was slightly different to how it’s been described here.

My docker builds were failing after running prune at the build step.

When I went into the failing layers and ran npx turbo --version it reported that it was still using turbo v1.13.3. However the turbo.json that was output from the prune step was missing the “pipeline” key and throwing the following error:

Step 18/26 : RUN npx turbo build --filter=backend...
 ---> Running in ed7a6fee8ac1

  x missing tasks in project

Error:   x could not find task `build` in project

This makes me think that even though turbo v1.13.3 was reported as being used (the same version as is in my package.json), the prune step was using the latest "$schema": "https://turbo.build/schema.json", schema which is missing the “pipeline” key from RootSchema and was stripping it out of the pruned turbo.json.

I’ve since updated to turbo v2.0.0 and the issue is fixed, but it took a while to debug and may be confusing to a lot of turbo users.

Folks, we believe we fixed this error path on Vercel. Could I ask those of you who were running into this before to try a re-deploy?

cc @omarish @brunofin @cSarcasme @mpereira 🙏

Running into this as well with an upgrade from 1.x.x to 2.0.4.

@anthonyshew thanks for the ack.

To update, we’re aware of this class of error on Vercel and working towards releasing the fix.

Hey, folks, want to update here. We’re aware that this upgrade process wasn’t smooth enough and I want to update with some fixes we’ve put in place.

Code updates

  • We now log a warning when no local turbo is found on an invocation of global turbo to help you know when you are out of sync (PR)
  • turbo-ignore now infers the correct version for your project in as many cases as we can reasonably do so (PR)

Documentation updates

The old documentation wasn’t good enough to keep you safe during this transition. We made some changes in the initial documentation release and several more over the past couple days.

We can’t change the difficulties that we created for you in the near past. Instead, we can do our best for you in the future. From working with folks around the ecosystem and here in this thread, we’re finding these changes have helped significantly already.

We’re also still investigating one larger change for global turbo that would keep you always on the version meant for your repo, no intervention from you required (similar to Corepack for package managers). I’m going to leave this open until we see what comes of that work.

You can use a custom ignore step and set it to npx turbo-ignore@^1 as long as you’re using v1 configuration. We’re working on having a better error message here.

Maybe updating some examples that Turbo provides could help avoid these types of issues in future when other major releases happen?

I believe quite some people follow docs to setup their apps.

Like in the Docker example - https://turbo.build/repo/docs/guides/tools/docker#example

There is a Line - RUN yarn global add turbo. It install latest version of turbo which is 2.0.1 at the time of writing. So if previously setup for turborepo was made with v1 - your build would fail.

Changing examples into something like this (self detecting version, using node):

RUN yarn global add turbo@$(node -p "require('./package.json').dependencies?.['turbo'] || require('./package.json').devDependencies['turbo']")

or this (leave for users to write specific version):

RUN yarn global add turbo@<turborepo-version-for-the-app>

(or even some other, better solutions) could prevent build failures when other major releases happen.

Was just about to report this as well. We have a Dockerfile that runs the following:

RUN npm install -g turbo
COPY . .
RUN turbo prune --scope=${APP_NAME} --docker

When that runs, I get the following error:

#18 [builder 7/7] RUN turbo prune --scope=@redacted/home --docker
#18 1.033 
#18 1.033 Attention:
#18 1.033 Turborepo now collects completely anonymous telemetry regarding usage.
#18 1.033 This information is used to shape the Turborepo roadmap and prioritize features.
#18 1.033 You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
#18 1.033 https://turbo.build/repo/docs/telemetry
#18 1.033 
#18 1.033   x could not resolve workspaces: missing packageManager field in package.json
#18 1.033   `-> missing packageManager field in package.json
#18 1.033 
#18 ERROR: executor failed running [/bin/sh -c turbo prune --scope=${APP_NAME} --docker]: exit code: 1

Looks to be thrown here: https://github.com/vercel/turbo/blob/67b2a855dbb28b0bcc4d16513f7a89b95c9c3906/crates/turborepo-repository/src/package_manager/mod.rs#L428-L431

Thanks for the workaround @4leite, worked for me.