yarn icon indicating copy to clipboard operation
yarn copied to clipboard

Error: ENOENT: no such file or directory, copyfile

Open timsuchanek opened this issue 7 years ago • 24 comments

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

What is the current behavior? When having a yarn workspace, adding one of the packages to another and then executing yarn install throws this error:

Error: ENOENT: no such file or directory, copyfile '/Users/tim/Library/Caches/Yarn/v1/npm-jsonfile-4.0.0-8771aae0799b64076b76640fca058f9c10e33ecb/CHANGELOG.md' -> '/Users/tim/code/prisma-deployment-test/cli/node_modules/prisma-yml/node_modules/jsonfile/CHANGELOG.md'

Complete yarn-error.log

If the current behavior is a bug, please provide the steps to reproduce.

git clone [email protected]:graphcool/prisma.git
git checkout 97b85c6d7ac0f8eabbb481b4e9b81f99d67d8f99
cd cli/packages/prisma-yml
yarn install
yarn build
cd ../prisma-cli-engine/
yarn add -E prisma-yml
yarn install #BOOM

What is the expected behavior? Execute yarn install without throwing an error.

Please mention your node.js, yarn and operating system version. [email protected] [email protected] macOS [email protected]

timsuchanek avatar Jan 24 '18 16:01 timsuchanek

That's a strange one. Even after it errors, I can stat both the "from" and "to" files reported in the error, and they both exist 😕

rally25rs avatar Jan 29 '18 19:01 rally25rs

I was having a similar issue but worked around it by removing node_modules. Guess that's not the most friendly solution here, though.

nikoheikkila avatar Jan 30 '18 18:01 nikoheikkila

When I just tried to reproduce the bug, I got there error already during the "yarn add -E prisma-yml" step. The "no such file or directory" message was appropriate here since the target directory cli/node_modules/prisma-yml/node_modules/jsonfile really didn't exist.

sth avatar Feb 21 '18 23:02 sth

rm -rf node_modules && yarn cache clean && yarn install solves most such problems.

markushausammann avatar Mar 29 '18 07:03 markushausammann

For what it's worth, I wasn't able to cure with the steps Markus suggests. I even tried reinstalling yarn and manually deleting the yarn cache using rm -fr ~/Library/Caches/Yarn.

I did find a partial solution. I'm posting here in hopes it sheds light on what the underlying issue might be. Bullet 4 below shows how I fixed it.

My situation:

  1. The file causing the ENOENT error is a dependency of a private module I added using yarn add ssh+git://[email protected]/me/myprivatemodule.git. To be specific, myprivatemodule depends on mathjs, and yarn install was stopping with:

error An unexpected error occurred: "https://registry.yarnpkg.com/mathjs/-/mathjs-5.0.2.tgz: ENOENT: no such file or directory, open '/Users/aneil/Library/Caches/Yarn/v1/npm-mathjs-5.0.2-ed23dcfb40e886697447bcfe43e5dc5d92dd8eb0/docs/reference/functions/permutations.md'".

  1. Looking in the Yarn cache, I noticed (after attempting to install with a clean cache) that I had two copies of mathjs:
npm-mathjs-3.20.2-3218aebde7de8cb5627c8fe3a1a216bf399ba91d/
npm-mathjs-5.0.2-ed23dcfb40e886697447bcfe43e5dc5d92dd8eb0/

And... the 5.0.2 directory was empty, which is why I was seeing the error.

  1. It's worth noting that I was attempting to yarn install a freshly cloned repo on a new machine

  2. Running yarn add ssh+git://[email protected]/me/myprivatemodule.git fixed the problem

  3. I can reproduce the error with

rm -fr node_modules && yarn cache clean && yarn install

So, although I can continue development, I suspect my CI is borked.


Update: I see why I have two copies of the offending module - another dependency of my private module depends on the 3.20.2 version of mathjs. However, making myprivatemodule use the same version of mathjs doesn't solve the issue.

aneilbaboo avatar Jul 12 '18 00:07 aneilbaboo

I had this today, and had to rm -rf my yarn cache dir, the one used when running yarn in ~/.cache/yarn and the one in /usr/local/share/.cache/yarn used when running sudo yarn. This is in Ubuntu 18 on Windows 10.

❯ node -v
v10.15.0
❯ npm -v
6.6.0
❯ yarn -v
1.13.0

robphoenix avatar Jan 22 '19 16:01 robphoenix

This is still an issue, even in 1.14

Arguments: 
  /home/jeff/n/bin/node /usr/share/yarn/bin/yarn.js install

PATH: 
  /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/mnt/c/Windows/System32:/mnt/c/Windows:/mnt/c/Windows/System32/wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0:/mnt/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/mnt/c/Windows/System32:/mnt/c/Windows:/mnt/c/Windows/System32/wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0:/mnt/c/Windows/System32/OpenSSH:/mnt/c/Program Files/NVIDIA Corporation/NVIDIA NvDLISR:/mnt/c/Program Files/Git/cmd:/mnt/c/Users/jkono/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/jkono/AppData/Local/hyper/app-2.1.2/resources/bin:/mnt/c/Users/jkono/AppData/Local/Programs/Microsoft VS Code/bin:/home/jeff/n/bin

Yarn version: 
  1.14.0

Node version: 
  10.15.1

Platform: 
  linux x64

Trace: 
  Error: ENOENT: no such file or directory, scandir '/mnt/c/Users/jkono/dev/PROJECT/node_modules/@storybook/addon-links/src'

jkonowitch avatar Mar 06 '19 16:03 jkonowitch

still errs after rm -rf node_modules and yarn cache clean.

Yarn version: 1.13.0

Node version: 11.10.0

Platform: linux x64 (WSL)

Trace: Error: ENOENT: no such file or directory, lstat '/home/h/.cache/yarn/v4/npm-enhanced-resolve-4.1.0-41c7e0bfdfe74ac1ffe1e57ad6a5c6c9f3742a7f/node_modules/enhanced-resolve/lib/AliasPlugin.js'


fix with yarn global add yarn to re-install yarn. (someone tells me what happens?)

aixfox avatar Mar 18 '19 08:03 aixfox

I found success by reinstalling yarn w/brew.

GioLogist avatar Apr 18 '19 08:04 GioLogist

Had the same problem upgrading to yarn 1.15.2. removing node modules and cleaning cache did the trick.

FabianSellmann avatar Apr 30 '19 02:04 FabianSellmann

still errs after rm -rf node_modules and yarn cache clean.

Yarn version: 1.13.0

Node version: 11.10.0

Platform: linux x64 (WSL)

Trace: Error: ENOENT: no such file or directory, lstat '/home/h/.cache/yarn/v4/npm-enhanced-resolve-4.1.0-41c7e0bfdfe74ac1ffe1e57ad6a5c6c9f3742a7f/node_modules/enhanced-resolve/lib/AliasPlugin.js'

fix with yarn global add yarn to re-install yarn. (someone tells me what happens?)

This worked for me

kylepecci avatar Jul 15 '19 19:07 kylepecci

For those hitting this problem from inside WSL on Windows, this fixed it for me:

  • Delete node_modules
  • Install/update yarn on host Windows installation
  • Run yarn install inside the project from within Windows cmd/powershell

Installation succeeded, and switching back to an Ubuntu terminal (in WSL (inside VSCode)) I could yarn start without issue.

alexmcmillan avatar Aug 13 '19 07:08 alexmcmillan

This may not have anything to do with the issue here, but in case it helps, I have run across this issue when trying to copy files in between different volumes (especially NAS volumes) using the native fs routines.

whoughton avatar Nov 28 '19 01:11 whoughton

I have this message from type to time when using Yalc to symlink folders

eric-burel avatar Dec 13 '21 15:12 eric-burel

I got the same problem. It started occurring in my CI after refactoring a lot of files WITHOUT doing any changes to the package.json or yarn.lock file. The refactor did however change in what order the dependencies were called.

I'm unfortunately not able to share the repository since it is a private work repository. . However, I was able to solve it by having the CI run yarn install --network-concurrency 1 --frozen-lockfile instead of yarn install --frozen-lockfile.

johachi avatar Jan 06 '22 04:01 johachi

It looks like this is still a problem with --network-concurrency 1 😕 Setting that just seems to reduce how frequently it occurs.

kira-bruneau avatar Mar 01 '22 13:03 kira-bruneau

yea ive been seeing this issue a lot lately

simkessy avatar May 24 '22 00:05 simkessy

version problem ?

brian4159 avatar Jul 20 '22 15:07 brian4159

Started with:

npm install --global yarn
yarn cache clean
DEL /F/Q/S node_modules > NUL 2>&1  &  RMDIR /S/Q node_modules > NUL 2>&1

Added below to User Environment variables

%LocalAppData%\Yarn\bin

Then

yarn install

Then since the issue was eslint in my case, did below

yarn global add eslint
yarn add eslint -D

Then did:

npm install --global eslint
npm install -D eslint

Then in VS Code, output, in dropdown, I saw error in linter: So uninstalled below:

marketplace.visualstudio.com/items?itemName=fnando.linter

Then it worked, this was unexpected!

manoharreddyporeddy avatar Sep 17 '22 14:09 manoharreddyporeddy

rm -rf node_modules && yarn cache clean && yarn install solves most such problems.

I've tried the suggestion above and worked here

kafir-coder avatar Oct 13 '22 09:10 kafir-coder

Update:

I think in my case it happened because the project was initially installed with pnpm, and I ran yarn add thereafter.


Hitting this error consistently today.

Both locally on MacOS and on Ubuntu in CI: https://github.com/akd-io/create-next-stack/actions/runs/4772052085/jobs/8484361470?pr=172

local yarn-error.log:

Arguments: 
  /Users/akd/.nvm/versions/node/v18.13.0/bin/node /Users/akd/.nvm/versions/node/v18.13.0/bin/yarn add @emotion/react@^11.0.0 @emotion/styled@^11.0.0 @chakra-ui/icons@^2.0.0 @chakra-ui/react@^2.0.0 @mui/material@^5.0.0 react-hook-form@^7.0.0 formik@^2.0.0 framer-motion@^9.0.0 mrm@^4.0.0 mrm-task-lint-staged@^7.0.0

PATH: 
  /Users/akd/workspace/create-next-stack/packages/create-next-stack/node_modules/.bin:/Users/akd/Library/pnpm/global/5/.pnpm/[email protected]/node_modules/pnpm/dist/node-gyp-bin:/Users/akd/workspace/create-next-stack/node_modules/.bin:/Users/akd/Library/pnpm:/opt/homebrew/opt/openjdk/bin:/Users/akd/.nvm/versions/node/v18.13.0/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/akd/Library/pnpm:/opt/homebrew/opt/openjdk/bin:/Users/akd/.nvm/versions/node/v18.13.0/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/Users/akd/.yarn/bin:/Users/akd/.yarn/bin:/Users/akd/.nvm/versions/node/v18.13.0/bin

Yarn version: 
  1.22.19

Node version: 
  18.13.0

Platform: 
  darwin arm64

Trace: 
  Error: ENOENT: no such file or directory, copyfile '/Users/akd/Library/Caches/Yarn/v6/npm-globby-11.1.0-bd4be98bb042f83d796f7e3811991fbe82a0d34b-integrity/node_modules/globby/index.js' -> '/Users/akd/workspace/create-next-stack-tests/run-d4eb6dcc-9846-4222-a5ef-100d98053b1e/node_modules/@typescript-eslint/typescript-estree/node_modules/globby/index.js'

npm manifest: 
  {
    "name": "run-d4eb6dcc-9846-4222-a5ef-100d98053b1e",
    "version": "0.1.0",
    "private": true,
    "scripts": {
      "dev": "next dev",
      "build": "next build",
      "start": "next start",
      "lint": "next lint"
    },
    "dependencies": {
      "@types/node": "18.15.13",
      "@types/react": "18.0.38",
      "@types/react-dom": "18.0.11",
      "eslint": "8.39.0",
      "eslint-config-next": "13.3.1",
      "next": "13.3.1",
      "react": "18.2.0",
      "react-dom": "18.2.0",
      "typescript": "5.0.4"
    }
  }

yarn manifest: 
  No manifest

Lockfile: 
  No lockfile

akd-io avatar Apr 22 '23 09:04 akd-io

Solved this same issue by changing the Docker volume flags from delegated to cached; It seems like there were eventual consistency issues, and files weren't where they were expected in a timely fashion.

I hope this helps somebody!

jorgebastida avatar Jul 15 '23 08:07 jorgebastida

My solution was removing the file mentioned on the error after the word copyfile

Svashly avatar Sep 07 '23 18:09 Svashly

TL;DR

If all the previous solutions did not work with You, try this:

  1. Run:
yarn config set "strict-ssl" false -g
  1. Try again the installation

perplexyves avatar Apr 02 '24 12:04 perplexyves