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

fetchYarnDeps fails if yarn lock has link lockentry #284157

Open
berberman opened this issue Jan 27, 2024 · 3 comments
Open

fetchYarnDeps fails if yarn lock has link lockentry #284157

berberman opened this issue Jan 27, 2024 · 3 comments
Labels

Comments

@berberman
Copy link
Member

Describe the bug

I found this issue while I was trying to update typst-preview to 0.10.7. In this commit, the author changed the dependency type of the local package typst-dom from file to link:

--- a/addons/frontend/package.json
+++ b/addons/frontend/package.json
@@ -14,11 +14,11 @@
   "dependencies": {
     "@myriaddreamin/typst-ts-renderer": "0.4.2-rc5",
     "@myriaddreamin/typst.ts": "0.4.2-rc5",
-    "typst-dom": "file:../typst-dom",
+    "typst-dom": "link:../typst-dom",
     "rxjs": "^7.8.1"
   },

with the follow changing in the lock file:

--- a/addons/frontend/yarn.lock
+++ b/addons/frontend/yarn.lock
-"typst-dom@file:../typst-dom":
+"typst-dom@link:../typst-dom":
   version "0.0.0"
+  uid ""
 

However, it seems that fetchYarnDeps only skips for downloading for file:

const downloadPkg = (pkg, verbose) => {
const fileMarker = '@file:'
const split = pkg.key.split(fileMarker)
if (split.length == 2) {
console.info(`ignoring lockfile entry "${split[0]}" which points at path "${split[1]}"`)
return
} else if (split.length > 2) {
throw new Error(`The lockfile entry key "${pkg.key}" contains "${fileMarker}" more than once. Processing is not implemented.`)
}
if (pkg.resolved === undefined) {
throw new Error(`The lockfile entry with key "${pkg.key}" cannot be downloaded because it is missing the "resolved" attribute, which should contain the URL to download from. The lockfile might be invalid.`)
}
const [ url, hash ] = pkg.resolved.split('#')
if (verbose) console.log('downloading ' + url)
const fileName = urlToName(url)
if (url.startsWith('https://codeload.github.com/') && url.includes('/tar.gz/')) {
const s = url.split('/')
return downloadGit(fileName, `https://github.com/${s[3]}/${s[4]}.git`, s[s.length-1])
} else if (url.startsWith('https://github.com/') && url.endsWith('.tar.gz')) {
const s = url.split('/')
return downloadGit(fileName, `https://github.com/${s[3]}/${s[4]}.git`, s[s.length-1].replace(/.tar.gz$/, ''))
} else if (isGitUrl(url)) {
return downloadGit(fileName, url.replace(/^git\+/, ''), hash)
} else if (url.startsWith('https://')) {
if (typeof pkg.integrity === 'string' || pkg.integrity instanceof String) {
const [ type, checksum ] = pkg.integrity.split('-')
return downloadFileHttps(fileName, url, Buffer.from(checksum, 'base64').toString('hex'), type)
}
return downloadFileHttps(fileName, url, hash)
} else if (url.startsWith('file:')) {
console.warn(`ignoring unsupported file:path url "${url}"`)
} else {
throw new Error('don\'t know how to download "' + url + '"')
}
}

And building the following drv:

let
  version = "0.10.7";
  src = fetchFromGitHub {
    owner = "Enter-tainer";
    repo = "typst-preview";
    rev = "v${version}";
    hash = "sha256-32GYsUMXYCoVNZzgALMR0XpFmHBPw8FQQkurKWdMQcc=";
    fetchSubmodules = true;
  };
fetchYarnDeps {
      yarnLock = "${src}/addons/frontend/yarn.lock";
      hash = "";
};

would fail with:

error: builder for '/nix/store/skvlzybc5518pngplb4ar0yjw6y4zrdi-offline.drv' failed with exit code 1;
       last 10 log lines:
       > downloading https://registry.yarnpkg.com/type-detect/-/type-detect-4.0.8.tgz
       > downloading https://registry.yarnpkg.com/typescript/-/typescript-5.3.3.tgz
       > Error: The lockfile entry with key "typst-dom@link:../typst-dom" cannot be downloaded because it is missing the "resolved" attribute, which should contain the URL to download from. The lockfile might be invalid.
       >     at downloadPkg (/nix/store/nj12l3mc3jl02lf0fb9zfq0ckgdgh2xn-prefetch-yarn-deps/libexec/index.js:101:9)
       >     at /nix/store/nj12l3mc3jl02lf0fb9zfq0ckgdgh2xn-prefetch-yarn-deps/libexec/index.js:145:32
       >     at worker (/nix/store/nj12l3mc3jl02lf0fb9zfq0ckgdgh2xn-prefetch-yarn-deps/libexec/index.js:130:47)
       >     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
       >     at async Promise.all (index 1)
       >     at async prefetchYarnDeps (/nix/store/nj12l3mc3jl02lf0fb9zfq0ckgdgh2xn-prefetch-yarn-deps/libexec/index.js:143:2)
       >     at async main (/nix/store/nj12l3mc3jl02lf0fb9zfq0ckgdgh2xn-prefetch-yarn-deps/libexec/index.js:187:3)
       For full logs, run 'nix log /nix/store/skvlzybc5518pngplb4ar0yjw6y4zrdi-offline.drv'.

IIUC, we should also check and skip for downloading if the path in an lockentry is a link.

Notify maintainers

@lorenzleutgeb

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
output here
  • system: "x86_64-linux"
  • host os: Linux 6.1.73, NixOS, 24.05 (Uakari), 24.05.20240117.842d9d8
  • multi-user?: yes
  • sandbox: yes
  • version: nix-env (Nix) 2.18.1
  • nixpkgs: /nix/store/gyjzpkp0g6xa2rj105nbgm7cki1d682m-wcidiyklj0nrljlz5m3qlkvhv8f2ddv8-source

Add a 👍 reaction to issues you find important.

@lorenzleutgeb
Copy link
Member

cc @yu-re-ka @lilyinstarlight

@drupol
Copy link
Contributor

drupol commented Feb 20, 2024

Encountered the issue and fixed it using substituteInPlace in #290207

@lorenzleutgeb
Copy link
Member

@drupol thanks for mentioning the workaround! :)

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

No branches or pull requests

4 participants