stencil icon indicating copy to clipboard operation
stencil copied to clipboard

WINDOWS Build Error EPERM: operation not permitted, copyfile

Open mmakrzem opened this issue 4 years ago • 6 comments

Stencil version:

 @stencil/[email protected]

I'm submitting a:

[X] bug report [ ] feature request [ ] support request => Please do not submit support requests here, use one of these channels: https://stencil-worldwide.herokuapp.com/ or https://forum.ionicframework.com/

Current behavior: stencil doesn't remove old read-only files that it copied to the www folder before it tries to copy them again on a subsequent run, thus an EPERM error happens on Windows.

Expected behavior: Read only files should be handled correctly by the build system.

Steps to reproduce: Copy the project found in: https://github.com/mmakrzem/stencilCopyBug

mark the file found in src/assets/images/readOnlyImage.jpg as being read-only

npm i

npm run start

stop the running session

npm run start

On the 2nd run, you will see the build error:

Build Error EPERM: operation not permitted, copyfile 'C:\st-1-17-2-copyBug\src\assets\images\readOnlyImage.jpg' -> 'C:\st-1-17-2-copyBug\www\assets\images\readOnlyImage.jpg'

mmakrzem avatar Jul 31 '20 12:07 mmakrzem

I filed this bug a while ago here: https://github.com/ionic-team/stencil/issues/2235 It was claimed to be fixed, but the problem is still occurring and isn't fixed

mmakrzem avatar Jul 31 '20 12:07 mmakrzem

hey, i was having this issue, when using vue.js, everytime i runned 'npm run dev' or 'npm run watch' this error appears, im using docker server, stopping it before run 'npm run dev' worked for me

Ezylpro avatar Jul 31 '20 22:07 Ezylpro

hope you understood what i said

Ezylpro avatar Jul 31 '20 22:07 Ezylpro

Getting same issue Code:

const fs = require('fs');

fs.copyFile('./dist/frontend.controls.0.0.1.umd.min.js', './../../dist/content/lib/asi/js/', (err) => {
  if (err) throw err;
  console.log('frontend.controls.0.0.1.umd.min.js was copied to destination.txt');
});

Error:

[Error: EPERM: operation not permitted, copyfile 'D:\Foundation.Web\src\frontend-control-library\dist\frontend.controls.0.0.1.umd.min.js' -> 'D:\Foundation.Web\dist\content\lib\asi\js'] {
  errno: -4048,
  code: 'EPERM',
  syscall: 'copyfile',
  path: 'D:\\Foundation.Web\\src\\frontend-control-library\\dist\\frontend.controls.0.0.1.umd.min.js',
  dest: 'D:\\Foundation.Web\\dist\\content\\lib\\asi\\js'
}

ranjanngc avatar Apr 27 '21 05:04 ranjanngc

It may be that the file is being used

OriginZero avatar May 02 '21 02:05 OriginZero

It seems that when copying an asset, Stencil doesn't remove the 'readonly' flag on the file. This results in a failure (I believe) due to trying to overwrite a readonly file (that was placed in www/assets/images/) on the first build

rwaskiewicz avatar Nov 08 '23 14:11 rwaskiewicz