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

Failure with dependencies with multiple integrities #46

Open
mmm444 opened this issue Jun 6, 2022 · 0 comments
Open

Failure with dependencies with multiple integrities #46

mmm444 opened this issue Jun 6, 2022 · 0 comments

Comments

@mmm444
Copy link

mmm444 commented Jun 6, 2022

Sometimes npm can generate package-lock.json file where the same dependency when identified by the resolved URL can be present with multiple integrity values - each for different hashing algorithm. For example let's say we are building package A that depends on packages B and C and B happens to also depend on C, both C in the same version. Then the C can have different integrity value in each subtree, like this:

A
├── B
│   └── C (resolved: http://c-url, integrity: sha1-somehash)
└── C     (resolved: http://c-url, integrity: sha512-someotherhash)

The output of cacheInput function in default.nix is indexed by the resolved url. This leads to the situation where the cacache generated by the mknpmcache.js script contains the package with only one of the integrity values. As the lookup to cacache by npm is done by the integrity value this leads to unresolved dependencies during the build. :(

I have managed to overcome this by indexing the result of cacheInput by the integrity value like this:

diff --git a/default.nix b/default.nix
index 1993513..1da4f1e 100644
--- a/default.nix
+++ b/default.nix
@@ -13,7 +13,7 @@ let
         bname
       else
         bname + ".tgz";
-    in nameValuePair resolved {
+    in nameValuePair integrity {
       inherit name bname integrity;
       path = fetchurl {
         name = fname;

Then cacache can index the same content with multiple integrity values as discussed in npm/cacache#25 (comment) and the npm cache lookups work (at least in my case).

I am novice in the area of npm & nix so I am not sure if I miss something or not. I can turn this into a PR if you are happy with this solution. Or you can apply the patch directly if you wish.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant