aspect-build / rules_js

High-performance Bazel rules for running Node.js tools and building JavaScript projects
https://docs.aspect.build/rules/aspect_rules_js
Apache License 2.0
310 stars 107 forks source link

Npm package with broken tarballs leading to "(Permission denied)" error #2026

Open gregmagolan opened 3 days ago

gregmagolan commented 3 days ago

Some npm packages have malformed tarballs (missing the +x file attr bit on directories) which don't play nicely with Bazel when they are extracted by the rules_js NpmPackageExtract action. See https://github.com/aspect-build/rules_js/issues/1637 for more details.

An example error from this issue:

WARNING: Remote Cache: /home/circleci/.cache/bazel/_bazel_circleci/a6e8cb0ce75ceb1ea1faa0cca0b0ae0d/execroot/figma/bazel-out/k8-fastbuild/bin/node_modules/.aspect_rules_js/pngjs@7.0.0/node_modules/pngjs/lib/format-normaliser.js (Permission denied)
ERROR: /home/circleci/foobar/BUILD.bazel:11:22: Extracting npm package pngjs@7.0.0 failed: IOException while logging spawn: /home/circleci/.cache/bazel/_bazel_circleci/a6e8cb0ce75ceb1ea1faa0cca0b0ae0d/execroot/figma/bazel-out/k8-fastbuild/bin/node_modules/.aspect_rules_js/pngjs@7.0.0/node_modules/pngjs/lib/bitmapper.js (Permission denied)

The work-around for these npm packages is to add custom_postinstall scripts for each with chmod -R a+X * or chmod -R a+X * && <other custom postinstall steps> to the npm_translate_lock repository rule / bzlmod extension.

This issue is here for users to share all of the package that this problem has been observed on where this work-around may be needed.

gregmagolan commented 3 days ago

@rahul-roy-glean listed a number of them in this comment https://github.com/aspect-build/rules_js/issues/1637#issuecomment-2314514337:

custom_postinstalls = {
        "pngjs": "chmod -R a+X *",
        "websocket-extensions": "chmod -R a+X *",
        "pretty-format": "chmod -R a+X *",
        "readdirp": "chmod -R a+X *",
        "serve-static": "chmod -R a+X *",
        "serialize-javascript": "chmod -R a+X *",
        "supports-preserve-symlinks-flag": "chmod -R a+X *",
        "strip-final-newline": "chmod -R a+X *",
        "webpack-dev-server": "chmod -R a+X *",
        "tapable": "chmod -R a+X *",
        "statuses": "chmod -R a+X *",
        "@nivo/legends": "chmod -R a+X *",
        "@lingui/react": "chmod -R a+X *",
        "license-webpack-plugin": "chmod -R a+X *",
        "command-exists-promise": "chmod -R a+X *",
    },