aspect-build / aspect-build/rules_js
[Bug]: 'node_modules/.bin' directory not created in sandbox
- Dominant language
- Starlark
- Stars
- 378
- Forks
- 183
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 32
Description
### What happened?
Hey guys, so I came across an interesting scenario: I'm using [icon-font-buildr](https://www.npmjs.com/package/icon-font-buildr) to generate a font file, and the utility tries to spawn a process as part of its execution: `npx svg2ttf`
Unfortunately, because `node_modules/.bin/svg2ttf` is not found, `npx` instead tries to download the package and store it in `/users//.npm/_npx/61742`, resulting in the following error:
```
Error: EPERM: operation not permitted, mkdir '/Users//.npm/_npx/61742'
```
Would it be possible to create the `node_modules/.bin` directory for the Bazel sandbox? Seems like this would get this particular package to work, along with any other packages that rely on calling the `npx` command internally.
The `npx` call can be seen in the source code here btw: https://github.com/fabiospampinato/icon-font-buildr/blob/master/src/index.ts#L387
### Version
Development (host) and target OS/architectures: MacOS Monterey
Output of `bazel --version`: 6.0.0-pre.20221020.1
Version of the Aspect rules, or other relevant rules from your
`WORKSPACE` or `MODULE.bazel` file: rules_js 1.6.8
Language(s) and/or frameworks involved: JS
### How to reproduce
**BUILD**:
```starlark
load("@aspect_rules_js//js:defs.bzl", "js_binary", "js_run_binary")
js_run_binary(
name = "test_icon_font_buildr",
tool = ":test_icon_font_buildr_bin",
outs = ["builder-fonts/MaterialDesign.woff2"]
)
js_binary(
name = "test_icon_font_buildr_bin",
entry_point = "test-icon-font-buildr.js",
data = [
"//:node_modules/icon-font-buildr",
"//:node_modules/svg2ttf",
]
)
```
**test-icon-font-buildr.js**:
```js
const path = require('path');
const IconFontBuildr = require('icon-font-buildr');
async function build() {
const builder = new IconFontBuildr({
sources: [
// Where to get the icons
'https://fonts.gstatic.com/s/i/materialicons/[icon]/v5/24px.svg',
],
icons: [
// Icons to download/use
'error',
],
output: {
fonts: path.join(__dirname, 'builder-fonts'), // Where to save the fonts
fontName: 'MaterialDesign', // The name of the font to generate
formats: [
'woff2',
],
},
});
await builder.build();
}
build().catch(err => {
console.log(err);
process.exit(1);
});
```
**Command**:
```bash
bazel build //:test_icon_font_buildr
```
### Any other information?
_No response_
### Fund our work
- [ ] Sponsor our open source work by donating a [bug bounty](https://opencollective.com/aspect-build/)
Contributor guide
Research direction
Start with the BUILD reproduction and test-icon-font-buildr.js, then run `bazel build //:test_icon_font_buildr` using the reported rules_js setup. Trace the Bazel sandbox contents during the build, focusing on why node_modules/.bin/svg2ttf is unavailable. Done means the sandbox provides node_modules/.bin and the example build succeeds without npx downloading svg2ttf.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100