Skip to content

Non-deterministic temporary files left in node_modules #2612

@alexeagle

Description

@alexeagle

A Makefile is generated during compilation, for example the ffi-napi package leaves a file node_modules/ffi-napi/build/Makefile on the disk.

This file contains an absolute path on the disk, which is non-deterministic: it depends on the setup of the machine where the installation takes place.

As a result, build systems which do incremental re-build/re-test based on distributed caches (such as Bazel) will have a cache miss when this file gets included in the inputs.

As a workaround, Bazel users must delete the build folder from offending packages in a postinstall step to avoid re-building everything that depends on that package.

 "scripts": {
    "// ": "we must delete non-deterministic outputs from compiling native packages, or they bust the bazel cache",
    "postinstall": "rm -rf node_modules/{deasync,iltorb,node-sass}/build node_modules/node-gyp/gyp/pylib/gyp/generator/__pycache__",
}

Instead I think it would be better for node-gyp to clean up its temporary files. (Perhaps a flag can be added for users who want to inspect those files to debug a native compilation)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions