yarn icon indicating copy to clipboard operation
yarn copied to clipboard

yarn 1.3.2 install uws gets stuck (regression)

Open wichert opened this issue 9 years ago • 18 comments

Note: this appears to be a regression. Yarn 1.2.1 works fine, upgrading to 1.3.2 introduces the problem.

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

Bug.

What is the current behavior?

yarn add uws never finishes. npm install uws works fine. This is the tail end of the yarn add --verbose uws output:

verbose 1.309 Removing extraneous file "/Users/wichert/.config/yarn/global/node_modules/send/node_modules/.bin".
[4/4] 📃  Building fresh packages...
[1/1] ⢀ uws
[-/1] ⢀ waiting...
[-/1] ⢀ waiting...
[-/1] ⢀ waiting...
[-/1] ⢀ waiting...

lsof output at that point:

COMMAND   PID    USER   FD     TYPE             DEVICE   SIZE/OFF    NODE NAME
node    29853 wichert  cwd      DIR                1,4        128 6122082 /private/tmp/z
node    29853 wichert  txt      REG                1,4   27769868 4104653 /usr/local/Cellar/node/8.9.1/bin/node
node    29853 wichert  txt      REG                1,4    2338884 4098024 /usr/local/Cellar/icu4c/59.1_1/lib/libicui18n.59.1.dylib
node    29853 wichert  txt      REG                1,4    1498796 4098040 /usr/local/Cellar/icu4c/59.1_1/lib/libicuuc.59.1.dylib
node    29853 wichert  txt      REG                1,4   26296416 4098020 /usr/local/Cellar/icu4c/59.1_1/lib/libicudata.59.1.dylib
node    29853 wichert  txt      REG                1,4     837248  725512 /usr/lib/dyld
node    29853 wichert  txt      REG                1,4 1147691008 3176243 /private/var/db/dyld/dyld_shared_cache_x86_64h
node    29853 wichert    0u     CHR               16,2        0t0    1141 /dev/ttys002
node    29853 wichert    1u     CHR               16,2  0t1148121    1141 /dev/ttys002
node    29853 wichert    2u     CHR               16,2  0t1207039    1141 /dev/ttys002
node    29853 wichert    3     PIPE 0x1b3ffd0570940b27      16384         ->0x1b3ffd0570940a67
node    29853 wichert    4     PIPE 0x1b3ffd0570940a67      16384         ->0x1b3ffd0570940b27
node    29853 wichert    5u  KQUEUE                                       count=0, state=0xa
node    29853 wichert    6     PIPE 0x1b3ffd05709414e7      16384         ->0x1b3ffd0570940827
node    29853 wichert    7     PIPE 0x1b3ffd0570940827      16384         ->0x1b3ffd05709414e7
node    29853 wichert    8     PIPE 0x1b3ffd0570940be7      16384         ->0x1b3ffd0570940527
node    29853 wichert    9     PIPE 0x1b3ffd0570940527      16384         ->0x1b3ffd0570940be7
node    29853 wichert   10u     CHR               16,2  0t1148121    1141 /dev/ttys002
node    29853 wichert   11r     CHR                3,2        0t0     311 /dev/null
node    29853 wichert   12u     CHR               16,2  0t1207039    1141 /dev/ttys002
node    29853 wichert   13u     CHR               16,2        0t0    1141 /dev/ttys002
node    29853 wichert   14u   systm 0x1b3ffd05697ece67        0t0         [ctl com.apple.netsrc id 9 unit 43]
node    29853 wichert   15u    unix 0x1b3ffd056f52a2a7        0t0         ->0x1b3ffd056f52bba7
node    29853 wichert   16u    IPv4 0x1b3ffd0564aa01c7        0t0     TCP 172.16.1.221:56009->104.16.62.173:https (ESTABLISHED)
node    29853 wichert   17u    IPv4 0x1b3ffd0564aa3057        0t0     TCP 172.16.1.221:56010->104.16.62.173:https (ESTABLISHED)
node    29853 wichert   18u    IPv4 0x1b3ffd0564aa2707        0t0     TCP 172.16.1.221:56011->104.16.62.173:https (ESTABLISHED)
node    29853 wichert   19u    IPv4 0x1b3ffd0564a9dc87        0t0     TCP 172.16.1.221:56012->104.16.62.173:https (ESTABLISHED)
node    29853 wichert   20u    IPv4 0x1b3ffd0564a9f877        0t0     TCP 172.16.1.221:56013->104.16.62.173:https (ESTABLISHED)
node    29853 wichert   21u    IPv4 0x1b3ffd0564aa0b17        0t0     TCP 172.16.1.221:56014->104.16.62.173:https (ESTABLISHED)
node    29853 wichert   22u    IPv4 0x1b3ffd0564c41467        0t0     TCP 172.16.1.221:56015->104.16.62.173:https (ESTABLISHED)
node    29853 wichert   23u    IPv4 0x1b3ffd0564c439a7        0t0     TCP 172.16.1.221:56016->104.16.62.173:https (ESTABLISHED)

and there are no child processes for yarn.

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

yarn 1.3.2 node 8.9.1 macOS 10.13.1

wichert avatar Nov 17 '17 10:11 wichert

I'm having the same issue. Is there any work around other than going back to yarn 1.2.1 ?

asgeo1 avatar Nov 22 '17 03:11 asgeo1

This works fine for me (node 8.5.0, yarn 1.3.2, OSX Sierra):

~/Projects/yarn-test 🐒   yarn add uws
yarn add v1.3.2
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 📃  Building fresh packages...
success Saved lockfile.
success Saved 1 new dependency.
└─ [email protected]
✨  Done in 9.53s.

however judging from your output, it is in the process of running the "install" script defined in the uws package, which is: node-gyp rebuild > build_log.txt 2>&1 || exit 0

Since that command is redirecting output to build_log.txt you can see if there is any helpful info in that file.


Alternatively, you could have yarn ignore the scripts and try running the node-gyp build yourself:

yarn add uws --ignore-scripts
cd node_modules/uws
../.bin/node-gyp rebuild

ums is a native module so it uses node-gyp to compile the module's c++ code. There is some info here on requirements on OSX: https://github.com/nodejs/node-gyp#on-mac-os-x

It might just be that XCode agreement needs to be accepted or updated or something.

rally25rs avatar Dec 04 '17 19:12 rally25rs

@rally25rs When yarn gets stuck the install script for uws already completed: there are no longer any running subprocess for yarn.

Trying to build uws manually shows something that may be relevant: ../.bin/node-gyp is not present.

wichert avatar Dec 05 '17 11:12 wichert

Even with node-gyp installed separately I still see the same yarn hang. Running ../.bin/node-gyp rebuild by hand works flawlessly.

wichert avatar Dec 05 '17 11:12 wichert

Hmmm, that's strange. Yarn basically just uses node.js' child_process.spawn command to fire off the process then waits for the close event. There might be something causing that event to never get thrown.

I can't seem to reproduce it myself to better debug, but if you can dig into it, we would appreciate it.

I would start here: https://github.com/yarnpkg/yarn/blob/master/src/util/child.js#L125 and see if that close event is ever called.

rally25rs avatar Dec 05 '17 13:12 rally25rs

I went back to using npm for a while because of this issue.

Today I thought I'd try Yarn 1.3.2 again (after deleting node_modules, package-lock.json), and low and behold it now works for me!

I'm guessing in the interim some package or OSX thing must have updated, fixing the issue.

asgeo1 avatar Dec 07 '17 01:12 asgeo1

@rally25rs I stuck a console.log() at the top of the spawn function, and that was never triggered.

wichert avatar Dec 07 '17 14:12 wichert

More print-style debugging notes:

added log statement in init():

console.log('MUST INIT:: ', flattenedTopLevelPatterns);
            yield _this4.scripts.init(flattenedTopLevelPatterns);
console.log('INIT complete')

results in:

[4/4] 📃  Building fresh packages...
MUST INIT::  [ 'uws@^9.14.0' ]
info This package requires node-gyp, which is not currently installed. Yarn will attempt to automatically install it. If this fails, you can run "yarn global add node-gyp" to manually install it.
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 📃  Building fresh packages...
MUST INIT::  [ 'decompress@^4.2.0',
  'express@^4.16.2',
  'fs-extra@^4.0.2',
  'redux-actions@^2.0.3',
  'socket.io@^2.0.4',
  'node-gyp@^3.6.2' ]
[1/1] ⢀ uws
[1/1] ⡀ uws
[-/1] ⢀ waiting...
[-/1] ⢀ waiting...
[-/1] ⢀ waiting...
[-/1] ⢀ waiting...

suggesting that the build-dependencies are never installed correctly?

Running PREFIX=/usr/local node --inspect /usr/local/Cellar/yarn/1.3.2/libexec/bin/yarn.js add uws and hitting pause in the chrome inspector gives me a weird call stack:

screen shot 2017-12-07 at 15 57 00

with lots of repetitions of that block.

emitInitScript is invoked with type=TickObject , which I suspect is just a hook to update the spinner on the console?

wichert avatar Dec 07 '17 14:12 wichert

Interestingly it turns out removing ~/.config/yarn/global makes the problem go away.

wichert avatar Dec 07 '17 15:12 wichert

Interestingly it turns out removing ~/.config/yarn/global makes the problem go away.

That's weird 😕 I wonder if there was something corrupted from a previous run that was preventing it from working?

Were you adding uws globally or to a project? ~.config/yarn/global would be used for yarn global add uws but I didn't see the global used in your original post, so not sure why that comes into play at all.

rally25rs avatar Dec 07 '17 19:12 rally25rs

I was adding uws locally using a standard yarn install. It came in as an indirect dependency. There was an older version of uws in ~/.config/yarn/global.

wichert avatar Dec 07 '17 19:12 wichert

I tried installing a global uws then installing it again in a project and it still worked fine. I remain perplexed... I'm glad it started working for you!

rally25rs avatar Dec 07 '17 19:12 rally25rs

I have the same problem. First, I had the problem only on my global installation. Trying to install any new global dependency triggers the rebuild of some native dependencies which in returns hangs forever. In my case, it's not uws the culprit.

Now, one of my project is having the same problem.

And indeed, moving ~/.config/yarn/global to another different path did fix the problem. I then tried to inverse, doing:

$ rm -rf ~/.config/yarn/global
$ mv /tmp/old_yarn_global ~/.config/yarn/global

And doing back the yarn install was not experiencing the issue anymore.

Not sure what is causing this, if I happen to reproduce it again, I will let you know.

maoueh avatar Jan 10 '18 21:01 maoueh

Worth noting that I tried this process and was tripped up because it turned out that even using yarn add uws --ignore-scripts the folder never ended up in yarn. I had to call node-gyp from the folder it was originally pulled into, so /opt/nodejs/bin/node-gyp rebuild. This was a global install so perhaps a different thing was occurring

I was installing socket.io globally and after following the no-script, rebuild process I was able to do so, though worth noting that it took significantly longer than I would have expected.

AramZS avatar Jan 25 '18 06:01 AramZS

Hi everyone, just my 2 cents on this issue.

I'm using yarn inside a rails application to precompile all the production assets. There is a rails task to do that, and that task runs a yarn install command before packing everything with webpack.

I could not get my assets precompiled because the install command would just stall there forever waiting for uws to be ready as described above.

I tryed almost everything suggested here and then run a yarn install:

  • I was using node 9.4 with yarn 1.3.2 when I run into this problem
  • Downgraded to lastest node 8 with yarn 1.3.2: same problem
  • Downgraded yarn to 1.2.1 both with node 8 and 9: same problem
  • Remove ~/.config/yarn/global and package.json: same problem
  • Running yarn add uws --ignore-scripts and later do the node-gyp rebuild on the console compiled the package but running yarn install stalled again so it didn't help

I then found this comment on issue #3728

npm install -g node-gyp fixes the issue. It seems that with Node 7, node-gyp was bundled with Node. But with Node 8 it is not...

so I did that, and the yarn install was running again!. In my case, the problem was that node-gyp was not in my path.

Hope it helps someone save a few hours and a broken deploy.

aalbagarcia avatar Jan 31 '18 06:01 aalbagarcia

The solution @aalbagarcia posted also works for me.

andrewrothman avatar Feb 22 '18 18:02 andrewrothman

It has been confirmed by a couple people that this is due to node-gyp not being up to date.

Interestingly, yarn has code that detects node-gyp and will auto install if it is actually missing. If I remove my node-gyp, I get:

info This package requires node-gyp, which is not currently installed. Yarn will attempt to automatically install it. If this fails, you can run "yarn global add node-gyp" to manually install it.
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 📃  Building fresh packages...
success Installed "[email protected]" with binaries:
      - node-gyp
v3.6.2
✨  Done in 2.40s.

or if I delete node-gyp and yarn add uws then yarn once again automatically installs node-gyp globally.

so I'm thinking that node-gyp might actually be there in some form but a broken install of it or out of date version or something. For anyone who can still reproduce this hang, could you add this to your package.json

"scripts": {
  "x": "which node-gyp",
  "y": "node-gyp -v"
}

then post the output of yarn run x and yarn run y and node -v.

rally25rs avatar Feb 24 '18 12:02 rally25rs

For those googling this: uws's build also gets caught in an endless loop if any of the files accessed have modification times in the future, so check your clock isn't set incorrectly.

snoopdouglas avatar Aug 23 '18 15:08 snoopdouglas