Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
AntJanus opened this issue Nov 15, 2016 · 34 comments · Fixed by #1871
Closed
Labels

Comments

@AntJanus
Copy link

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
@adrai
Copy link

adrai commented Nov 15, 2016

same on ubuntu

@eltuza
Copy link

eltuza commented Nov 15, 2016

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'".

@bestander
Copy link
Member

I can confirm, this is a regression after 0.16.1

@thomaschaaf
Copy link
Contributor

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.

@bestander
Copy link
Member

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

@thomaschaaf
Copy link
Contributor

@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.

@thomaschaaf
Copy link
Contributor

@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 :)

@AntJanus
Copy link
Author

Wow that was quick! Thanks everyone! :)

@hustcer
Copy link

hustcer commented Nov 16, 2016

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.

@warent
Copy link

warent commented Nov 16, 2016

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'".

@warent
Copy link

warent commented Nov 16, 2016

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

@webia1
Copy link

webia1 commented Nov 30, 2016

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

@soywod
Copy link

soywod commented Feb 16, 2017

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]

@joscha
Copy link

joscha commented Feb 27, 2017

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.

@czyin
Copy link

czyin commented Mar 2, 2017

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'

@bestander
Copy link
Member

bestander commented Mar 2, 2017

The lstat/ENOTDIR/ENOENT error is investigated in #2629

@kellyrmilligan
Copy link

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

@tortilaman
Copy link

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

@GeeWee
Copy link

GeeWee commented Aug 15, 2017

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

@vtno
Copy link

vtno commented May 7, 2018

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?

@idandrd
Copy link

idandrd commented Jun 10, 2018

same problem, yarn 1.7.0 on mac

@romenigld
Copy link

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'".

@odragora
Copy link

Same problem, on Windows 10 WSL

@patmcdermott
Copy link

Same problem on Ubuntu 18.04

@marcus-sa
Copy link

marcus-sa commented Dec 7, 2018

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?

@andsmi97
Copy link

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

@figo38
Copy link

figo38 commented Jan 4, 2019

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

@johannesschobel
Copy link

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!

@johannesschobel
Copy link

johannesschobel commented Jul 18, 2019

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.

@gitowiec
Copy link

gitowiec commented Nov 5, 2019

@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

@gregory
Copy link

gregory commented Dec 3, 2019

@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: #4563 (comment) :)

@tombh
Copy link

tombh commented Feb 22, 2020

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.

@smac89
Copy link

smac89 commented Jan 18, 2022

I've noticed that this error only started occurring when I used the --link-duplicates option for yarn install. I will be removing the option for now

@mseyfayi
Copy link

mseyfayi commented Nov 5, 2023

In my case removing node_modules and installing again wirked

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet