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

"File name too long" when trying to use generator for node

Open piotrek-k opened this issue 11 months ago • 1 comments

flatpak-builder version

flatpak-builder-1.4.2

Linux distribution and version

Linux Mint 22

Affected flatpak-builder tool

node/flatpak-node-generator.py

flatpak-builder tool cli args

No response

Source repository URL

No response

Flatpak-builder manifest URL

No response

Description

What I just did is:

  1. Cloned this repo:
git clone https://github.com/flatpak/flatpak-builder-tools   

(I'm on commit aac65cf44cd4e008594a9d9ac1db08e2025067a6) 2. Went to flatpak_node_generator (cd node/flatpak_node_generator ) 3. Installed dependencies pipx install . 4. Then I've ran generator on my lock file like this:

flatpak-node-generator npm package-lock.json 

Result as below:

Reading packages from lockfiles...
394 packages read.
Generating packages [312/394] sanitize-filename @ 1.6.3                                                                                                           
Traceback (most recent call last):
  File "/home/piotrek/.local/bin/flatpak-node-generator", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/piotrek/.local/share/pipx/venvs/flatpak-node-generator/lib/python3.12/site-packages/flatpak_node_generator/main.py", line 277, in main
    asyncio.run(_async_main())
  File "/usr/lib/python3.12/asyncio/runners.py", line 194, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/asyncio/base_events.py", line 687, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/home/piotrek/.local/share/pipx/venvs/flatpak-node-generator/lib/python3.12/site-packages/flatpak_node_generator/main.py", line 229, in _async_main
    await progress.run()
  File "/home/piotrek/.local/share/pipx/venvs/flatpak-node-generator/lib/python3.12/site-packages/flatpak_node_generator/progress.py", line 78, in run
    await coro
  File "/usr/lib/python3.12/asyncio/tasks.py", line 631, in _wait_for_one
    return f.result()  # May raise f.exception().
           ^^^^^^^^^^
  File "/home/piotrek/.local/share/pipx/venvs/flatpak-node-generator/lib/python3.12/site-packages/flatpak_node_generator/progress.py", line 68, in _generate
    await self.module_provider.generate_package(package)
  File "/home/piotrek/.local/share/pipx/venvs/flatpak-node-generator/lib/python3.12/site-packages/flatpak_node_generator/providers/npm.py", line 359, in generate_package
    size=await RemoteUrlMetadata.get_size(
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/piotrek/.local/share/pipx/venvs/flatpak-node-generator/lib/python3.12/site-packages/flatpak_node_generator/url_metadata.py", line 56, in get_size
    bucket_reader = bucket.open_read()
                    ^^^^^^^^^^^^^^^^^^
  File "/home/piotrek/.local/share/pipx/venvs/flatpak-node-generator/lib/python3.12/site-packages/flatpak_node_generator/cache.py", line 158, in open_read
    fp = self._cache_path.open('rb')
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/pathlib.py", line 1015, in open
    return io.open(self, mode, buffering, encoding, errors, newline)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
OSError: [Errno 36] File name too long: '/home/piotrek/.cache/flatpak-node-generator/remote-url-metadata_3Asize_3Ahttps_3A_2F_2Fregistry.npmjs.org_2Felectron-builder-squirrel-windows_2F-_2Felectron-builder-squirrel-windows-25.1.8.tgz'

Looks like the script is joining multiple paths into one and trying to access it.

Here is my lockfile:

package-lock.json

piotrek-k avatar Mar 03 '25 20:03 piotrek-k

Ok, so it turns out that your caching mechanism uses a naming convention that uses the full URL as the filename of the cached resource. In my case it simply exceeded max file name length.

I've managed to run this script successfully just by disabling caching:

$ flatpak-node-generator npm package-lock.json --no-requests-cache

But this is only a temporary workaround, ideally cache should name files in a different way...

piotrek-k avatar Mar 12 '25 20:03 piotrek-k