Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running a turbo upgrade fails when running it twice #8495

Open
1 task
maxshay opened this issue Jun 15, 2024 · 5 comments
Open
1 task

Running a turbo upgrade fails when running it twice #8495

maxshay opened this issue Jun 15, 2024 · 5 comments
Labels
kind: bug Something isn't working needs: triage New issues get this label. Remove it after triage owned-by: turborepo

Comments

@maxshay
Copy link

maxshay commented Jun 15, 2024

Verify canary release

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

Link to code that reproduces this issue

na

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

pnpm

What operating system are you using?

Mac

Which canary version will you have in your reproduction?

na

Describe the Bug

While upgrading turborepo with npx @turbo/codemod@latest update I ran into the following error:

Error message:

(3/11) Running migrate-env-var-dependencies
 INFO  Migrating environment variable dependencies from "globalDependencies" and "dependsOn" to "env" in "turbo.json"... 

Unexpected error. Please report it as a bug:
TypeError: Cannot convert undefined or null to object
    at Function.values (<anonymous>)
    at Pu (/Users/mshay/.npm/_npx/36146fcc85b26196/node_modules/@turbo/codemod/dist/transforms/migrate-env-var-dependencies.js:39:6831)
    at Object.WE [as transformer] (/Users/mshay/.npm/_npx/36146fcc85b26196/node_modules/@turbo/codemod/dist/transforms/migrate-env-var-dependencies.js:39:8345)
    at Command.Wh (/Users/mshay/.npm/_npx/36146fcc85b26196/node_modules/@turbo/codemod/dist/cli.js:46:9172)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Command.parseAsync (/Users/mshay/.npm/_npx/36146fcc85b26196/node_modules/commander/lib/command.js:935:5)

Expected Behavior

Does not error and completes the migration successfully after running a second time.

To Reproduce

Migrating turbo repo from 1.13.3 to latest with npx @turbo/codemod@latest update. I was also updating eslint versions and some internal packages' (eslint config and typescript config) names and didn't replace all references in my apps that referenced them. Not ideal but it happened this way. Running npx @turbo/codemod@latest update the first time resulted in what seemed like a successfull migration:

mshay@Maksims-MBP appName % npx @turbo/codemod@latest update
Need to install the following packages:
  @turbo/[email protected]
Ok to proceed? (y) y
? Where is the root of the repo to migrate? .
Upgrading turbo from 1.13.3 to 2.0.4 (11 required codemods) 

(1/11) Running add-package-manager
 INFO  Set "packageManager" key in root "package.json" file... 
 MODIFIED  package.json 

Results:
┌──────────────┬────────────┬───────────┬───────────┬────────┐
│   (index)    │   action   │ additions │ deletions │ error  │
├──────────────┼────────────┼───────────┼───────────┼────────┤
│ package.json │ 'modified' │     1     │     1     │ 'None' │
└──────────────┴────────────┴───────────┴───────────┴────────┘

(2/11) Running create-turbo-config
 INFO  Migrating "package.json" "turbo" key to "turbo.json" file... 
 UNCHANGED  turbo.json 
 UNCHANGED  package.json 

Results:
┌──────────────┬─────────────┬───────────┬───────────┬────────┐
│   (index)    │   action    │ additions │ deletions │ error  │
├──────────────┼─────────────┼───────────┼───────────┼────────┤
│  turbo.json  │ 'unchanged' │     0     │     0     │ 'None' │
│ package.json │ 'unchanged' │     0     │     0     │ 'None' │
└──────────────┴─────────────┴───────────┴───────────┴────────┘

(3/11) Running migrate-env-var-dependencies
 INFO  Migrating environment variable dependencies from "globalDependencies" and "dependsOn" to "env" in "turbo.json"... 
 UNCHANGED  turbo.json 

Results:
┌────────────┬─────────────┬───────────┬───────────┬────────┐
│  (index)   │   action    │ additions │ deletions │ error  │
├────────────┼─────────────┼───────────┼───────────┼────────┤
│ turbo.json │ 'unchanged' │     0     │     0     │ 'None' │
└────────────┴─────────────┴───────────┴───────────┴────────┘

(4/11) Running stabilize-env-mode
 INFO  Rewriting `experimentalPassThroughEnv` and `experimentalGlobalPassThroughEnv` 
 UNCHANGED  turbo.json 
 UNCHANGED  apps/appName/turbo.json 

Results:
┌────────────────────────────┬─────────────┬───────────┬───────────┬────────┐
│          (index)           │   action    │ additions │ deletions │ error  │
├────────────────────────────┼─────────────┼───────────┼───────────┼────────┤
│         turbo.json         │ 'unchanged' │     0     │     0     │ 'None' │
│ apps/appName/turbo.json │ 'unchanged' │     0     │     0     │ 'None' │
└────────────────────────────┴─────────────┴───────────┴───────────┴────────┘

(5/11) Running transform-env-literals-to-wildcards
 INFO  Rewriting env vars to support wildcards 
 UNCHANGED  turbo.json 
 UNCHANGED  apps/appName/turbo.json 

Results:
┌────────────────────────────┬─────────────┬───────────┬───────────┬────────┐
│          (index)           │   action    │ additions │ deletions │ error  │
├────────────────────────────┼─────────────┼───────────┼───────────┼────────┤
│         turbo.json         │ 'unchanged' │     0     │     0     │ 'None' │
│ apps/appName/turbo.json │ 'unchanged' │     0     │     0     │ 'None' │
└────────────────────────────┴─────────────┴───────────┴───────────┴────────┘

(6/11) Running clean-globs
 UNCHANGED  turbo.json 
 UNCHANGED  apps/appName/turbo.json 

Results:
┌────────────────────────────┬─────────────┬───────────┬───────────┬────────┐
│          (index)           │   action    │ additions │ deletions │ error  │
├────────────────────────────┼─────────────┼───────────┼───────────┼────────┤
│         turbo.json         │ 'unchanged' │     0     │     0     │ 'None' │
│ apps/appName/turbo.json │ 'unchanged' │     0     │     0     │ 'None' │
└────────────────────────────┴─────────────┴───────────┴───────────┴────────┘

(7/11) Running add-package-names
 INFO  Validating that each package has a unique "name"... 
 MODIFIED  package.json 
 MODIFIED  apps/appName/package.json 

Results:
┌──────────────────────────────┬────────────┬───────────┬───────────┬────────┐
│           (index)            │   action   │ additions │ deletions │ error  │
├──────────────────────────────┼────────────┼───────────┼───────────┼────────┤
│         package.json         │ 'modified' │     1     │     0     │ 'None' │
│ apps/appName/package.json │ 'modified' │     1     │     1     │ 'None' │
└──────────────────────────────┴────────────┴───────────┴───────────┴────────┘

(8/11) Running migrate-dot-env
 INFO  Moving entries in `dotEnv` key in task config to `inputs` 
 UNCHANGED  turbo.json 
 UNCHANGED  apps/appName/turbo.json 

Results:
┌────────────────────────────┬─────────────┬───────────┬───────────┬────────┐
│          (index)           │   action    │ additions │ deletions │ error  │
├────────────────────────────┼─────────────┼───────────┼───────────┼────────┤
│         turbo.json         │ 'unchanged' │     0     │     0     │ 'None' │
│ apps/appName/turbo.json │ 'unchanged' │     0     │     0     │ 'None' │
└────────────────────────────┴─────────────┴───────────┴───────────┴────────┘

(9/11) Running rename-output-mode
 INFO  Renaming `outputMode` key in task config to `outputLogs` 
 UNCHANGED  turbo.json 
 UNCHANGED  apps/appName/turbo.json 

Results:
┌────────────────────────────┬─────────────┬───────────┬───────────┬────────┐
│          (index)           │   action    │ additions │ deletions │ error  │
├────────────────────────────┼─────────────┼───────────┼───────────┼────────┤
│         turbo.json         │ 'unchanged' │     0     │     0     │ 'None' │
│ apps/appName/turbo.json │ 'unchanged' │     0     │     0     │ 'None' │
└────────────────────────────┴─────────────┴───────────┴───────────┴────────┘

(10/11) Running rename-pipeline
 INFO  Renaming `pipeline` key in turbo.json to `tasks` 
 MODIFIED  turbo.json 
 MODIFIED  apps/appName/turbo.json 

Results:
┌────────────────────────────┬────────────┬───────────┬───────────┬────────┐
│          (index)           │   action   │ additions │ deletions │ error  │
├────────────────────────────┼────────────┼───────────┼───────────┼────────┤
│         turbo.json         │ 'modified' │     1     │     1     │ 'None' │
│ apps/appName/turbo.json │ 'modified' │     1     │     1     │ 'None' │
└────────────────────────────┴────────────┴───────────┴───────────┴────────┘

(11/11) Running stabilize-ui
 INFO  Renaming `experimentalUI` key in turbo.json to `ui` 
 UNCHANGED  turbo.json 

Results:
┌────────────┬─────────────┬───────────┬───────────┬────────┐
│  (index)   │   action    │ additions │ deletions │ error  │
├────────────┼─────────────┼───────────┼───────────┼────────┤
│ turbo.json │ 'unchanged' │     0     │     0     │ 'None' │
└────────────┴─────────────┴───────────┴───────────┴────────┘

Upgrading turbo with pnpm add turbo@latest --save-dev -w 

Migration failed
Unable to upgrade turbo: Error: Command failed: pnpm add turbo@latest --save-dev -w

Until it got to the last part there of upgrading turbo with pnpm. And since package references were wrong pnpm failed, thus migration failed.

I fixed the references, ran pnpm install in the root to make sure, and reran npx @turbo/codemod@latest update and got the error noted in Describe the Bug

Since the migrations succeed the first time I manually updated the package.json turbo version to "^2.0.3" and pnpm installed. And everything seemed to work ok.

A rare edge case but still reporting nonetheless.

Additional context

@maxshay maxshay added kind: bug Something isn't working needs: triage New issues get this label. Remove it after triage owned-by: turborepo labels Jun 15, 2024
@cmanuelpriver
Copy link

@maxshay Could you solve it? I have the same problem

@maxshay
Copy link
Author

maxshay commented Jun 19, 2024

@cmanuelpriver not really solved, but the first time i ran it, it seems like the migrations part was all successful. So i manually updated the turbo version from "^1.13.3" to "^2.0.4" in the package json, and did a pnpm install. And it seems to run fine.

If that doesn't work for you just create a separate turborepo app using the lastest version using the cmd line. And make sure the turbo related files look the same. Shouldn't be a lot of files for a regular project.

@cmanuelpriver
Copy link

I solved, I had problems with nvm and windows, I deleted everything and tried again and it worked, I never knew what the specific problem was.

@cmanuelpriver
Copy link

@maxshay Thank you for your help

@Nicolasvegam

This comment was marked as spam.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: bug Something isn't working needs: triage New issues get this label. Remove it after triage owned-by: turborepo
Projects
None yet
Development

No branches or pull requests

3 participants