Closed rafalsatl closed 1 month ago
Hello, the answer is right on the landing page :) :
PYarn only supports Yarn v1 lockfiles. Parsing Yarn v2 lockfiles should be trivial since they are yaml files.
To add a bit more context, Yarn v2+ lockfiles include __metadata
that distinguish it from a v1 lockfile: https://github.com/yarnpkg/berry/blob/10d16c36653713dae4c4347394cd80b7c2015412/packages/yarnpkg-core/sources/Project.ts#L374
Thanks.
Even though it's on the landing page and it's easy etc
File ".../venv/lib/python3.12/site-packages/ply/yacc.py", line 1063, in parseopt_notrack lookahead = get_token() # Get the next token ^^^^^^^^^^^ File ".../venv/lib/python3.12/site-packages/pyarn/lexer_wrapper.py", line 36, in token t = self.lexer.token() ^^^^^^^^^^^^^^^^^^ File ".../venv/lib/python3.12/site-packages/ply/lex.py", line 386, in token newtok = self.lexerrorf(tok) ^^^^^^^^^^^^^^^^^^^ File ".../venv/lib/python3.12/site-packages/pyarn/lexer.py", line 99, in t_error raise ValueError(f"{t.lexer.lineno}: Invalid token {t.value}") ValueError: 4: Invalid token __metadata: version: 6 cacheKey: 8
Followed by the whole lock file contents ;) (notice the sizes)
-rw-r--r--@ 1 ... 906636 Sep 3 12:45 log.txt -rw-r--r--@ 1 ... 11648 Sep 3 12:43 package.json -rw-r--r--@ 1 ... 904436 Sep 3 12:43 yarn.lock
The team created this library to solve a single particular thing in a different project. While I can't rule out the possibility of adding what you're asking, we're not actively maintaining this either and we may even archive it in the future solely because of the lack of maintenance.
Hi, @rafalsatl, thanks for the report :)
When I initially started writing this package, yarn v2 wasn't widely adopted at all. Given the time constraint I had back then (we needed this to support a specific use case of a project), we decided not to cover v2 back then. Covering it should be quite straightforward since it is mostly yaml. You you like to try preparing a PR to extend it to cover other versions of yaml as well?
Thanks @athos-ribeiro - I understand how we got here. I did take a look inside when trying to understand the errors and what it would take to add the support but... in the process just wrote my own basic to cover the specific use case I had and cover both versions (it even keeps comments and their order ;) )
I'm getting errors trying to read yarn.lock file version 6 - are there any plans to support anything above version 1 anytime soon?