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

@turbo/codemod Unexpected error. Please report it as a bug #9056

Open
1 task done
shuther opened this issue Aug 24, 2024 · 1 comment
Open
1 task done

@turbo/codemod Unexpected error. Please report it as a bug #9056

shuther opened this issue Aug 24, 2024 · 1 comment
Labels
kind: bug Something isn't working needs: triage New issues get this label. Remove it after triage

Comments

@shuther
Copy link

shuther commented Aug 24, 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?

npm, Yarn v2/v3/v4 (node_modules linker only)

What operating system are you using?

Mac

Which canary version will you have in your reproduction?

1.13.4

Describe the Bug

I tried to migrate from 1.13.4 -> 2.x using: npx @turbo/codemod update --force (I also tried @canary version)

Need to install the following packages:
@turbo/[email protected]
Ok to proceed? (y) y

npm warn deprecated [email protected]: cross-spawn no longer requires a build toolchain, use it instead
WARNING: Git directory is not clean. Forcibly continuing...
? Where is the root of the repo to migrate? .
Upgrading turbo from 1.13.4 to 2.0.14 (11 required codemods) 

(1/11) Running add-package-manager
 INFO  "packageManager" already set in root "package.json" 

(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"... 

Unexpected error. Please report it as a bug:
TypeError: Cannot convert undefined or null to object
    at Function.values (<anonymous>)
    at Iu (/Users/shuther/.npm/_npx/24554e532d5698bb/node_modules/@turbo/codemod/dist/transforms/migrate-env-var-dependencies.js:39:7068)
    at Object.zS [as transformer] (/Users/shuther/.npm/_npx/24554e532d5698bb/node_modules/@turbo/codemod/dist/transforms/migrate-env-var-dependencies.js:39:8582)
    at Command.Zh (/Users/shuther/.npm/_npx/24554e532d5698bb/node_modules/@turbo/codemod/dist/cli.js:46:9079)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Command.parseAsync (/Users/shuther/.npm/_npx/24554e532d5698bb/node_modules/commander/lib/command.js:935:5)

Expected Behavior

upgrade turbo to latest version

To Reproduce

n/a

Additional context

migrate failed with (but it seems every steps to change turbo.json went well, the latest one is 11/11 - Running stabilize-ui)

Migration failed
Unable to determine upgrade command
➜  web-main3-git git:(gitbutler/integration) ✗ npx @turbo/codemod      

turbo.json after the 1st pass of migrate before update again:

{
  "$schema": "https://turborepo.org/schema1.json",
  "globalDependencies": [
    "**/.env",
    "**/.env.*local",
    "tsconfig.json"
  ],
  "globalEnv": [
    "PACKAGE_VERSION",
    "NODE_ENV"
  ],
  "globalPassThroughEnv": [
    "CROWDIN_PERSONAL_TOKEN",
    "CROWDIN_PROJECT_ID",
    "GITHUB_TOKEN"
  ],
  "tasks": {
    "topo": {
      "dependsOn": [
        "^topo"
      ]
    },
    "build": {
      "dependsOn": [
        "^build"
      ],
      "env": [
        "\\*",
        "RESEND_API_KEY",
        "\\!NEXT_PUBLIC_GIT_\\*",
        "TINY_BIRD_API_KEY",
        "NODE_ENV",
        "VERCEL_URL"
      ],
      "outputs": [
        ".next/**",
        "!.next/cache/**",
        "next-env.d.ts"
      ],
      "inputs": [
        "$TURBO_DEFAULT$",
        "!README.md"
      ]
    },
    "dev": {
      "persistent": true,
      "cache": false
    },
    "format": {
      "outputs": [
        "node_modules/.cache/.prettiercache"
      ],
      "outputLogs": "new-only"
    },
    "lint": {
      "dependsOn": [
        "^topo"
      ],
      "outputs": [
        "node_modules/.cache/.eslintcache"
      ]
    },
    "typecheck": {
      "dependsOn": [
        "^topo"
      ],
      "outputs": [
        "node_modules/.cache/tsbuildinfo.json"
      ]
    },
    "clean": {
      "cache": false
    }
  }
}

@shuther shuther added kind: bug Something isn't working needs: triage New issues get this label. Remove it after triage labels Aug 24, 2024
@jongjunpark
Copy link

"tasks" is available to turbo 2.x. Therefore, the error is occurring because "tasks" cannot be read. As a solution, change "tasks" to "pipeline," which can be read by version 1, and then run npx @turbo/codemod update, which will automatically update it.

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
Projects
None yet
Development

No branches or pull requests

2 participants