Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non-deterministic temporary files left in node_modules #2612

Closed
alexeagle opened this issue Feb 14, 2022 · 1 comment
Closed

Non-deterministic temporary files left in node_modules #2612

alexeagle opened this issue Feb 14, 2022 · 1 comment
Labels
ffi-napi Node Sass --> Dart Sass https:/sass/node-sass/issues/2952

Comments

@alexeagle
Copy link

alexeagle commented Feb 14, 2022

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)

@jwalton
Copy link

jwalton commented Jul 18, 2023

I'm buildng on Docker, so the paths are always the same, but the order of some of the dependencies for the Makefile target differs from one build to the next (this example is from better-sqlite3):

< Makefile: $(srcdir)/binding.gyp $(srcdir)/deps/defines.gypi $(srcdir)/../../../../local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi $(srcdir)/build/config.gypi $(srcdir)/deps/sqlite3.gyp $(srcdir)/../../../../../root/.cache/node-gyp/18.16.1/include/node/common.gypi $(srcdir)/deps/common.gypi
---
> Makefile: $(srcdir)/build/config.gypi $(srcdir)/deps/sqlite3.gyp $(srcdir)/deps/defines.gypi $(srcdir)/binding.gyp $(srcdir)/../../../../local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi $(srcdir)/../../../../../root/.cache/node-gyp/18.16.1/include/node/common.gypi $(srcdir)/deps/common.gypi

So even keeping your paths the same doesn't make this deterministic.

@cclauss cclauss added the Node Sass --> Dart Sass https:/sass/node-sass/issues/2952 label Apr 3, 2024
@cclauss cclauss closed this as completed May 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ffi-napi Node Sass --> Dart Sass https:/sass/node-sass/issues/2952
Projects
None yet
Development

No branches or pull requests

3 participants