Yarn: "No such file file or directory, lstat" for Yarn cache during package install on Windows

Created on 15 Nov 2016  ·  32Comments  ·  Source: yarnpkg/yarn

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

Bug

What is the current behavior?

I'm on Windows 10, Node v6.9.1, and Yarn 0.17.0

I'm running yarn to install packages for a personal project and during installation, I get the error:

error An unexpected error occurred: "ENOENT: no such file or directory, lstat 'C:\\Users\\[my username]\\AppData\\Local\\Yarn\\cache\\npm-gulp-4.0.0-alpha.2-58ae6d972ff84fa07ba9cc30cf7d13d9bc646f39'".

I'm guessing yarn is not a big fan of the Gulp version "github:gulpjs/gulp#4.0" which causes it to have the above issue. Running yarn cache clean and redoing the install doesn't help.

What is the expected behavior?

Installation without errors. Running npm install with npm version 3.10.8 works without a hitch.

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

  • Windows 10 Anniversary
  • Node v 6.9.1
  • Yarn 0.17.0
cat-bug

Most helpful comment

same problem, yarn 1.7.0 on mac

All 32 comments

same on ubuntu

same on macOs Sierra 10.12.1

An unexpected error occurred: "ENOENT: no such file or directory, lstat '/Users/[username]/Library/Caches/Yarn/npm-gulp-4.0.0-alpha.2-58ae6d972ff84fa07ba9cc30cf7d13d9bc646f39'".

I can confirm, this is a regression after 0.16.1

I tried finding the reason and could nail it down to: https://github.com/yarnpkg/yarn/blob/master/src/resolvers/exotics/hosted-git-resolver.js#L140 missing the hash attribute. This results in the package being created in the cache folder with a name without the hash (https://github.com/yarnpkg/yarn/blob/master/src/config.js#L265). After it is downloaded however the hash is set here: https://github.com/yarnpkg/yarn/blob/master/src/package-fetcher.js#L91 removing this assignment fixes the problem.

@thomaschaaf, would you try sending a PR with a unit test?

@bestander the better option would be to get the hash in https://github.com/yarnpkg/yarn/blob/master/src/resolvers/exotics/hosted-git-resolver.js#L140 here.
Removing the hash updating seems nasty. Or we could not add a hash if a hash was not set until that point.

I am still trying to navigate through the code but can't figure out how it was done before.

@bestander I am sorry I can't create a unit test at the moment - as I have to be up early in the morning.

The PR should fix the problem :)

Wow that was quick! Thanks everyone! :)

Same here, with [email protected], [email protected], macOS10.12.1

error An unexpected error occurred: "ENOENT: no such file or directory, lstat '/Users/hustcer/Library/Caches/Yarn/npm-gulp-4.0.0-alpha.2-947491601cd7d5959a48d2f305d96ef44d94b047'".
info If you think this is a bug, please open a bug report with the information provided in "/Users/hustcer/github/swift-quant/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

Experiencing this problem in yarn v0.17.2 on Arch Linux 4.8.7-1-ARCH

error An unexpected error occurred: "https://registry.yarnpkg.com/async-each/-/async-each-1.0.1.tgz:
ENOENT: no such file or directory, open '/home/warent/.cache/yarn/npm-async-each-1.0.1-19d386a1d9edc6e7c1c85d388aedbcc56d33602d/.yarn-tarball.tgz'".

Interestingly, when I updated my npm prefix, per: https://docs.npmjs.com/getting-started/fixing-npm-permissions

and then I ran yarn v0.17.2, it worked fine

Today, same problem, windows 7, yarn 0.17.9, node 6.8.1, npm 4.0.3

I had the same error using [email protected] (but no problem with [email protected])
Here my repo where I reproduced it : https://github.com/soywod/yarn-bug-1834

Main error : Error: ENOENT: no such file or directory, lstat '/Users/clementdouin/Documents/yarn-bug-1834/node_modules/chai-fs/test/fixtures/non-existing.txt'

Uname -a : Darwin MAC164 16.4.0 Darwin Kernel Version 16.4.0: Thu Dec 22 22:53:21 PST 2016; root:xnu-3789.41.3~3/RELEASE_X86_64 x86_64

[email protected]

I am still seeing this error with 0.20.3:

 ✘ joscha@canvabox  ~/dev/canva/web/ui   master  yarn cache clean
yarn cache v0.20.3
success Cleared cache.
✨  Done in 3.99s.
 joscha@canvabox  ~/dev/canva/web/ui   master  yarn install
yarn install v0.20.3
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
error An unexpected error occurred: "ENOENT: no such file or directory, lstat '/Users/joscha/Library/Caches/web'".
info If you think this is a bug, please open a bug report with the information provided in "/Users/joscha/dev/canva/web/ui/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

I had the similar error with [email protected],

Arguments:
/usr/local/bin/node /usr/local/bin/yarn cache ls

Yarn version:
0.21.3

Node version:
7.7.1

Platform:
darwin x64

npm manifest:
No manifest

yarn manifest:
No manifest

Lockfile:
No lockfile

Trace:
Error: ENOTDIR: not a directory, scandir '/Users/**/Library/Caches/Yarn/npm-engine.io-1.8.3-8de7f97895d20d39b85f88eeee777b2bd42b13d4/package.json'

The lstat/ENOTDIR/ENOENT error is investigated in https://github.com/yarnpkg/yarn/issues/2629

same issue here as well, os x sierra, node 6.9.2, latest yarn

Still seeing this error with github based packages on yarn V0.27.5

Yep - a pulling a package from github completely broke our yarn as well.

I have this issue with yarn 1.6.0 node v9.11.1. Are there a way to fix this without reverting to older version?

same problem, yarn 1.7.0 on mac

Same problem on Mac OS
yarn check
yarn check v1.7.0
error An unexpected error occurred: "ENOENT: no such file or directory, open '/Users/romenigld/package.json'".

Same problem, on Windows 10 WSL

Same problem on Ubuntu 18.04

This keeps happening all the time, which is extremely annoying.
Clearing the cache doesn't help either.

So now I have to run yarn install 200 times before it succeeds.
Is there no flag for telling it to keep retrying if it fails?

Got the same problem while running create-react-app.
Node -v v10.7.0
yarn --version 1.12.1

Same issue on linux subsystem Ubuntu 18.04 for windows 10,
yarn global add create-react-app
yarn --version 1.12.3
node --version 8.12.0

then

create-react-app myApp

i recently ran into the same issue on windows 10 and windows 8.1 .. however, when looking for the file that was mentioned in the error description, i found out, that the file exist but cannot be read ... (e.g., if i try to open the file with a notepad).

When i than ran a check disk tool from windows it stated, that the disk had errors and needs to be repaired - which i did when i restarted the computer.

Then, the issue was resolved..

Buuuuuuuuuuuuuuuuuuuut - it emerged some weeks later again.. so i re-repaired the disk and so on, and now it works again..

Any solution for this? Because i don't think my disk is broken - it is quite new!
Thanks for your help and suggestions!

i managed to solve the issue with running

yarn cache clean
rm ./yarn.lock
yarn install

This process, however, takes ages, because it downloads all packages again because you a) don't have a cache any more and your lock file has been removed.

@andsmi97 I don't know any flag but I use this script to run yarn install in a loop:

#!/bin/bash
set -x #echo on

until
    yarn install --check-files --frozen-lockfile;
do
    echo "Surprise, surprise. Let's try again..."
done

It is Linux script (could run on Windows WSL or MacOS, I don't know)
Put it in a file like this yarn-install-in-loop.sh and call it with ./yarn-install-in-loop.sh

@andsmi97 I don't know any flag but I use this script to run yarn install in a loop:

#!/bin/bash
set -x #echo on

until
    yarn install --check-files --frozen-lockfile;
do
    echo "Surprise, surprise. Let's try again..."
done

It is Linux script (could run on Windows WSL or MacOS, I don't know)
Put it in a file like this yarn-install-in-loop.sh and call it with ./yarn-install-in-loop.sh

funny just found the exact same snippet here: https://github.com/yarnpkg/yarn/issues/4563#issuecomment-443375674 :)

I was getting this same frustrating and hard to debug error. The problem in my case seemed to be yarn workspace behaviour caused by different versions of the same dependency in different packages (specifically ava versions 2 and 3). Only once I'd upgraded all occurrences of ava to their latest did I stop getting this error.

Was this page helpful?
0 / 5 - 0 ratings