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

Error: ENOENT: no such file or directory, copyfile #5275

Open
timsuchanek opened this issue Jan 24, 2018 · 24 comments
Open

Error: ENOENT: no such file or directory, copyfile #5275

timsuchanek opened this issue Jan 24, 2018 · 24 comments
Assignees

Comments

@timsuchanek
Copy link

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 git@github.com: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.
yarn@1.4.0
node@9.4.0
macOS Sierra@10.12.6

@ghost ghost assigned rally25rs Jan 24, 2018
@ghost ghost added the triaged label Jan 24, 2018
@rally25rs
Copy link
Contributor

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 😕

@nikoheikkila
Copy link

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

@sth
Copy link
Contributor

sth commented Feb 21, 2018

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.

@markushausammann
Copy link

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

@aneilbaboo
Copy link

aneilbaboo commented Jul 12, 2018

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://git@github.com/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://git@github.com/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.

@robphoenix
Copy link

robphoenix commented Jan 22, 2019

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

@jkonowitch
Copy link

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'

@aixfox
Copy link

aixfox commented Mar 18, 2019

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?)

@GioLogist
Copy link

I found success by reinstalling yarn w/brew.

@FabianSellmann
Copy link

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

@kylepecci
Copy link

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

@alexmcmillan
Copy link

alexmcmillan commented Aug 13, 2019

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.

@whoughton
Copy link

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.

hyochan added a commit to dooboolab-community/dooboo-ui that referenced this issue Oct 23, 2021
Yarn cache is not working as expected. Maybe related yarnpkg/yarn#5275
hyochan added a commit to dooboolab-community/dooboo-ui that referenced this issue Oct 23, 2021
* Upgrade expo sdk to 43 and instsall deps

* Upgrade @dooboo-ui/theme

* Fix linting

* Update test config and prevent breaking

* Remove `resolution`, the types looks like fixed

* Yarn2 renamed --frozen-lockfile into --immutable

* Remove --frozen-lock

   Yarn cache is not working as expected. Maybe related yarnpkg/yarn#5275

* Install expo-cli in CI

* Revert the expo/match-media package url

* Upgrade @dooboo-ui/theme to 0.4.3

* Update yarn.lock

* fix: added --network-concurrency to yarn install script

   Related yarnpkg/yarn#6312

* Fix linting

* Warn react-hooks/exhaustive-deps instead of error

   Strangely some machine thorws different errors

* Remove dup rules in eslint
@eric-burel
Copy link

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

@johachi
Copy link

johachi commented Jan 6, 2022

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.

@kira-bruneau
Copy link

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

@simkessy
Copy link

yea ive been seeing this issue a lot lately

@brian4159
Copy link

version problem ?

@manoharreddyporeddy
Copy link

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!

@kafir-coder
Copy link

kafir-coder commented Oct 13, 2022

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

I've tried the suggestion above and worked here

@akd-io
Copy link

akd-io commented Apr 22, 2023

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/pnpm@8.3.0/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

@jorgebastida
Copy link

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!

@Svashly
Copy link

Svashly commented Sep 7, 2023

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

@perplexyves
Copy link

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

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

No branches or pull requests