You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fetchYarnDeps doesn't support v2 (YAML) lockfiles #254369
SyntaxError: Unknown token: { line: 3, col: 2, type: 'INVALID', value: undefined } 3:2 in lockfile
at Parser.unexpected (/nix/store/b1wnrddjgg85i1w4kzgsp8mksa344abx-prefetch-yarn-deps/libexec/yarnpkg-lockfile.js:5064:11)
at Parser.parse (/nix/store/b1wnrddjgg85i1w4kzgsp8mksa344abx-prefetch-yarn-deps/libexec/yarnpkg-lockfile.js:5193:14)
at parse (/nix/store/b1wnrddjgg85i1w4kzgsp8mksa344abx-prefetch-yarn-deps/libexec/yarnpkg-lockfile.js:5262:17)
at module.exports.exports.default (/nix/store/b1wnrddjgg85i1w4kzgsp8mksa344abx-prefetch-yarn-deps/libexec/yarnpkg-lockfile.js:4835:96)
at prefetchYarnDeps (/nix/store/b1wnrddjgg85i1w4kzgsp8mksa344abx-prefetch-yarn-deps/libexec/index.js:133:28)
at main (/nix/store/b1wnrddjgg85i1w4kzgsp8mksa344abx-prefetch-yarn-deps/libexec/index.js:187:9)
I suspect that this is because it's a new-style yarn.lock file using the YAML syntax, and not the old "custom" syntax. The yarnpkg-lockfile npm package can't parse it for that reason.
Notify maintainers
cc @lilyinstarlight (not technically maintainer I think, but you touched it last :p)
Reacted by Nicholas Sielicki, Nicolas Lenz, Dan Buch, Lord-Valen, Atemu, Jalil David Salamé Messina, Tristan Smith, Violet, A1ca7raz, Felix Bargfeldt and 20 more
Our tooling still won't actually work with yarn-berry yet, even if it did parse the lockfile. I do want proper yarn-berry support soon though, given a lot of things are starting to use it now
not technically maintainer I think, but you touched it last :p
No I'm not technically maintainer, but unless someone else steps up I'm probably going to be the one to add yarn-berry support to our tooling anyway 🙈
Yeah, I hacked around to add YAML parsing support and found out that there's (unsurprisingly) a lot more things to fix, and I'm very out of my depth with 0 knowledge of that ecosystem unfortunately :) Thank you!
i looked into this more with some digging into the yarn codebase and it seems like we've got a few issues:
newer yarn has a resolution key instead of a URL, in the format of name@protocol:version, (ex. @aashutoshrathi/word-wrap@npm:1.2.6) so we have to construct the URL to download ourselves
checksums are now hex encoded and based on, from what i could tell, a zipfile of the actual files on disk. what confuses me is that the zipfile compression seems to be configurable, which i can only assume will interfere with the hashes...
this is possible to fix but imo the better solution would be to find some way to use yarn cli to do the actual fetching and validation because this is much more complicated
UPDATE: the checksum thing is ridiculous. i did some testing and yes, changing the compression level in the yarn config will change the hashes of every single lockfile entry, or fail if --immutable is passed.
the default compress level is 0, so it's not like this will always break...
i'm leaning towards just running yarn install --immutable --mode skip-scripts instead of reimplementing their own logic but worse. i'm not entirely sure why we don't always just do that, i think it's probably because we operate off of only the lockfile and yarn itself requires the presence of a package.json as well.
If builtins.fromYaml (NixOS/nix#7340) gets merged, would it be possible to use the hashes from yarn.lock directly and get rid of other sort of vendor hashs?
I don't see us using fromYAML any time soon even if it was merged tomorrow because it'd break eval with old versions of Nix.
Not sure about the process to determine when to use a built-in function, but it's sensible to wait at least until the stable branch-off after it hits Nixpkgs.
There's a sizable chunk of users still on nix 2.3. I don't see a good reason to break eval for them. And if it has to be polyfilled anyway, then we don't even need to wait for the PR merge to do so.
I'm not sure if this checks off all the stability requirements for nixpkgs, but if you need to package something for personal use, you can do something like this:
Activity
lilyinstarlight commentedon Sep 10, 2023
Our tooling still won't actually work with yarn-berry yet, even if it did parse the lockfile. I do want proper yarn-berry support soon though, given a lot of things are starting to use it now
No I'm not technically maintainer, but unless someone else steps up I'm probably going to be the one to add yarn-berry support to our tooling anyway 🙈
delroth commentedon Sep 10, 2023
Yeah, I hacked around to add YAML parsing support and found out that there's (unsurprisingly) a lot more things to fix, and I'm very out of my depth with 0 knowledge of that ecosystem unfortunately :) Thank you!
ashkitten commentedon Jan 7, 2024
i looked into this more with some digging into the yarn codebase and it seems like we've got a few issues:
resolutionkey instead of a URL, in the format ofname@protocol:version, (ex.@aashutoshrathi/word-wrap@npm:1.2.6) so we have to construct the URL to download ourselvesthis is possible to fix but imo the better solution would be to find some way to use yarn cli to do the actual fetching and validation because this is much more complicated
ashkitten commentedon Jan 8, 2024
UPDATE: the checksum thing is ridiculous. i did some testing and yes, changing the compression level in the yarn config will change the hashes of every single lockfile entry, or fail if --immutable is passed.
the default compress level is 0, so it's not like this will always break...
i'm leaning towards just running
yarn install --immutable --mode skip-scriptsinstead of reimplementing their own logic but worse. i'm not entirely sure why we don't always just do that, i think it's probably because we operate off of only the lockfile and yarn itself requires the presence of a package.json as well.EDIT: bug report submitted upstream here: yarnpkg/berry#6068
dotlambda commentedon Jan 9, 2024
We need to use a format that's guaranteed to be stable across different versions of Yarn.
ShamrockLee commentedon Feb 26, 2024
If
builtins.fromYaml(NixOS/nix#7340) gets merged, would it be possible to use the hashes fromyarn.lockdirectly and get rid of other sort of vendor hashs?Atemu commentedon Feb 26, 2024
I don't see us using
fromYAMLany time soon even if it was merged tomorrow because it'd break eval with old versions of Nix.ShamrockLee commentedon Feb 26, 2024
Not sure about the process to determine when to use a built-in function, but it's sensible to wait at least until the stable branch-off after it hits Nixpkgs.
https://discourse.nixos.org/t/when-is-a-nix-builtin-function-builtins-considered-ready-to-be-used-inside-nixpkgs/35369/2
eclairevoyant commentedon Feb 26, 2024
There's a sizable chunk of users still on nix 2.3. I don't see a good reason to break eval for them. And if it has to be polyfilled anyway, then we don't even need to wait for the PR merge to do so.
szlend commentedon Apr 27, 2024
I'm not sure if this checks off all the stability requirements for
nixpkgs, but if you need to package something for personal use, you can do something like this:Expand source
21 remaining items
anki: 24.11 -> 25.02
anki: 24.11 -> 25.02
euank commentedon Apr 25, 2025
Now that #399404 has landed, you can use
yarn-berry.fetchYarnBerryDepsinstead for v2 lockfiles.