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

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

Closed
JuanJo4 opened this issue May 13, 2023 · 13 comments
Labels
kind: bug Something isn't working needs: triage New issues get this label. Remove it after triage

Comments

@JuanJo4
Copy link

JuanJo4 commented May 13, 2023

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

@JuanJo4 JuanJo4 added area: turborepo kind: bug Something isn't working needs: triage New issues get this label. Remove it after triage labels May 13, 2023
@JuanJo4 JuanJo4 changed the title [turborepo] [turborepo] turbo prune throws unable to parse yaml: data did not match any variant of untagged enum StringOrNum May 13, 2023
@danielpza
Copy link

danielpza commented May 13, 2023

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

@Pagebakers
Copy link

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

@Hey
Copy link

Hey commented May 13, 2023

Same.

@mrdrogdrog
Copy link

Oh good! I'm not the only one.

Using yarn v3 with node_modules linker and turbo 1.9.4

@krinoid
Copy link

krinoid commented May 15, 2023

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
Copy link
Contributor

chris-olszewski commented May 15, 2023

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
Copy link

krinoid commented May 15, 2023

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
Copy link
Contributor

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
Copy link

krinoid commented May 15, 2023

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
Copy link
Contributor

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

chris-olszewski added a commit that referenced this issue May 16, 2023
### Description

I believe this is probably the culprit behind #4925. 

`serde_yaml` parses `1` as an unsigned int, `1.2` as a float, and
`1.2.3` as a string. We were missing handling the float case.

### Testing Instructions

Added unit test of deserialization of semver ranges that's a valid float
@chav-aniket
Copy link

chav-aniket commented May 17, 2023

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: * unable to parse yaml: data did not match any variant of untagged enum StringOrNum at line 4 column 1 but with turbo build instead on turbo@1.9.6 😞 Have my yarn.lock below

# 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
Copy link
Contributor

I confirm that #4945 is solving the issue.

@JuanJo4
Copy link
Author

JuanJo4 commented May 17, 2023

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 🤝

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

10 participants