parcel-bundler / parcel

The zero configuration build tool for the web. πŸ“¦πŸš€
https://parceljs.org
MIT License
43.39k stars 2.27k forks source link

@parcel/cache: EPERM: operation not permitted, rename #5036

Open dgkimpton opened 4 years ago

dgkimpton commented 4 years ago

πŸ› bug report

I get an error when using the latest @nightly that I don't get using the @next.

Strangely Parcel goes ahead and builds anyway so I'm not quite sure what this is about. Both files mentioned in the error exist, so it maybe fails to rename and copies instead?

It isn't 100% repeatable - exactly once it succeeded without the error - race condition?

πŸŽ› Configuration (.babelrc, package.json, cli command)

rm -rf .parcel-cache/* dist/* && parcel build --no-source-maps *.html src/**/*.html

πŸ€” Expected Behavior

No error.

😯 Current Behavior

@parcel/cache: EPERM: operation not permitted, rename 'E:codewebreaction-web.parcel-cache4b8ca9278422d5f7bdd56853b2d8203c.v8.26532.0.1' -> 'E:codewebreaction-web.parcel-cache4b8ca9278422d5f7bdd56853b2d8203c.v8'
Error: EPERM: operation not permitted, rename 'E:\code\web\reaction-web\.parcel-cache\4b\8ca9278422d5f7bdd56853b2d8203c.v8.26532.0.1' -> 'E:\code\web\reaction-web\.parcel-cache\4b\8ca9278422d5f7bdd56853b2d8203c.v8'

🌍 Your Environment

Software Version(s)
Parcel 2.0.0-nightly.370
Node 14.4.0
npm 6.14.5
Operating System Windows 10

Running the command in git-bash hosted inside vs-code.

I'm afraid I'm not quite sure what to include to help debug this one without copying across my entire project. Let me know if you want anything specific or something testing.

mischnic commented 4 years ago

It's probably because two thread try to write to the cache at the same time and renaming a file fails if the new name 8ca9278422d5f7bdd56853b2d8203c.v8 already exists.

Related: #4955, though this is about the cache and not the distdir...

Cristy94 commented 3 years ago

I get the same error every time I try to build using nightly-420. It was working fine in nightly-286, now I can not build anymore :(

@parcel/cache: EPERM: operation not permitted, rename '.parcel-cache2551fcab67e8d70c9e78e7663604f616.v8.16584.0.8' -> '.parcel-cache2551fcab67e8d70c9e78e7663604f616.v8'

Cristy94 commented 3 years ago

I want to mention that I get this error even though I build with --no-cache:

parcel build src/index.html --no-cache --no-scope-hoist --no-source-maps

Cristy94 commented 3 years ago

Reverting back to nightly-286 fixes the problem. I constantly tried to update to newer nightlies, but 286 was the last one that is still working fine for my project.

mischnic commented 3 years ago

So parcel@2.0.0-nightly.286 works but parcel@2.0.0-nightly.287 doesn't? Are you sure that all Parcel packages are on the same version (e.g. if you're using a parcelrc)?

AFAICT, this is the difference between 286 and 287: https://github.com/parcel-bundler/parcel/compare/1d216a94...4338719e. Nothing suspicious.

Cristy94 commented 3 years ago

So parcel@2.0.0-nightly.286 works but parcel@2.0.0-nightly.287 doesn't? Haven't tried with 287, I remember trying with something 300-ish and it didn't work, and now it still doesn't work with 420. Maybe I can try doing a binary-search through versions and see which is the first one that breaks.

Are you sure that all Parcel packages are on the same version (e.g. if you're using a parcelrc)?

I don't use a .parcelrc. I tried updating to 420, remove the .parcel-cache, build, it fails with that error plus some other errors (something related to V8 Handler and some warnings related to source-maps missing, even though I build with --no-source-maps.

droooney commented 3 years ago

Got the same issue after updating next (2.0.0-beta.1) to nightly (2.0.0-nightly.425).

Cristy94 commented 3 years ago

I tried again updating to nightly.433, same error. I even deleted before node_modules and all caches, still building doesn't work...

console: (node:14676) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 17 error listeners added to [Socket]. Use emitter.setMaxListeners() to increase limit 
console: (node:14676) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 17 close listeners added to [Socket]. Use emitter.setMaxListeners() to increase limit 
@parcel/cache: EPERM: operation not permitted, rename '.parcel-cache15d17aa12a6997112f0d035735b688fb.v8.14676.0.5' -> '.parcel-cache15d17aa12a6997112f0d035735b688fb.v8'
DindoLeonard commented 3 years ago

I just solved it, I uninstall parcel, npm uninstall pacel, then installed it again, npm install parcel-bundler --save-dev

krnlde commented 3 years ago

Continuing the discussion from #5965: @mischnic I prepared a repo for you resulting in the EPERM error (though not 100% of the time, but around 60% of the time everytime). To reproduce:

  1. git clone https://github.com/lookmom/nohands.git to your favorite testing folder (exact commit)
  2. yarn install it (you need yarn, it has some workspaces)
  3. yarn start it
  4. Open your favorite IDE and go to the file: https://github.com/lookmom/nohands/blob/main/src/assets/theme/_example.scss#L2
  5. Change the value to something else
  6. Sometimes see this (though not everytime): image
  7. If you don't see the error just stop and start again from point 3.

I have:

SCLeoX commented 3 years ago

@krnlde Could it be caused by cmder? I am having the same issue, and I am using cmder as well. (I have downgraded parcel, so I cannot try now.)

krnlde commented 3 years ago

Possibly. I'll try in plain cmd

krnlde commented 3 years ago

Nope, it took a lot longer to reproduce but still: image

Windows Terminal Preview (cmd)

What I do to reproduce is trying to modify the contents of the file, sometimes add a statement like color: gray;, sometimes remove it, to force the bundler to recompile (don't need try to change while recompiling). Let it recompile and sometimes in this process it fails with the above error (~ every 1 out of 5).

EDIT: it doesn't seem to happen ever with WSL Ubuntu shell. Probably windows specific though a showstopper since the (sym-)linked packages in node_modules from Linux cannot be resolved in Windows (needed for typescript code completions in the IDE)

krnlde commented 3 years ago

@mischnic did you try it in the meantime? Do you have a windows machine to test it on? Any news? This issue is annoying to a point where I consider to reconsider the bundler choice.

SCLeoX commented 3 years ago

@mischnic did you try it in the meantime? Do you have a windows machine to test it on? Any news? This issue is annoying to a point where I consider to reconsider the bundler choice.

Are there any feature of parcel 2 that you need? If not, I suppose you can revert back to parcel 1 and wait for this to be resolved. (That is what I did.)

krnlde commented 3 years ago

@SCLeoX: Other than that it's promoted as "production ready", "gets more frequent updates" and "is generally better"? No not really. I guess so.

mischnic commented 3 years ago

Sorry for the late response. I can indeed reproduce it with https://github.com/parcel-bundler/parcel/issues/5036#issuecomment-815808270

krnlde commented 3 years ago

How do we continue?

yasssuz commented 3 years ago

I'm having this error as well, it's annoying. Probably I'm going to change my bundler choice...

mischnic commented 3 years ago

For me, the error occurs way too rarely with the reproduction above to be able to debug it. I just no error at all after at least 5 minutes of trying.

I do think that this call is the failing operation: https://github.com/parcel-bundler/parcel/blob/a3679960728140a609ff29d98bf069e15d773305/packages/core/fs/src/NodeFS.js#L79

krnlde commented 3 years ago

Could it have something to do with (non-)atomic saves that possibly are handled differently in different OSes?

mischnic commented 3 years ago

This is definitely specific to Windows, and I did test this on Windows

krnlde commented 3 years ago

Update. Having "parcel": "2.0.0-nightly.649", and "@parcel/transformer-sass": "2.0.0-nightly.651", I didn't get the error for a whole workday. Can anyone confirm?

ahmedlahrizi commented 3 years ago

Update. Having "parcel": "2.0.0-nightly.649", and "@parcel/transformer-sass": "2.0.0-nightly.651", I didn't get the error for a whole workday. Can anyone confirm?

Doesn't work for me πŸ˜₯! but please don't close the issue, changing the version isn't a way to fix a problem

ahmedlahrizi commented 3 years ago

For me, the error occurs way too rarely with the reproduction above to be able to debug it. I just no error at all after at least 5 minutes of trying.

* Do you have to restart Parcel to get it to trigger? (= does it only happen on the first change after the initial build)

* Does it happen at all when there's a cache entry for the file contents (for example with `color: a;` -> `color: b` -> `color: a`, does the error happen after changing it back)?

I do think that this call is the failing operation:

https://github.com/parcel-bundler/parcel/blob/a3679960728140a609ff29d98bf069e15d773305/packages/core/fs/src/NodeFS.js#L79

So should we delete this line ?

mjep commented 3 years ago

I have been using parcel v2 on my Mac for about six weeks and one of my colleagues has just joined the project and is using win 10.

He straight away got this problem on his machine. I tried to reproduce on Mac and had no problems.

So I have just tried in my bootcamp partition, which was a bare windows install. I've installed node.js and cloned my project, run npm install and npm run watch and right away I get the same error.

I really need help with fixing this as this is a big problem and I don't think downgrading is a viable solution.

krnlde commented 3 years ago

Which version are you using? I couldn't reproduce it anymore with nightly 688+

mjep commented 3 years ago

I have been using this build for my dev: "parcel": "^2.0.0-beta.2"

However, I just uninstalled parcel and installed "parcel": "^2.0.0-beta.3.1" and have the same problems with both builds. I run a clean script between any build or watch attempts which deletes the cached files

mjep commented 3 years ago

Just an addtional observation. I get the following error after the above EPERM error when I run npm run build:

Γ— Build failed. @parcel/core: Failed to resolve '/testem.js' from './node\_modules/console-browserify/test/static/index.html' @parcel/resolver-default: Cannot load file '../../../../testem.js' in './node_modules/console-browserify/test/static'. Did you mean ../../.testem.json? Parcel is shutting down...

However, if I npm run watch I get a similar error referencing different files:

Γ— Build failed. @parcel/core: Failed to resolve '/bundle.js' from './node\_modules/vm-browserify/example/run/index.html' @parcel/resolver-default: Cannot load file '../../../../bundle.js' in './node_modules/vm-browserify/example/run'. Did you mean ../../index.js? Did you mean ./bundle.js? Parcel is shutting down...

krnlde commented 3 years ago

I have been using this build for my dev: "parcel": "^2.0.0-beta.2"

However, I just uninstalled parcel and installed "parcel": "^2.0.0-beta.3.1" and have the same problems with both builds. I run a clean script between any build or watch attempts which deletes the cached files

Could you try a parcel version >= 2.0.0-nightly.688 and see if it persists?

Realtimeknowledge commented 3 years ago

Yes sure I'll try now

mjep commented 3 years ago

With 2.0.0-nightly.688 I no longer get the EPERM error with either watch or build, but I do get another error, which looks like it's pointing at an error in my code perhaps? See below.

Γ— Build failed. @parcel/transformer-js: Browser scripts cannot have imports or exports. Use a Githubissues.

  • Githubissues is a development platform for aggregating issues.