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

Parcel 2: EPERM: operation not permitted, rename '...' -> '...' #4955

Open
Banou26 opened this issue Jul 30, 2020 · 24 comments
Open

Parcel 2: EPERM: operation not permitted, rename '...' -> '...' #4955

Banou26 opened this issue Jul 30, 2020 · 24 comments

Comments

@Banou26
Copy link
Contributor

Banou26 commented Jul 30, 2020

🐛 bug report

When modifying files, there's sometimes this error that is thrown:

 Error: EPERM: operation not permitted, rename 'C:devtestdistindex.015b01c3.js.3811495039' -> 'C:devtestdistindex.015b01c3.js'

The error is quite inconsistent.

Software Version(s)
Parcel ^2.0.0-nightly.353
Node v14.3.0
Operating System Windows 10 Pro 1909
@lokmeinmatz
Copy link

Same for me (Windows 10 Home, parcel: ^2.0.0-beta.1).
Happens often if i change the HTML file parcel is serving.

Currently I get this every time I change the file, I also deleted the cache and dist folders and restarted parcel, still no luck :( Every change after start leads to this error.
If I change the content back to the original at start time, the server is building again.

@acharayaP03
Copy link

Same problem here, if i remove --no-cache flag, scss partials are not reflected but when i have this flag then every time I make change same error occurs

@acharayaP03
Copy link

Same problem here, if i remove --no-cache flag, scss partials are not reflected but when i have this flag then every time I make change same error occurs

I dont know if this is a smart solution or not but, this method is working for me for now.
"watch": "node-sass src/main.scss ../dist/css/main.css -w",
"start": "parcel serve ./src/index.html --no-cache",
"dev": " npm-run-all --parallel watch start"

the error seems to be gone and all my js and scss including scss partials are compiling just fine.
I really like the idea of zero configuration with parcel. Will stick to this for now till this issue is fixed.

@petrhdk
Copy link

petrhdk commented Jan 7, 2021

Any progress? :)

I am using 2.0.0-nightly.514 on Windows 10 Command-Line, and the issue still persists. Well, "persists" might be misleading. Sometimes it's there, sometimes it is not.

the error seems to be gone

For me, adding --no-cache has no effect at all - parcel build nevertheless creates/uses the .parcel-cache/ directory and generates the 'EPERM' error, just as without --no-cache. Smells like a bug in itself :''D

Downgrading to 2.0.0-nightly.286 (as mentioned in #5036 in this comment) works, however this older version is much slower, etc.

My currently best "solution" is to simply ignore the 'EPERM' errors, because they don't abort the parcel build process ;)

@navaneeth-dev
Copy link

Same issue for me, "🚨 Error: EPERM: operation not permitted, rename".

  "devDependencies": {
    "@parcel/transformer-sass": "^2.0.0-alpha.3",
    "parcel": "^2.0.0-beta.1",
    "sass": "^1.32.2"
  },
Software Version
parcel ^2.0.0-beta.1
node v14.15.3
npm 6.14.9
os Windows 20H2

@tapioko
Copy link

tapioko commented Feb 19, 2021

I sometimes get this too. The last time it persisted between some restarts and then was gone.

Maybe it's not related to cache, because the error message refers to a file in dist-directory?

Using Sysinternals' Process Explorer I verified that the file was indeed used/locked by node.exe. There are two node-processes running in case it's related:
image

Software Version
parcel 2.0.0-nightly.570
node v14.15.5
npm 6.14.11
os Windows 1909

@WhalenSITHS
Copy link

I don't understand, is there no solution? Should go back to Parcel V1?

@petrhdk
Copy link

petrhdk commented Mar 20, 2021

See my comment above.

Simply ignore the errors (because for me they don't actually cancel or corrupt the build process), or downgrade to 2.0.0-nightly.286 (which very likely will be without the error, but it's older and slower, based on my experience).

@wibjorn
Copy link

wibjorn commented Apr 13, 2021

+1 on this issue. --no-cache still generates .parcel-cache folder (on windows, node 14.14.0) and definitely throws EPERM errors. They do not break builds, but they do look very bad.

@mischnic
Copy link
Member

--no-cache still generates .parcel-cache folder

This is intentional, the cache is also used to send data between threads

@wibjorn
Copy link

wibjorn commented Apr 14, 2021

@mischnic Thanks! That's good to know, might be nice to note that in the documentation for the CLI, since the behavior differs from v1, and because (IMO) it's somewhat surprising. (Sorry for the off topic comment)

@rstarkov
Copy link

rstarkov commented Apr 18, 2021

Getting this in serve mode, which stops working and requires a restart (edit: as in, Ctrl+C and run it again).

It feels like v2 isn't ready enough for v1 to be marked deprecated.

@MikesGlitch
Copy link

MikesGlitch commented Apr 23, 2021

Just in case anyone's restarting their computer to fix this, I found that closing my terminal and opening a new one fixed the issue. Still annoying tho.

@miloxeon
Copy link

Any progress on this?

@wibjorn
Copy link

wibjorn commented Apr 29, 2021

(Perhaps someone else could lend some credence to one the following combinations of workarounds as well, but ...) The combination of adding the ...

  1. recommended quotes around the entry point,
  2. reducing to a single entry point (was building multiple stylesheets at a time) and
  3. (the one that I think really did it) adding --no-source-maps
  4. Ensuring included Sass filenames are exact. `@import './path/to/_partial-file.scss'. Beware the underscores!

... has both precluded these EPERM errors from occurring (#4955) AND a problem regarding watching changes in included sass partials. However, errors regarding partial updates after an error (#6025) are still evident.

[...]
"watch-scripts": "parcel watch \"path/to/my/entry.scss\" --public-url . --no-autoinstall --log-level verbose --no-cache --no-source-maps"

Details:
dart-sass ('sass')
node 15.7
@parcel 2.0.0-beta.2

@mischnic
Copy link
Member

Can someone provide a code sample and instructions on how to reproduce this error consistently?

@Banou26
Copy link
Contributor Author

Banou26 commented Apr 30, 2021

@mischnic

Can someone provide a code sample and instructions on how to reproduce this error consistently?

From my experience with this bug, it's quite inconsistent, it just kind of randomly happens. So I'm not sure if someone will even be able to make a repro for this issue.

I've been trying to make a repro for this but it looks like the smaller a project is, the less chances are for it to happen.
Also it doesn't help that restarting the Parcel process fixes the issue.

Just deving on a medium or big sized project on windows should be enough for it to happen after some time though AFAIK.

Parcel isn't the first to have this issue, a lot of node projects have had their fair share of EPERM issues: microsoft/TypeScript#29407

It looks like Parcel must be locking onto cache files and then trying to modify them or something like that?

@mischnic
Copy link
Member

mischnic commented Apr 30, 2021

I suspect that the reason that this happens on Windows only is that using rename or mv to overwrite an existing file works fine on Linux/macOS but causes this error on Windows:

$ ls
a.js b.js
$ mv a.js b.js
$ ls
b.js

It looks like Parcel must be locking onto cache files and then trying to modify them or something like that?

(This issue is about EPERM rename with the dist dir)
I think the reason is that Parcel tries to write a bundle to the dist dir multiple times concurrently.

@MingweiSamuel
Copy link

I found one particular way to create this problem consistently with the following index.html on 2.0.0-beta.2:

<!doctype html>
<html lang="en">
<head>
  <script>
    // script tag
  </script>
</head>
<body>
</body>
</html>

Then run parcel serve src/index.html and once that is going run touch src/index.html (or just trigger a no-changes save from whatever editor).

The EPERM happens on the cache blob file corresponding to the script tag, which always is something like \.parcel-cache\ec\f40c59972a1659ee06b3f60fc35c87.blob.15372.1.oq. The script tag can be empty.

However this no longer happens on both 2.0.0-beta.3.1 and 2.0.0-nightly.749, so it seems that the specific issue I've described is fixed.

However this doesn't seem to quite match what others have been experiencing so there are probably other bugs causing this too.

@MingweiSamuel
Copy link

However this doesn't seem to quite match what others have been experiencing so there are probably other bugs causing this too.

Confirmed that I have run into this again for different unknown reasons

@rolve
Copy link

rolve commented Nov 21, 2021

I get the same error with 2.0.1, practically every time I change an HTML file. This is unusable.

@skhtml
Copy link

skhtml commented Nov 29, 2021

same error, Windows 11 (windows defender is off) When saving html file - got error @parcel/compressor-raw: EPERM: operation not permitted, rename

@andygock
Copy link

I have the same issue on parcel 2.0.1. Happens maybe one out of five edits and I'm forced to Ctrl+C and restart Parcel. Makes for a unusable workflow. Only noticed it happening when editing a HTML file.

@ghost
Copy link

ghost commented Feb 6, 2022

I am still getting this error. Ever since I updated Parcel. This happens regardless of whether I am making changes to html or scss files.

@parcel/compressor-raw: EPERM: operation not permitted, rename 'C:\Users\nicho\Desktop\projects\codecademy\Alpine\dist\index.b10d73a7.css.119072295' ->
'C:\Users\nicho\Desktop\projects\codecademy\Alpine\dist\index.b10d73a7.css'
"devDependencies": {
    "@parcel/transformer-sass": "^2.2.1",
    "parcel": "^2.2.1",
    "sass": "^1.49.7"
  }
Software Version
parcel ^2.2.1
node v17.3.0
npm 8.3.0
os Windows 11 - 21H2

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