Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does `yarn install` hang when fetching packages on CentOS?

When attempting to install the dependencies for my project with Yarn via yarn install, the process (and progress bar indicator) hangs when attempting to fetch packages. A timeout never occurs and the --verbose option gives no useful clues regarding the cause of the problem.

CentOS 7

Yarn version: 0.27.5

like image 583
user3006381 Avatar asked Oct 18 '22 09:10

user3006381


1 Answers

This issue is caused by the combination of the older version of Git installed by Yum on CentOS (1.8.3.1-6 at the time of this writing) and Git's two-factor authentication mechanism.

Git's 2FA is the reason the hanging occurs in the first place, since one of the packages Yarn was attempting to fetch was a private repo via HTTPS (see here for details).

The version of the Git client in CentOS turned out to be the reason the hanging continued to occur and never timed / erred out. That is, the aforementioned version of Git on CentOS prevented Yarn from recognizing the authentication error and exiting accordingly.

The solution is to upgrade Git to a more recent version using a different repo:

sudo yum -y erase git
sudo rpm -U http://opensource.wandisco.com/centos/7/git/x86_64/wandisco-git-release-7-2.noarch.rpm
sudo yum -y install git

This will stop Yarn from continuing to hang, with an output similar to the following:

[1/4] Resolving packages...
[2/4] Fetching packages...
error Command failed.
Exit code: 128
Command: git
...
fatal: could not read Username for 'https://github.com': terminal prompts disabled
like image 89
user3006381 Avatar answered Oct 21 '22 04:10

user3006381