aspect-build / aspect-build/rules_js

[Bug]: Preinstall scripts are not executed with js_image_layer

Open
#972 4 comments 0 reactions 0 assignees View on GitHub
bug enhancement need: funding
Dominant language
Starlark
Stars
378
Forks
183
Avg merge
1d 9h
Merged PRs (30d)
32

Description

### What happened?

I'm depending on a package that requires node-gyp in a preinstall script. This works fine when running locally, but when running in a Linux docker container using js_image_layer, it causes an error like the below:

Error: /app/main.runfiles/__main__/node_modules/.aspect_rules_js/ref-napi@3.0.3/node_modules/ref-napi/build/Release/binding.node: invalid ELF header

I believe this is caused by the package being compiled for the host machine, during the preinstall script phase, but not being recompiled in the Docker image. Therefore, the binding.node file is running the version from the host PC, which may have been compiled for a difference arch/os.

Example: https://github.com/jacobshirley/rules_js/tree/main/e2e/js_image_docker_preinstall_scripts

### Version

Development (host) and target OS/architectures: MacOs Ventura 13.2.1 M2 chip

Output of `bazel --version`: aspect 5.2.1

Version of the Aspect rules, or other relevant rules from your
`WORKSPACE` or `MODULE.bazel` file: v1.23.2 (latest)

Language(s) and/or frameworks involved: JavaScript/Docker

### How to reproduce

```shell
I have created an example that should be reproducible: https://github.com/jacobshirley/rules_js/tree/main/e2e/js_image_docker_preinstall_scripts
```

### Any other information?

I can't think of anything else i can try

Contributor guide

Open the contributing guide

Research direction

Start with the reproducible example in e2e/js_image_docker_preinstall_scripts and the js_image_layer behavior described in the report. Reproduce the Mac-to-Linux case and inspect when the preinstall script and native binding.node are handled. Done means the Linux image does not retain an incompatible host-compiled binding and the example succeeds.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, javascript
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.