Skip to content

[Bug]: 'node_modules/.bin' directory not created in sandbox #630

@gregjacobs

Description

@gregjacobs

What happened?

Hey guys, so I came across an interesting scenario: I'm using 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/<user>/.npm/_npx/61742, resulting in the following error:

Error: EPERM: operation not permitted, mkdir '/Users/<user>/.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:

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:

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:

bazel build //:test_icon_font_buildr

Any other information?

No response

Fund our work

  • Sponsor our open source work by donating a bug bounty

Metadata

Metadata

Assignees

No one assigned

    Labels

    blockedBlocked by another issueenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions