flatpak-builder-tools icon indicating copy to clipboard operation
flatpak-builder-tools copied to clipboard

node-generator does not support lockfiles generated by yarn v2 and above

Open vemonet opened this issue 2 years ago • 1 comments

flatpak-builder version

1.3.3

Linux distribution and version

Fedora 38

Affected flatpak-builder tool

node/flatpak-node-generator.py

flatpak-builder tool cli args

No response

Source repository URL

https://github.com/vemonet/EmojiMart/tree/19df11b324e74a9e3d32f25d65e7595b08c59c8c

Flatpak-builder manifest URL

https://github.com/vemonet/flathub/tree/io.github.vemonet.EmojiMart

Description

When trying to build the sources for a yarn.lock generated by yarn v3 (which is the version officially recommended by yarn today), it fails with the error:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/vemonet/develop/tmp/flatpak-builder-tools/node/flatpak_node_generator/main.py", line 277, in main
    asyncio.run(_async_main())
  File "/opt/conda/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/opt/conda/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "/home/vemonet/develop/tmp/flatpak-builder-tools/node/flatpak_node_generator/main.py", line 198, in _async_main
    packages.update(lockfile_provider.process_lockfile(lockfile))
  File "/home/vemonet/develop/tmp/flatpak-builder-tools/node/flatpak_node_generator/providers/yarn.py", line 107, in process_lockfile
    for name_line, package in self.parse_lockfile(lockfile).items():
  File "/home/vemonet/develop/tmp/flatpak-builder-tools/node/flatpak_node_generator/providers/yarn.py", line 69, in parse_lockfile
    key, value = shlex.split(line)
ValueError: too many values to unpack (expected 2)

Which is triggered by the line conditions: os=android & cpu=arm64 (your parser expect only 1 blank space per line, to split it in 2 variables)

Note that I shared my repo URL with the commit where I was still using yarn v3 to help reproduce the error, but the main is now using yarn v1

There are a few changes of lockfile format between yarn v1 and v3, so I would expect there will be many other things to fix, so not sure if someone will have the time to look into it

In the meantime would it be possible to print a clearer error message when a user try to compile sources for a yarn v3 lockfile please? e.g. Lockfiles generated by yarn v3+ are not supported, please use yarn v1, cf. https://classic.yarnpkg.com/lang/en/

vemonet avatar Jun 28 '23 17:06 vemonet

In the meantime would it be possible to print a clearer error message when a user try to compile sources for a yarn v3 lockfile please? e.g. Lockfiles generated by yarn v3+ are not supported, please use yarn v1, cf. https://classic.yarnpkg.com/lang/en/

I added the error, only v1 lockfiles are supported

bbhtt avatar Jul 25 '25 04:07 bbhtt