vercel / turborepo

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

[turborepo] turbo prune throws unable to parse yaml: data did not match any variant of untagged enum StringOrNum #4925

Closed JuanJo4 closed 1 year ago

JuanJo4 commented 1 year ago

What version of Turborepo are you using?

1.9.4

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

Yarn v2/v3 (node_modules linker only)

What operating system are you using?

Mac

Describe the Bug

running yarn dlx turbo prune --scope=myapp throws:

 ERROR  could not construct graph: 1 error occurred:
        * unable to parse yaml: data did not match any variant of untagged enum StringOrNum at line 4 column 1

the same will work just fine with v1.9.3

I'm not sure which yaml file is referring to, i'm guessing is something internally in turbo?

Expected Behavior

yarn dlx turbo prune --scope=myapp won't throw errors.

To Reproduce

yarn dlx turbo prune --scope=myapp

Reproduction Repo

No response

danielpza commented 1 year ago

We are seeing the same issue with the latest version, yarn v3 node_module linker

Pagebakers commented 1 year ago

Just got the same issue while deploying to Vercel, also using yarn 3 with node_modules linker.

Hey commented 1 year ago

Same.

mrdrogdrog commented 1 year ago

Oh good! I'm not the only one.

Using yarn v3 with node_modules linker and turbo 1.9.4

krinoid commented 1 year ago

I'm also facing this error in the context of yarn v3.2.4 and node_modules linker. But turbo is installed using yarn v1.22.19, with RUN yarn global add turbo, as .yarn, .yarnrc.yml are not copied at that point yet. Log message:

#13 [prune 5/5] RUN turbo prune --scope=test-project --docker -vvv
#13 sha256:3720702b3f9d4e212d4db96ae544d01d6cfb770f362775072119ea03fa634454
#13 0.234 2023-05-15T10:19:12.213+0000 [DEBUG] turborepo_lib::shim: Global turbo version: 1.9.4
#13 0.234 2023-05-15T10:19:12.214+0000 [DEBUG] turborepo_lib::shim: No local turbo binary found at: /prune/node_modules/turbo-linux-arm64/bin/turbo
#13 0.234 2023-05-15T10:19:12.214+0000 [DEBUG] turborepo_lib::shim: No local turbo binary found at: /prune/node_modules/turbo/node_modules/turbo-linux-arm64/bin/turbo
#13 0.234 2023-05-15T10:19:12.214+0000 [DEBUG] turborepo_lib::shim: Repository Root: /prune
#13 0.234 2023-05-15T10:19:12.214+0000 [DEBUG] turborepo_lib::shim: Running command as global turbo
#13 0.235 2023-05-15T10:19:12.214+0000 [TRACE] log: registering event source with poller: token=Token(2147483649), interests=READABLE
#13 0.237 2023-05-15T10:19:12.216+0000 [TRACE] turborepo_lib::execution_state: Found berry as package manager
#13 0.238 2023-05-15T10:19:12.216+0000 [DEBUG] turbo: Found go binary at "/usr/local/share/.config/yarn/global/node_modules/turbo-linux-arm64/bin/go-turbo"
#13 0.238 2023-05-15T10:19:12.217+0000 [TRACE] turbo: Invoking go binary with {"api_client_config":{"token":null,"team_id":null,"team_slug":null,"api_url":"https://vercel.com/api","use_preflight":false,"timeout":20},"package_manager":"berry","cli_args":{"api":null,"color":false,"cpu_profile":null,"cwd":"/prune","heap":null,"login":null,"no_color":false,"preflight":false,"remote_cache_timeout":null,"team":null,"token":null,"trace":null,"verbosity":3,"test_run":false,"command":{"Prune":{"scope":["test-project"],"docker":true,"output_dir":"out"}}}}
#13 0.307 2023-05-15T10:19:12.287Z [ERROR] turbo: error: could not construct graph: 1 error occurred:
#13 0.307   * unable to parse yaml: data did not match any variant of untagged enum StringOrNum at line 4 column 1
#13 0.307
#13 0.307
#13 0.307  ERROR  could not construct graph: 1 error occurred:
#13 0.307   * unable to parse yaml: data did not match any variant of untagged enum StringOrNum at line 4 column 1
#13 0.307
#13 0.307
#13 0.307 Turbo error: could not construct graph: 1 error occurred:
#13 0.307   * unable to parse yaml: data did not match any variant of untagged enum StringOrNum at line 4 column 1
#13 0.307
#13 0.307
#13 ERROR: executor failed running [/bin/sh -c turbo prune --scope=test-project --docker -vvv]: exit code: 1

I validated that with RUN yarn global add turbo@1.9.3 turbo prune works fine and with RUN yarn global add turbo@1.9.4 I'm getting the above error. PRs that seem related:

This part in turbo/crates/turborepo-lockfiles/src/berry/de.rs seems to be related: https://github.com/vercel/turbo/blob/main/crates/turborepo-lockfiles/src/berry/de.rs#L33:

match StringOrNum::deserialize(deserializer)? {
            StringOrNum::String(s) => Ok(SemverString(s)),
            StringOrNum::Num(x) => Ok(SemverString(x.to_string())),
        }
chris-olszewski commented 1 year ago

Hello sorry for the disruption. Could someone section of the yarn.lock that the YAML parser is tripping over (it looks like line 4 which should be the __metadata section)?

krinoid commented 1 year ago

All good, thanks for your work on improving this great tool! 😄 Here's the top of the yarn.lock:

# This file is generated by running "yarn install" inside your project.
# Manual changes might be lost - proceed with caution!

__metadata:
  version: 6
  cacheKey: 8c0
chris-olszewski commented 1 year ago

Hmm, the line number of the parse error seems to be off, that metadata matches one of the fixtures we tested parsing against. Is there any way you could share your lockfile with me?

krinoid commented 1 year ago

Not immediately, sorry. I'd need to discuss with legal first and this might take a bit... If you can point me to the place where I could add more logging within turbo, I should be able to compile it locally, use it on the failing yarn.lock and share the relevant part.

chris-olszewski commented 1 year ago

No worries, I'm pretty sure I just found the issue. Should have a fix up soon.

chav-aniket commented 1 year ago

I'm getting the same ` WARNING Issues occurred when constructing package graph. Turbo will function, but some features may not be available: 1 error occurred:

# This file is generated by running "yarn install" inside your project.
# Manual changes might be lost - proceed with caution!

__metadata:
  version: 6
  cacheKey: 8
ValentinH commented 1 year ago

I confirm that #4945 is solving the issue.

JuanJo4 commented 1 year ago

i can confirm the issue is resolver in v1.9.7-canary.0. I guess issue can be closed once v1.9.8 is released.

Thanks @chris-olszewski and all 🤝