yarnpkg / yarn

The 1.x line is frozen - features and bugfixes now happen on https://github.com/yarnpkg/berry
https://classic.yarnpkg.com
Other
41.4k stars 2.73k forks source link

yarn install hangs during "Fetching packages..." #764

Closed indieisaconcept closed 7 years ago

indieisaconcept commented 7 years ago

Do you want to request a feature or report a bug?

Bug

What is the current behavior?

yarn install hangs at fetching packages and does not provide any further information as to the cause.

If the current behavior is a bug, please provide the steps to reproduce.

With the following package.json run the below

> yarn cache clean & yarn install

What is the expected behavior?

Installation should succeed.

Please mention your node.js, yarn and operating system version.

robclancy commented 7 years ago

So our issues with this went away for us locally but I have still been using NPM in CI because of this happening sometimes. With the last comments about ssh I decided to check and change any with https. They were just public github repositories so never needed ssh but I thought if ssh changes could solve this maybe it was an issue with ssl. And changing those packages to both a version and one using the github definitions instead of a https url and first run hasn't hung.

On Fri, Mar 3, 2017 at 4:30 AM DouG Molidor notifications@github.com wrote:

@jdelStrother https://github.com/jdelStrother that was it! I had a private package reference and ssh-add -K && yarn install is the command that got it to work. Thank you and my appreciation, sir!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/yarnpkg/yarn/issues/764#issuecomment-283737992, or mute the thread https://github.com/notifications/unsubscribe-auth/AA0UF5PKUy1Lx5nlGZF9HMoSIPhEG8-Tks5rhwrOgaJpZM4KUM4j .

moneytree-doug commented 7 years ago

Same here for CircleCI with Ubuntu 14.04 (Trusty) and node v6.9.1.

kirs commented 7 years ago

I fixed the issue in https://github.com/yarnpkg/yarn/pull/2950. There's been a missing timeout.

I'm surprised how much time was wasted on discussions when it was literally a one line fix, counting that I'm not from Javascript background.

herrherrmann commented 7 years ago

Had the issue while using Node 5.12.0 only. Switching to version 6.9.1 of Node (via nvm) fixed the issue for me.

kirs commented 7 years ago

It shouldn't be affected by the Node version because the cause of the issue is the timeout that is not specified. #2950 adds the timeout.

knoguchi commented 7 years ago

So when timeout happens, does yarn retry and fetch from other servers? Is that why timeout is considered the fix for the hangs?

kirs commented 7 years ago

Yarn retries any requests that failed due network error. This PR makes Yarn to consider the timeout error as a network error. There are no "other servers" but you may get more lucky on next retry if it was a connectivity error between where your app is hosted (EC2) and the CDN in front of registry.yarkpkg.com

tetherit commented 7 years ago

apt-get update is freezing forever when I have 'deb https://dl.yarnpkg.com/debian/ stable main' in my sources.list :( - any solution?

stereobooster commented 7 years ago

Still have this problem with yarn v0.23.2and nodejs 6.1.0. Upgrade to nodejs 6.7.0 solved the problem.

modusss commented 7 years ago

I have this issue too with: yarn v.0.23.2 nodejs v.7.9.0

and after trying this command: yarn add semantic-ui

I waited more then two hours and it didn't finish to install

bestander commented 7 years ago

Looks like most cases are fixed with a Node update. Another way to help debug this is running with --verbose flag, to see what request is hanging. Otherwise not sure we can do anything here

kirs commented 7 years ago

You can also use strace to see what exactly it hanging.

jeffshek commented 7 years ago

Same issue, had nvm and would switch node versions to find one that works.

Went from 4.4.6 and 5.12 (no success). node 6.7.0 works, but it's harder to convince team that yarn is a drop-in replacement if we have to switch node versions.

kirs commented 7 years ago

@jeffshek can you try to strace stuck yarn on node 4.4.6 or 5.12? That could potentially help us to find the issue.

jeffshek commented 7 years ago

So after I switched over to node 6.7, I was able to install, etc.

To try to recreate this issue, I wiped out the yarn.lock, removed all node_modules and switched to node 4.4.6.

I was getting

yarn install

[2/4] 🚚  Fetching packages...
error xmlbuilder@9.0.0: The engine "node" is incompatible with this module. Expected version ">=6.0".
error Found incompatible module

So okay, that looks like some type of diagnosable message ... (Was this error message just hiding the entire time?)

But now when I run yarn install, it just magically ... works (node 4.4.6). So now even on node 4.4.6, I'm able to yarn install just fine with the same package.json that wouldn't work a few hours ago. I've removed yarn.lock, done a fresh yarn install, and it continues to work.

I really wish I could be more more help, but using nvm to switch to version 6.7 and then back to 4.4.6 made the previous issue disappear.

matthew-dean commented 7 years ago

I'm new to yarn. Tried it for the first time. Ran yarn install. Result: hanging indefinitely during install of packages. (Specifically, the jsesc package, but not sure that matters.)

Turns out, yarn also botched my NPM commands? o_O "npm clean" now no longer works after a simple brew install yarn and yarn install. That's all I did in a project folder, and my GLOBAL Node modules are now borked.

Yarn version is 0.24.6 Node.js version is 7.10.0

Since installing Yarn, Node looks completely broken.

Update: I finally got Node / NPM working again, but Yarn still hangs.

matthew-dean commented 7 years ago

For me, it hangs here indefinitely: screen shot 2017-05-26 at 6 21 03 pm

andrsnn commented 7 years ago

This appears to still be a persistent issue. I'm able to reproduce with:

yarn@v0.19.4 yarn@v0.21.3 osx@10.10.4 osx@10.10.5 amazon linux@2017.03 node@v5.12.0 node@v4.4.6

appears to be successful for node@>=6.9.5

As far as I can tell, the issue seems to be related to git repo dependencies due to a race condition when extracting the tar produced from git archive .

I made a repo that exhibits the behavior. https://github.com/andrsnn/yarn-git-dependency-issue

So far I've tracked the issue down this this bit of code located in ~/.yarn/lib-legacy/util/git.js

_cloneViaLocalFetched(dest) {
    var _this4 = this;

    return (0, (_asyncToGenerator2 || _load_asyncToGenerator()).default)(function* () {
      yield (_child || _load_child()).spawn('git', ['archive', _this4.hash], {
        cwd: _this4.cwd,
        process: function process(proc, resolve, reject, done) {
          const extractor = tar.Extract({ path: dest });
          extractor.on('error', reject);
          extractor.on('end', done);

          proc.stdout.pipe(extractor);
        }
      });
    })();
}

At this step, the dependency repository appears to have been successfully cloned down into a tmp folder /Users/andrsnn/Library/Caches/Yarn/.tmp/06cc8c2b5aba0eca42bd03dabc0d87f6 , extracting to a destination at /Users/andrsnn/Library/Caches/Yarn/npm-yarn-dependency-a-1.0.2-fc796525f8a9e3130248520d386f9823502eb6cd . Does not appear to be a network problem.

Occasionally the 'end' event is never fired from the node-tar module. It appears to hang on a 'data' emit, which contains a trucated chunk of the yarn.lock file from the git dependency.

████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████░ 176/177{ '0': 'data',
  '1': <Buffer 30 2e 34 3a 0a 20 20 76 65 72 73 69 6f 6e 20 22 34 2e 30 2e 36 22 0a 20 20 72 65 73 6f 6c 76 65 64 20 22 68 74 74 70 73 3a 2f 2f 72 65 67 69 73 74 72 ... > }
0.4:
  version "4.0.6"
  resolved "https://registry.yarnpkg.com/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz#7c526a52d89b45c45cc690b88163be0497f550cb"

lodash.isstring@^4.0.1:
  version "4.0.1"
  resolved "https://registry.yarnpkg.com/lodash.isstring/-/lodash.isstring-4.0.1.tgz#d527dfb5456eca7cc9bb95d5daeaf88ba54a5451"

lodash.keys@^3.0.0:
  version "3.1.2"
  resolved "https://registry.yarnpkg.com/lodash.keys/-/lodash.keys-3.1.2.tgz#4dbc0472b156be50a0b286855d1bd0b0c656098a"
  dependencies:
    loda

To determine the above I wrapped the event emitter:

_cloneViaLocalFetched(dest) {
    var _this4 = this;

    return (0, (_asyncToGenerator2 || _load_asyncToGenerator()).default)(function* () {
      yield (_child || _load_child()).spawn('git', ['archive', _this4.hash], {
        cwd: _this4.cwd,
        process: function process(proc, resolve, reject, done) {
          const extractor = tar.Extract({ path: dest });

          var timeout;
          function log(args) {
            return function() {
              console.log(require('util').inspect(args));
              console.log(args[1].toString());
            };
          }
          function debug(emitter) {
              var originalEmitter = emitter.emit;

              emitter.emit = function() {
                  console.log('eventName', arguments[0]);
                  clearTimeout(timeout);
                  timeout = setTimeout(log(arguments), 20000);
                  originalEmitter.apply(emitter, arguments);
              };
          }

          debug(extractor);
          extractor.on('error', reject);
          extractor.on('end', done);

          proc.stdout.pipe(extractor);
        }
      });
    })();
}

This very well could be a bug in node-tar or a dependency it relies on.

Hopefully others can shed some light on the fix. Been having a difficult time with this bug, causing issues on CI servers and in local development.

bestander commented 7 years ago

Thanks a lot for the repro stapes and analysis. We had an issue of a tar to be download twice and that caused and exception during untarring.

The core team will focus on stability all through next week before releasing 0.26

On 28 May 2017 at 22:44, andrsnn notifications@github.com wrote:

This appears to still be a persistent issue. I'm able to reproduce with:

yarn@v0.19.4 yarn@v0.21.3 osx@10.10.4 osx@10.10.5 amazon linux@2017.03 node@v5.12.0 node@v4.4.6

appears to be successful for node@>=6.9.5

As far as I can tell, the issue seems to be related to git repo dependencies due to a race condition when extracting the tar produced from git archive .

I made a repo that exhibits the behavior. https://github.com/andrsnn/yarn-git-dependency-issue

So far I've tracked the issue down this this bit of code located in ~/.yarn/lib-legacy/util/git.js

_cloneViaLocalFetched(dest) { var _this4 = this;

return (0, (_asyncToGenerator2 || _load_asyncToGenerator()).default)(function* () {
  yield (_child || _load_child()).spawn('git', ['archive', _this4.hash], {
    cwd: _this4.cwd,
    process: function process(proc, resolve, reject, done) {
      const extractor = tar.Extract({ path: dest });
      extractor.on('error', reject);
      extractor.on('end', done);

      proc.stdout.pipe(extractor);
    }
  });
})();

}

Occasionally the 'end' event is never fired from the node-tar module. It appears to hang on a 'data' emit, which contains a trucated chunk of the yarn.lock file from the git dependency.

████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████░ 176/177{ '0': 'data', '1': <Buffer 30 2e 34 3a 0a 20 20 76 65 72 73 69 6f 6e 20 22 34 2e 30 2e 36 22 0a 20 20 72 65 73 6f 6c 76 65 64 20 22 68 74 74 70 73 3a 2f 2f 72 65 67 69 73 74 72 ... > } 0.4: version "4.0.6" resolved "https://registry.yarnpkg.com/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz#7c526a52d89b45c45cc690b88163be0497f550cb"

lodash.isstring@^4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/lodash.isstring/-/lodash.isstring-4.0.1.tgz#d527dfb5456eca7cc9bb95d5daeaf88ba54a5451"

lodash.keys@^3.0.0: version "3.1.2" resolved "https://registry.yarnpkg.com/lodash.keys/-/lodash.keys-3.1.2.tgz#4dbc0472b156be50a0b286855d1bd0b0c656098a" dependencies: loda

To determine the above I wrapped the event emitter:

_cloneViaLocalFetched(dest) { var _this4 = this;

return (0, (_asyncToGenerator2 || _load_asyncToGenerator()).default)(function* () {
  yield (_child || _load_child()).spawn('git', ['archive', _this4.hash], {
    cwd: _this4.cwd,
    process: function process(proc, resolve, reject, done) {
      const extractor = tar.Extract({ path: dest });

      var timeout;
      function log(args) {
        return function() {
          console.log(require('util').inspect(args));
          console.log(args[1].toString());
        };
      }
      function debug(emitter) {
          var originalEmitter = emitter.emit;

          emitter.emit = function() {
              console.log('eventName', arguments[0]);
              clearTimeout(timeout);
              timeout = setTimeout(log(arguments), 20000);
              originalEmitter.apply(emitter, arguments);
          };
      }

      debug(extractor);
      extractor.on('error', reject);
      extractor.on('end', done);

      proc.stdout.pipe(extractor);
    }
  });
})();

}

This very well could be a bug in node-tar or a dependency it relies on.

Hopefully others can shed some light on the fix. Been having a difficult time with this bug, causing issues on CI servers and in local development.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/yarnpkg/yarn/issues/764#issuecomment-304542314, or mute the thread https://github.com/notifications/unsubscribe-auth/ACBdWLWEI3Aui9XTLxl7ISk-OaXSQLL0ks5r-eqlgaJpZM4KUM4j .

JulianLeviston commented 7 years ago

Was having this issue for the last few week since updating yarn, and fixed it eventually by bumping the version of node from 6.2.0 to 6.9.0. Hope this helps others.

vass-david commented 7 years ago

Same problem. Got stuck on the last package while "Fetching packages". Not happening in every project, but most of my projects got this issue. I've reinstalled my system yesterday so may be that previous version didn't have this issues or the package that is doing mess was already cached or whatever.

Yarn version: v0.24.6 Node version: tried v8.0.0, v7.10.0, v7.9.0, nothing worked OS: macOS 10.12.5

Yarn installed via brew, node via nvm in order to try more versions of node.

// EDIT ssh-agent prompted for passphrase and yarn swallowed it. When I hit enter, I could see the question once again because "I've entered incorrect passphrase"

BYK commented 7 years ago

@vass-david with your latest edit, are you still having the issue? @andrsnn - I've tried to reproduce the issue with your repo using various combinations of Node 4.8, Node 6.10, Node 7, Node 8 and yarn 0.24, 0.25, master. I couldn't reproduce the issue. can you confirm it is not there anymore?

kirs commented 7 years ago

@vass-david @JulianLeviston can you use strace on the stuck yarn process to find out what exactly is stuck? Here is a great manual how to use it.

vass-david commented 7 years ago

@BYK no, since now I understand what is the issue and that I should simply enter my passphrase for ssh. On the other side it shouldn't swallow this prompt message, so if user is not aware of this, he might never realise that happened. @kirs do you still need this even if now I know what is the issue?

JulianLeviston commented 7 years ago

@kirs Mine's working since I updated yarn.

spointecker commented 6 years ago

Had the same issue. Deleting the node_modules folder completely and rerun yarn worked for me!

wikieswan commented 6 years ago

i try

rm yarn.lock
yarn 

it works for me

webbrandon commented 6 years ago

I had the issue with node 7.10.0 and yarn v0.24.6 in docker but realized the node_modules folder accidentally got push. Removing the node_modules folder and yarn clear cache resolved the issue.

indatawetrust commented 6 years ago

this is happening in large packages. it can be nice if a warning is given on a certain size.

Karl-EdwardFPJeanMehu commented 6 years ago

I had the same issue. I believe it is version conflict with node. My project was using v81.2. I simply switched to the correct version and yarn stoped hanging: nvm use v7.4

Xuhao commented 6 years ago

Still have this problem in v1.9.4, but same as #5055

md8n commented 5 years ago

Had the same problem: OS: OSX 10.14.1 (Mojave) Node: 10.9.0 Yarn: 1.12.3

Looks like it was probably a corrupted yarn.lock file. Doing the following fixed it:

yarn cache clean
rm yarn.lock
rm - r node_modules

yarn
krunalshahcodes commented 5 years ago

Same issue

OS: OSX 10.14.1 (Mojave) Node: 12.3.1 Yarn: 1.16.0

LeonSkrilec commented 5 years ago

I solved it by switching to different network (hotspot). I guess our office network firewall had some restrictions.

skycrazyk commented 5 years ago

Same issue

OS Windows 10

My solve: update motherboard drivers

iqbalhussain931 commented 5 years ago

Had the same problem: OS: Ubuntu 18.04 Node: v8.10.0 Yarn: 1.17.3

I solved it by doing the following: yarn cache clean

than again tried the install command and it works. though it takes few minutes to complete the process so be patient it will work. In my case it took 10 minutes (Depends on the internet speed) to complete the process.

nzawirski commented 4 years ago

Updating yarn did not help. In my case one of the packages was too large and couldn't download before the timeout

Solution is to install using yarn install --network-timeout 100000

or add .yarnrc file to your project and put this inside: network-timeout 500000

ghasemikasra39 commented 4 years ago

same here:

yarn install v1.22.4
warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[###############################################################################################] 1908/1909
System:
    OS: macOS 10.15.3
    CPU: (4) x64 Intel(R) Core(TM) i5-5257U CPU @ 2.70GHz
    Memory: 192.86 MB / 8.00 GB
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 12.13.1 - ~/.nvm/versions/node/v12.13.1/bin/node
    Yarn: 1.22.4 - ~/Documents/youpendo-app-bareworkflow/node_modules/.bin/yarn
    npm: 6.12.1 - ~/.nvm/versions/node/v12.13.1/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.9.3 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1
    Android SDK:
      API Levels: 28, 29
      Build Tools: 28.0.3, 29.0.2
      System Images: android-28 | Google APIs Intel x86 Atom, android-29 | Google APIs Intel x86 Atom
      Android NDK: Not Found
  IDEs:
    Android Studio: 3.6 AI-192.7142.36.36.6392135
    Xcode: 11.3.1/11C504 - /usr/bin/xcodebuild
  Languages:
    Java: 1.8.0_232 - /usr/bin/javac
    Python: 2.7.16 - /usr/bin/python
  npmPackages:
    @react-native-community/cli: ^4.8.0 => 4.9.0
    react: 16.11.0 => 16.11.0
    react-native: 0.62.2 => 0.62.2
  npmGlobalPackages:
    *react-native*: Not Found
ievgennaida commented 4 years ago

Same problem! Why this one is closed?

yarn@1.22.4 Node.js v12.18.2.

Executed for this repo: https://github.com/metabase/metabase

Windows 10

christo8989 commented 3 years ago

Long story short, check your vpn. Is it connected?

A coworker and I were debugging this same issue. It would just stop at a specific package although we weren't sure which package.

Basically, the person had restarted their computer earlier and when they started it back up, they also had to setup a new password for their vpn. So their vpn never automatically reconnected. Since it was an "issue with yarn", I didn't think much about the vpn. But we have a company repo with a few packages and that is where it was hanging. :/

ws7one commented 3 years ago

Weirdy, this worked yarn clean & yarn cache clean & yarn

wojtekwtf commented 3 years ago

My download was getting stuck on the last dependency. None of the answers above helped / gave any clue.

I switched to a mobile hotspot and it worked

boranh commented 3 years ago

My download was getting stuck on the last dependency. None of the answers above helped / gave any clue.

I switched to a mobile hotspot and it worked

Thank You 👌👌