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: couldn't find any versions but yarn install works #203708

Closed
urandom2 opened this issue Nov 30, 2022 · 5 comments
Closed

fetchYarnDeps: couldn't find any versions but yarn install works #203708

urandom2 opened this issue Nov 30, 2022 · 5 comments

Comments

@urandom2
Copy link
Contributor

urandom2 commented Nov 30, 2022

Describe the bug

while packaging #114305, mkYarnPackage appears to be incorrectly setting up yarn-offline-mirror.

Steps To Reproduce

Steps to reproduce the behavior:

  1. setup legacyPackages pointer to:
mkYarnPackage rec {
  pname = "olaris-react";
  version = "0.4.0";

  src = fetchFromGitLab {
    owner = "olaris-react";
    repo = pname;
    rev = "v${version}";
    hash = "sha256-VPHIjmNry8KwEB3/4jZU2DNSgPTI+46Fydyc7Hi6BoM=";
  };

  postBuild = "yarn --offline build";

  installPhase = "cp -a build $out";

  doDist = false;
}
  1. run:
[nobody@localhost:~]$ nix shell .#olaris-react`
building
yarn config v1.22.19
success Set "yarn-offline-mirror" to "/nix/store/cygh22xi5nlsy6vh3ymcim2pqd9zkvkp-offline".
Done in 0.03s.
yarn install v1.22.19
[1/4] Resolving packages...
error Couldn't find any versions for "url-parse" that matches "1.5.9" in our cache (possible versions are ""). This is usually caused by a missing entry in the lockfile, running Yarn without the --offline flag m>
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

Additional context

I have manually confirmed that this is not just an issue with mkYarnPackage it reproduces with a minimal stdenv too. I have also regenerating the yarn.lock file using rm yarn.lock && yarn install only makes things worse:

[nobody@localhost:~]$ nix shell .#olaris-react`
building
yarn config v1.22.19
success Set "yarn-offline-mirror" to "/nix/store/jlp5wfbiij2kikfpismb2b5gbdm0cfq7-offline".
Done in 0.03s.
yarn install v1.22.19
[1/4] Resolving packages...
error Couldn't find any versions for "@apollo/react-hooks" that matches "^3.1.1" in our cache (possible versions are ""). This is usually ca>
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
Error: Couldn't find any versions for "@fortawesome/fontawesome-svg-core" that matches "^1.2.25" in our cache (possible versions are ""). Th>
    at MessageError.ExtendableBuiltin (/nix/store/zdcnqq55qi214j46zgw2qa1jp4dpdf2m-yarn-1.22.19/libexec/yarn/lib/cli.js:721:66)
    at new MessageError (/nix/store/zdcnqq55qi214j46zgw2qa1jp4dpdf2m-yarn-1.22.19/libexec/yarn/lib/cli.js:750:123)
    at NpmResolver.<anonymous> (/nix/store/zdcnqq55qi214j46zgw2qa1jp4dpdf2m-yarn-1.22.19/libexec/yarn/lib/cli.js:50438:15)
    at Generator.next (<anonymous>)
    at step (/nix/store/zdcnqq55qi214j46zgw2qa1jp4dpdf2m-yarn-1.22.19/libexec/yarn/lib/cli.js:310:30)
    at /nix/store/zdcnqq55qi214j46zgw2qa1jp4dpdf2m-yarn-1.22.19/libexec/yarn/lib/cli.js:321:13
Error: Couldn't find any versions for "@fortawesome/free-regular-svg-icons" that matches "^5.11.2" in our cache (possible versions are ""). >
    at MessageError.ExtendableBuiltin (/nix/store/zdcnqq55qi214j46zgw2qa1jp4dpdf2m-yarn-1.22.19/libexec/yarn/lib/cli.js:721:66)
    at new MessageError (/nix/store/zdcnqq55qi214j46zgw2qa1jp4dpdf2m-yarn-1.22.19/libexec/yarn/lib/cli.js:750:123)
    at NpmResolver.<anonymous> (/nix/store/zdcnqq55qi214j46zgw2qa1jp4dpdf2m-yarn-1.22.19/libexec/yarn/lib/cli.js:50438:15)
    at Generator.next (<anonymous>)
    at step (/nix/store/zdcnqq55qi214j46zgw2qa1jp4dpdf2m-yarn-1.22.19/libexec/yarn/lib/cli.js:310:30)
    at /nix/store/zdcnqq55qi214j46zgw2qa1jp4dpdf2m-yarn-1.22.19/libexec/yarn/lib/cli.js:321:13
Error: Couldn't find any versions for "@fortawesome/free-solid-svg-icons" that matches "^5.11.2" in our cache (possible versions are ""). Th>
    at MessageError.ExtendableBuiltin (/nix/store/zdcnqq55qi214j46zgw2qa1jp4dpdf2m-yarn-1.22.19/libexec/yarn/lib/cli.js:721:66)
    at new MessageError (/nix/store/zdcnqq55qi214j46zgw2qa1jp4dpdf2m-yarn-1.22.19/libexec/yarn/lib/cli.js:750:123)
    at NpmResolver.<anonymous> (/nix/store/zdcnqq55qi214j46zgw2qa1jp4dpdf2m-yarn-1.22.19/libexec/yarn/lib/cli.js:50438:15)
    at Generator.next (<anonymous>)
    at step (/nix/store/zdcnqq55qi214j46zgw2qa1jp4dpdf2m-yarn-1.22.19/libexec/yarn/lib/cli.js:310:30)
    at /nix/store/zdcnqq55qi214j46zgw2qa1jp4dpdf2m-yarn-1.22.19/libexec/yarn/lib/cli.js:321:13
Error: Couldn't find any versions for "@fortawesome/react-fontawesome" that matches "^0.1.3" in our cache (possible versions are ""). This i>
    at MessageError.ExtendableBuiltin (/nix/store/zdcnqq55qi214j46zgw2qa1jp4dpdf2m-yarn-1.22.19/libexec/yarn/lib/cli.js:721:66)
    at new MessageError (/nix/store/zdcnqq55qi214j46zgw2qa1jp4dpdf2m-yarn-1.22.19/libexec/yarn/lib/cli.js:750:123)
    at NpmResolver.<anonymous> (/nix/store/zdcnqq55qi214j46zgw2qa1jp4dpdf2m-yarn-1.22.19/libexec/yarn/lib/cli.js:50438:15)
    at Generator.next (<anonymous>)
    at step (/nix/store/zdcnqq55qi214j46zgw2qa1jp4dpdf2m-yarn-1.22.19/libexec/yarn/lib/cli.js:310:30)
    at /nix/store/zdcnqq55qi214j46zgw2qa1jp4dpdf2m-yarn-1.22.19/libexec/yarn/lib/cli.js:321:13
Error: Couldn't find any versions for "apollo-cache-inmemory" that matches "^1.2.4" in our cache (possible versions are ""). This is usually>
    at MessageError.ExtendableBuiltin (/nix/store/zdcnqq55qi214j46zgw2qa1jp4dpdf2m-yarn-1.22.19/libexec/yarn/lib/cli.js:721:66)
    at new MessageError (/nix/store/zdcnqq55qi214j46zgw2qa1jp4dpdf2m-yarn-1.22.19/libexec/yarn/lib/cli.js:750:123)
    at NpmResolver.<anonymous> (/nix/store/zdcnqq55qi214j46zgw2qa1jp4dpdf2m-yarn-1.22.19/libexec/yarn/lib/cli.js:50438:15)
    at Generator.next (<anonymous>)
    at step (/nix/store/zdcnqq55qi214j46zgw2qa1jp4dpdf2m-yarn-1.22.19/libexec/yarn/lib/cli.js:310:30)
    at /nix/store/zdcnqq55qi214j46zgw2qa1jp4dpdf2m-yarn-1.22.19/libexec/yarn/lib/cli.js:321:13
Error: Couldn't find any versions for "apollo-client" that matches "^2.5.1" in our cache (possible versions are ""). This is usually caused >
    at MessageError.ExtendableBuiltin (/nix/store/zdcnqq55qi214j46zgw2qa1jp4dpdf2m-yarn-1.22.19/libexec/yarn/lib/cli.js:721:66)
    at new MessageError (/nix/store/zdcnqq55qi214j46zgw2qa1jp4dpdf2m-yarn-1.22.19/libexec/yarn/lib/cli.js:750:123)
    at NpmResolver.<anonymous> (/nix/store/zdcnqq55qi214j46zgw2qa1jp4dpdf2m-yarn-1.22.19/libexec/yarn/lib/cli.js:50438:15)
    at Generator.next (<anonymous>)
    at step (/nix/store/zdcnqq55qi214j46zgw2qa1jp4dpdf2m-yarn-1.22.19/libexec/yarn/lib/cli.js:310:30)
    at /nix/store/zdcnqq55qi214j46zgw2qa1jp4dpdf2m-yarn-1.22.19/libexec/yarn/lib/cli.js:321:13
Error: Couldn't find any versions for "apollo-link" that matches "^1.2.11" in our cache (possible versions are ""). This is usually caused b>
    at MessageError.ExtendableBuiltin (/nix/store/zdcnqq55qi214j46zgw2qa1jp4dpdf2m-yarn-1.22.19/libexec/yarn/lib/cli.js:721:66)
    at new MessageError (/nix/store/zdcnqq55qi214j46zgw2qa1jp4dpdf2m-yarn-1.22.19/libexec/yarn/lib/cli.js:750:123)
    at NpmResolver.<anonymous> (/nix/store/zdcnqq55qi214j46zgw2qa1jp4dpdf2m-yarn-1.22.19/libexec/yarn/lib/cli.js:50438:15)
    at Generator.next (<anonymous>)
    at step (/nix/store/zdcnqq55qi214j46zgw2qa1jp4dpdf2m-yarn-1.22.19/libexec/yarn/lib/cli.js:310:30)
    at /nix/store/zdcnqq55qi214j46zgw2qa1jp4dpdf2m-yarn-1.22.19/libexec/yarn/lib/cli.js:321:13
Error: Couldn't find any versions for "apollo-link-error" that matches "^1.1.12" in our cache (possible versions are ""). This is usually ca>
    at MessageError.ExtendableBuiltin (/nix/store/zdcnqq55qi214j46zgw2qa1jp4dpdf2m-yarn-1.22.19/libexec/yarn/lib/cli.js:721:66)
    at new MessageError (/nix/store/zdcnqq55qi214j46zgw2qa1jp4dpdf2m-yarn-1.22.19/libexec/yarn/lib/cli.js:750:123)
    at NpmResolver.<anonymous> (/nix/store/zdcnqq55qi214j46zgw2qa1jp4dpdf2m-yarn-1.22.19/libexec/yarn/lib/cli.js:50438:15)
    at Generator.next (<anonymous>)
    at step (/nix/store/zdcnqq55qi214j46zgw2qa1jp4dpdf2m-yarn-1.22.19/libexec/yarn/lib/cli.js:310:30)
    at /nix/store/zdcnqq55qi214j46zgw2qa1jp4dpdf2m-yarn-1.22.19/libexec/yarn/lib/cli.js:321:13
Error: Couldn't find any versions for "apollo-link-http" that matches "^1.5.4" in our cache (possible versions are ""). This is usually caus>
    at MessageError.ExtendableBuiltin (/nix/store/zdcnqq55qi214j46zgw2qa1jp4dpdf2m-yarn-1.22.19/libexec/yarn/lib/cli.js:721:66)
    at new MessageError (/nix/store/zdcnqq55qi214j46zgw2qa1jp4dpdf2m-yarn-1.22.19/libexec/yarn/lib/cli.js:750:123)
    at NpmResolver.<anonymous> (/nix/store/zdcnqq55qi214j46zgw2qa1jp4dpdf2m-yarn-1.22.19/libexec/yarn/lib/cli.js:50438:15)
    at Generator.next (<anonymous>)
    at step (/nix/store/zdcnqq55qi214j46zgw2qa1jp4dpdf2m-yarn-1.22.19/libexec/yarn/lib/cli.js:310:30)
    at /nix/store/zdcnqq55qi214j46zgw2qa1jp4dpdf2m-yarn-1.22.19/libexec/yarn/lib/cli.js:321:13
Error: Couldn't find any versions for "graphql" that matches "^14.5.8" in our cache (possible versions are ""). This is usually caused by a >
    at MessageError.ExtendableBuiltin (/nix/store/zdcnqq55qi214j46zgw2qa1jp4dpdf2m-yarn-1.22.19/libexec/yarn/lib/cli.js:721:66)
    at new MessageError (/nix/store/zdcnqq55qi214j46zgw2qa1jp4dpdf2m-yarn-1.22.19/libexec/yarn/lib/cli.js:750:123)
    at NpmResolver.<anonymous> (/nix/store/zdcnqq55qi214j46zgw2qa1jp4dpdf2m-yarn-1.22.19/libexec/yarn/lib/cli.js:50438:15)
    at Generator.next (<anonymous>)
    at step (/nix/store/zdcnqq55qi214j46zgw2qa1jp4dpdf2m-yarn-1.22.19/libexec/yarn/lib/cli.js:310:30)
    at /nix/store/zdcnqq55qi214j46zgw2qa1jp4dpdf2m-yarn-1.22.19/libexec/yarn/lib/cli.js:321:13
Error: Couldn't find any versions for "graphql-tag" that matches "^2.9.2" in our cache (possible versions are ""). This is usually caused by>
    at MessageError.ExtendableBuiltin (/nix/store/zdcnqq55qi214j46zgw2qa1jp4dpdf2m-yarn-1.22.19/libexec/yarn/lib/cli.js:721:66)
    at new MessageError (/nix/store/zdcnqq55qi214j46zgw2qa1jp4dpdf2m-yarn-1.22.19/libexec/yarn/lib/cli.js:750:123)
    at NpmResolver.<anonymous> (/nix/store/zdcnqq55qi214j46zgw2qa1jp4dpdf2m-yarn-1.22.19/libexec/yarn/lib/cli.js:50438:15)
    at Generator.next (<anonymous>)
    at step (/nix/store/zdcnqq55qi214j46zgw2qa1jp4dpdf2m-yarn-1.22.19/libexec/yarn/lib/cli.js:310:30)
    at /nix/store/zdcnqq55qi214j46zgw2qa1jp4dpdf2m-yarn-1.22.19/libexec/yarn/lib/cli.js:321:13
Error: Couldn't find any versions for "react-apollo" that matches "^3.1.1" in our cache (possible versions are ""). This is usually caused b>
    at MessageError.ExtendableBuiltin (/nix/store/zdcnqq55qi214j46zgw2qa1jp4dpdf2m-yarn-1.22.19/libexec/yarn/lib/cli.js:721:66)
    at new MessageError (/nix/store/zdcnqq55qi214j46zgw2qa1jp4dpdf2m-yarn-1.22.19/libexec/yarn/lib/cli.js:750:123)
    at NpmResolver.<anonymous> (/nix/store/zdcnqq55qi214j46zgw2qa1jp4dpdf2m-yarn-1.22.19/libexec/yarn/lib/cli.js:50438:15)
    at Generator.next (<anonymous>)
    at step (/nix/store/zdcnqq55qi214j46zgw2qa1jp4dpdf2m-yarn-1.22.19/libexec/yarn/lib/cli.js:310:30)
    at /nix/store/zdcnqq55qi214j46zgw2qa1jp4dpdf2m-yarn-1.22.19/libexec/yarn/lib/cli.js:321:13
Error: Couldn't find any versions for "react-autosuggest" that matches "^9.3.4" in our cache (possible versions are ""). This is usually cau>
    at MessageError.ExtendableBuiltin (/nix/store/zdcnqq55qi214j46zgw2qa1jp4dpdf2m-yarn-1.22.19/libexec/yarn/lib/cli.js:721:66)
    at new MessageError (/nix/store/zdcnqq55qi214j46zgw2qa1jp4dpdf2m-yarn-1.22.19/libexec/yarn/lib/cli.js:750:123)
    at NpmResolver.<anonymous> (/nix/store/zdcnqq55qi214j46zgw2qa1jp4dpdf2m-yarn-1.22.19/libexec/yarn/lib/cli.js:50438:15)
    at Generator.next (<anonymous>)
    at step (/nix/store/zdcnqq55qi214j46zgw2qa1jp4dpdf2m-yarn-1.22.19/libexec/yarn/lib/cli.js:310:30)
    at /nix/store/zdcnqq55qi214j46zgw2qa1jp4dpdf2m-yarn-1.22.19/libexec/yarn/lib/cli.js:321:13

Notify maintainers

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"
 - system: `"x86_64-linux"`
 - host os: `Linux 5.15.79, NixOS, 23.05 (Stoat), 23.05.20221124.27ccd29`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.11.0`
 - channels(root): `""`
 - channels(Colin Arnott): `"nixos-22.05-22.05"`
 - channels(colin): `""`
 - nixpkgs: `/nix/store/dd636dqmf0s78wnv83rssk6qbj6jan1f-source`
@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/mkyarnpackage-lockfile-has-incorrect-entry/21586/5

@GuillaumeDesforges
Copy link
Contributor

I had the same issue for Marp. I think I found the root cause in my case. mkYarnPackage moves the original package.json to a path like deps/yourproject/package.json and creates a workspace package.json, but it does not copy the resolutions field from the original one. However, only the resolutions field in the root package.json is used. So it is indeed looking for packages in the local cache index which are not there.

@winterqt
Copy link
Member

winterqt commented Feb 9, 2023

I know @urandom2 said this occurs in a minimal stdenv as well, but it shouldn't. Do you have logs for that case?

For a quick setup of that, you can use #210814.

@urandom2
Copy link
Contributor Author

urandom2 commented Feb 10, 2023

I do not have the derivation lying around anymore, but the build output was identical; it would have looked something like the example from the discourse thread:

{ lib, stdenv, fixup_yarn_lock, callPackage, yarn, nodejs-slim }:

stdenv.mkDerivation {
  pname = "foo";
  version = "1.0.0";

  src = lib.cleanSource ./.;

  yarnOfflineCache = (callPackage ./yarn.nix {}).offline_cache;
  # or fetchYarnDeps

  nativeBuildInputs = [
    fixup_yarn_lock yarn nodejs-slim
  ];

  configurePhase = ''
    export HOME=$NIX_BUILD_TOP
    yarn config --offline set yarn-offline-mirror $yarnOfflineCache
    fixup_yarn_lock yarn.lock
    yarn install --offline --frozen-lockfile --ignore-scripts --no-progress --non-interactive
    patchShebangs node_modules/
  '';

  buildPhase = ''
    ...
  '';

  installPhase = ''
    ...
    # if the node_modules dir is needed at runtime, move it to $out/libexec here
  '';
}

EDIT: @winterqt, can you clarify how I would use #210814?

@GuillaumeDesforges
Copy link
Contributor

Should be fixed since this PR merge
#214952

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

No branches or pull requests

6 participants