# Yarn install hangs and never completes

**URL:** <https://discuss.circleci.com/t/yarn-install-hangs-and-never-completes/7664>\
**Category:** Build Environment\
**Tags:** circle-yml\
**Created:** [October 26, 2016, 4:51am UTC](https://discuss.circleci.com/t/yarn-install-hangs-and-never-completes/7664 "2016-10-26T04:51:17Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![CJBridges](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/cjbridges/32/8740_2.png) [@CJBridges](https://discuss.circleci.com/u/CJBridges)\
**Post date:** [October 26, 2016, 4:51am UTC](https://discuss.circleci.com/t/yarn-install-hangs-and-never-completes/7664/1 "2016-10-26T04:51:17Z")

</div>

Build (skipped the middle since it was boring)

 ![](https://global.discourse-cdn.com/circleci/original/3X/8/8/88bbec5d249c3cff6626b5c4ad176b2287ba7c76.png)  
(…)  
 ![](https://global.discourse-cdn.com/circleci/original/3X/1/2/126495f322df954ad018a41b17bde3e2ff0e44fd.png)

The build hangs at this point and eventually circle times out (no output for 10 minutes) and kills the build.

Circle.yml file (relevant portions):  
`machine: pre: - mkdir -p ~/.yarn-cache environment: RAILS_ENV: test RACK_ENV: test NODE_ENV: test dependencies: override: - nvm install v4.4.6 # default version in image of 0.x.y can't run yarn - nvm alias default v4.4.6 - sudo apt-key adv --keyserver pgp.mit.edu --recv D101F7899D41F3C3 - echo "deb http://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list - sudo apt-get update -qq - sudo apt-get install -y -qq yarn - mkdir -p node_modules && rm -r node_modules/ - yarn install --pure-lockfile # this is the step that hangs cache_directories: - "~/.yarn-cache"`

**Tightest reproducible case**

- The tightest reproducible case I could come up with was:

1. SSH into the node
2. `/bin/dash` since that’s the shell used by Circle to run commands apparently. (Note: no errors seen when using bash shell, which is the default upon ssh’ing in)
3. `yarn install --pure-lockfile`

Expectd: `yarn install` succeeds  
Actual: `yarn install` fails as above.

**Some approaches attempted (none succeeded):**

1. Change the line in circle.yml to push it toward bash ( `- /bin/bash -c "yarn install --pure-lockfile"`)
2. Redirect all output to /dev/null (`- yarn install --pure-lockfile >/dev/null 2>/dev/null`)
3. Turn off emoji (`yarn install --no-emoji --pure-lockfile`)

My very ugly hack to bring this temporarily operational was:

1. Set the install command to `- sleep 150 && yarn install`
2. SSH into the node during build, stay in bash shell
3. Wait until the sleep is entered, run `yarn install` to completion

Cache is now seeded and future builds run without errors. Rebuilding without cache re-introduces the failure.

Any other suggestions on why dash/yarn would not be playing nice together? Nothing obvious appeared when looking through the yarnpkg issues on github.

---

<div class="post-metadata">

**Author:** ![drazisil](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/drazisil/32/24029_2.png) [@drazisil](https://discuss.circleci.com/u/drazisil)\
**Post date:** [October 27, 2016, 6:23am UTC](https://discuss.circleci.com/t/yarn-install-hangs-and-never-completes/7664/2 "2016-10-27T06:23:36Z")

</div>

[https://discuss.circleci.com/t/preinstall-yarn/7353/4](https://discuss.circleci.com/t/preinstall-yarn/7353/4)

The instructions here work, have you given them a try?

---

<div class="post-metadata">

**Author:** ![CJBridges](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/cjbridges/32/8740_2.png) [@CJBridges](https://discuss.circleci.com/u/CJBridges)\
**Post date:** [October 27, 2016, 6:47pm UTC](https://discuss.circleci.com/t/yarn-install-hangs-and-never-completes/7664/3 "2016-10-27T18:47:28Z")

</div>

1. I’ve tried a lot of different approaches, including installing yarn via npm as suggested in your linked post. Yarn itself installs fine, just the follow-on yarn install of my project fails.
2. After a lot of further investigation, it looks closely related to these two issues from yarnpkg:  
[https://github.com/yarnpkg/yarn/issues/1144](https://github.com/yarnpkg/yarn/issues/1144)  
[https://github.com/yarnpkg/yarn/issues/764](https://github.com/yarnpkg/yarn/issues/764)

I’ve included more detail there and will continue to work with the yarn team on resolution.

---

<div class="post-metadata">

**Author:** ![CJBridges](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/cjbridges/32/8740_2.png) [@CJBridges](https://discuss.circleci.com/u/CJBridges)\
**Post date:** [October 31, 2016, 6:37pm UTC](https://discuss.circleci.com/t/yarn-install-hangs-and-never-completes/7664/4 "2016-10-31T18:37:26Z")

</div>

A workaround for this (far from ideal, but our org can use this workaround) is to upgrade node to version 6.9.1 (the latest LTS release).

Please see the github issues linked for more details. Still pending triage/resolution by the yarn team.

---

<div class="post-metadata">

**Author:** ![drazisil](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/drazisil/32/24029_2.png) [@drazisil](https://discuss.circleci.com/u/drazisil)\
**Post date:** [August 3, 2017, 12:53pm UTC](https://discuss.circleci.com/t/yarn-install-hangs-and-never-completes/7664/5 "2017-08-03T12:53:04Z")

</div>

Closed on August 3, 2017, 12:53pm UTC


