yarn install fails with `ENOENT: no such file or directory` occasionally
Running yarn install as part of a build step for a Docker image based on node:7 fails on Travis CI with ENOTEMPTY, EEXISTS errors. It always seems to error on the webdriverio package.
yarn install v0.19.1
[1/4] Resolving packages...
[2/4] Fetching packages...
error An unexpected error occurred: "https://registry.yarnpkg.com/webdriverio/-/webdriverio-4.6.2.tgz: ENOENT: no such file or directory, open '/usr/local/share/.cache/yarn/npm-webdriverio-4.6.2-dd095ee618896a21c8f1b9d4278736d85a64ca0f/lib/protocol/timeouts.js'".
When Travis runs yarn install as part of the install phase it works just fine. The error only happens when building a Docker image.
Repo which reproduces this issue.
node:7 OS: Docker + Travis CI yarn: 0.19.1 package.json yarn.lock
I've tried installing yarn both with npm install -g and with apt and both methods cause the failure on Travis.
Weirdly enough, the image builds successfully on my local machine which runs Ubuntu 16.04.1 LTS with Docker version 1.13.0, build 49bf474.
Interesting, so it only fails on Travis, but works when testing locally? That's very weird given Docker is supposed to ensure the environment is consistent.
@Daniel15 I know right...
I've downgraded node to version 6 and it still fails on Travis. I've added the --verbose flag to yarn install and all I got was
verbose Performing "GET" request to "https://registry.yarnpkg.com/spawn-wrap/-/spawn-wrap-1.3.4.tgz".
verbose Performing "GET" request to "https://registry.yarnpkg.com/yargs/-/yargs-6.6.0.tgz".
verbose Performing "GET" request to "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-4.2.1.tgz".
verbose Performing "GET" request to "https://registry.yarnpkg.com/fibers/-/fibers-1.0.15.tgz".
verbose Performing "GET" request to "https://registry.yarnpkg.com/selenium-standalone/-/selenium-standalone-5.11.2.tgz".
verbose Performing "GET" request to "https://registry.yarnpkg.com/tcp-port-used/-/tcp-port-used-0.1.2.tgz".
verbose Performing "GET" request to "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-5.8.38.tgz".
verbose Error: ENOTEMPTY: directory not empty, rmdir '/usr/local/share/.cache/yarn/npm-webdriverio-4.6.2-dd095ee618896a21c8f1b9d4278736d85a64ca0f/lib/protocol'
at Error (native)
error An unexpected error occurred: "ENOTEMPTY: directory not empty, rmdir '/usr/local/share/.cache/yarn/npm-webdriverio-4.6.2-dd095ee618896a21c8f1b9d4278736d85a64ca0f/lib/protocol'".
I am open to ideas on how to debug this.
Downgrading to yarn 0.18.1 seemed to fix this for me. Seems like 0.19 might have a regression; see #1834
I also have this problem with yarn 0.23.3, it's happening not when building an image but simply when running some CI. The error is the following:
$ time yarn --frozen-lockfile
yarn install v0.20.3
[1/4] Resolving packages...
[2/4] Fetching packages...
error An unexpected error occurred: "ENOTEMPTY: directory not empty, rmdir '/builds/linagora/petals-cockpit/yarncache/npm-@angular/core-4.0.0-beta.8-8d9c8a64e7c26ff7208404e716deea94bb509cd7/src'".
info If you think this is a bug, please open a bug report with the information provided in "/builds/linagora/petals-cockpit/frontend/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
real 0m9.812s
user 0m7.596s
sys 0m0.932s
I think there may be some strange way of doing remove of files…
Important point: the cache was empty!
And on my machine, if I try to repro, I get this:
yarn install v0.20.3
[1/4] Resolving packages...
[2/4] Fetching packages...
error An unexpected error occurred: "http://docker0.gso.lan:8081/repository/npm/@angular/core/-/core-4.0.0-beta.8.tgz: EEXIST: file already exists, mkdir '/home/vnoel/.cache/yarn/npm-@angular/core-4.0.0-beta.8-8d9c8a64e7c26ff7208404e716deea94bb509cd7/src/metadata'".
info If you think this is a bug, please open a bug report with the information provided in "/home/vnoel/Linagora/Petals/dev/git/petals-cockpit-new/frontend/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
And with yarn 0.21.2:
yarn install v0.21.2
[1/4] Resolving packages...
[2/4] Fetching packages...
error An unexpected error occurred: "http://docker0.gso.lan:8081/repository/npm/@angular/core/-/core-4.0.0-beta.8.tgz: ENOENT: no such file or directory, lstat '/home/vnoel/.cache/yarn/npm-@angular/core-4.0.0-beta.8-8d9c8a64e7c26ff7208404e716deea94bb509cd7/bundles/core.umd.js'".
info If you think this is a bug, please open a bug report with the information provided in "/home/vnoel/Linagora/Petals/dev/git/petals-cockpit-new/frontend/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
That's terrible!
And I concur with @twooster about 0.18.1 working ok!
@Daniel15 it doesn't work locally either. Actually, it NEVER work when the cache is empty for me!
@victornoel the recent error could be https://github.com/yarnpkg/yarn/issues/2714
@bestander I did try 0.19.1 at the time and it didn't work…
I retried, and now the bug:
- does not appear with an empty cache, but does appear in the following case (I really hope it is reproducible…):
rm -rfthe yarn cache- clone https://gitlab.com/linagora/petals-cockpit.git
- checkout 5f31ccb4b2357201baa50539b30702cffceb6992
- run yarn in the
frontenddirectory - checkout master
- run yarn again in the
frontenddirectory - I get:
error An unexpected error occurred: "http://docker0.gso.lan:8081/repository/npm/@angular/core/-/core-4.0.0-rc.1.tgz: ENOENT: no such file or directory, utime '/home/vnoel/.cache/yarn/npm-@angular/core-4.0.0-rc.1-7f87b7696b407476e45d6d3c1880a50d5afbb6e3/@angular/core/testing.js'".(I am using my own registry, but the same happens without it)
- does appear with yarn 0.21.2, 0.19.1 but not with 0.18.2
So I don't think it is the same, let's hope you can reproduce it at least…
(actually, I just tried again and reproduced the bug with an empty cache and yarn 0.21.2 while it wasn't the case before, maybe there is another file somewhere else that is the source of this problem, and that is not in the cache?)
@bestander I will still test yarn as soon as #2744 is available as a nightly build :)
Ping me if I can help. The best action is to send a PR with a broken (and skipped) e2e test.
@bestander well, nope, I still get errors such as:
➜ frontend git:(master) ✗ yarn
yarn install v0.22.0-20170227.1509
[1/4] Resolving packages...
[2/4] Fetching packages...
error An unexpected error occurred: "https://registry.yarnpkg.com/@angular/core/-/core-4.0.0-rc.1.tgz: ENOENT: no such file or directory, lstat '/home/vnoel/.cache/yarn/npm-@angular/core-4.0.0-rc.1-7f87b7696b407476e45d6d3c1880a50d5afbb6e3/typings/src/facade/lang.d.ts'".
or:
➜ frontend git:(master) ✗ yarn
yarn install v0.22.0-20170227.1509
[1/4] Resolving packages...
[2/4] Fetching packages...
error An unexpected error occurred: "https://registry.yarnpkg.com/typescript/-/typescript-2.2.1.tgz: ENOENT: no such file or directory, lstat '/home/vnoel/.cache/yarn/npm-typescript-2.2.1-4862b662b988a4c8ff691cc7969622d24db76ae9/lib/typescriptServices.js'".
I will see if I can make an e2e test.
@bestander anyway I can get a complete stacktrace of the error?
I only see this in the yarn-error.log:
Trace:
Error: http://docker0.gso.lan:8081/repository/npm/@angular/core/-/core-4.0.0-rc.1.tgz: ENOENT: no such file or directory, lstat '/home/vnoel/.cache/yarn/npm-@angular/core-4.0.0-rc.1-7f87b7696b407476e45d6d3c1880a50d5afbb6e3/@angular/core.es5.js'
at Error (native)
That's a bit useless :)
the detailled error is:
{ Error: http://docker0.gso.lan:8081/repository/npm/@angular/core/-/core-4.0.0-rc.1.tgz: ENOENT: no such file or directory, lstat '/home/vnoel/.cache/yarn/npm-@angular/core-4.0.0-rc.1-7f87b7696b407476e45d6d3c1880a50d5afbb6e3/@angular/core.js'
at Error (native)
errno: -2,
code: 'ENOENT',
syscall: 'lstat',
path: '/home/vnoel/.cache/yarn/npm-@angular/core-4.0.0-rc.1-7f87b7696b407476e45d6d3c1880a50d5afbb6e3/@angular/core.js',
fstream_type: 'File',
fstream_path: '/home/vnoel/.cache/yarn/npm-@angular/core-4.0.0-rc.1-7f87b7696b407476e45d6d3c1880a50d5afbb6e3/@angular/core.js',
fstream_class: 'FileWriter',
fstream_stack:
[ '/home/vnoel/Linagora/Petals/dev/git/yarn/node_modules/fstream/lib/writer.js:285:28',
'/home/vnoel/Linagora/Petals/dev/git/yarn/node_modules/graceful-fs/polyfills.js:284:29',
'FSReqWrap.oncomplete (fs.js:123:15)' ] }
Not sure exactly what to do with this… it's happening at package-fetcher.js, line 56 exactly, I have trouble finding the source though…
It seems stupid, but I feel like it fails only when my networked npm mirror (a sonatype nexus in my company) has mirrored the @angular/core artefact. If it hasn't, things go well and then it fails on another artefact that is already mirrored (typescript in this case).
If I remove the artefact from the nexus mirror by hand, it works!
So… it is a bit like yarn can't keep up if things arrive too fast ^^ because when I use the normal npm registry without using my mirror, things usually goes well (we have a slow internet connection). And it would explain why it often fails on CI systems because they usually have very fast internet connections…
That's a bit of stretch to conclude that, but it could help find the origin of the problem. WDYT @bestander?
For the record, I think the error is emanating from tar.Extract step in the fetching pipeline, but I'm not totally sure ^^
Thanks for researching more, @victornoel, you might be on something here.
I can repro scenario from https://github.com/yarnpkg/yarn/issues/2629#issuecomment-282745896. Looking into it.
I get
error An unexpected error occurred: "https://registry.yarnpkg.com/typescript/-/typescript-2.2.1.tgz: ENOENT: no such file or directory, lstat '/Users/bestander/Library/Caches/Yarn/npm-typescript-2.2.1-4862b662b988a4c8ff691cc7969622d24db76ae9/lib/typescriptServices.js'".
However if I just try yarn install again and again it will eventually finish the installation.
Looks like exploding the .tgz file ends with error.
Update:
- the .tgz seems fine, I can unzip manually the one that fails during fetch phase
- I wonder if
tarpackage is throwing this error for some reason, could it be concurrency?
Some help investigating why untaring those few dependencies (in my case typescript and angular-core) causes error is welcome. Concurrency? Bug in https://github.com/npm/node-tar?