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

Npm ERR! code EPERM error 4048 #2490

Closed
memao opened this issue Oct 8, 2019 · 13 comments
Closed

Npm ERR! code EPERM error 4048 #2490

memao opened this issue Oct 8, 2019 · 13 comments

Comments

@memao
Copy link

memao commented Oct 8, 2019

We encounter error 4048 randomly when we run npm ci on the hosted agent.

"The operation was rejected by your operating system. npm ERR! It's possible that the file was already in use (by a text editor or antivirus), npm ERR! or that you lack permissions to access it."

The file that have this error is random too. According to this trouble shoot guide, https://docs.microsoft.com/en-us/azure/devops/pipelines/troubleshooting?view=azure-devops, I think it might because of anti-virus running on the machine.
So I printed out the exclusion list, it already shows the d:\ (the working directory is D:\a\1\s, which is already under d:).

I also used handle.exe before and after the "npm ci" step to find the process that lock the file, but nothing suspicious showed up.

I am wondering is there any other anit-virus software on the hosted machine? Or is there any other software running on the agent that might cause the issue?

@jtpetty
Copy link
Contributor

jtpetty commented Feb 7, 2020

@memao - I apologize for the delay in responding back to you. Are you still seeing this issue? I am not aware of anything running on the hosted agents that might cause this.

If you are still seeing this, can you share the pipeline you are running?

@Rahkola
Copy link

Rahkola commented Apr 24, 2020

I'm experiencing similar issue. Azure DevOps build with YAML pipeline fails semi-randomly (around every third build) at npm install. Fails somehow due to Material design icons?

18578 error code EPERM
18579 error syscall unlink
18580 error path D:\a\1\s\Client\app\node_modules.staging\material-design-icons-d7808840\iconfont\MaterialIcons-Regular.svg
18581 error errno -4048
18582 error Error: EPERM: operation not permitted, unlink 'D:\a\1\s\Client\app\node_modules.staging\material-design-icons-d7808840\iconfont\MaterialIcons-Regular.svg'
18582 error [OperationalError: EPERM: operation not permitted, unlink 'D:\a\1\s\Client\app\node_modules.staging\material-design-icons-d7808840\iconfont\MaterialIcons-Regular.svg'] {
18582 error cause: [Error: EPERM: operation not permitted, unlink 'D:\a\1\s\Client\app\node_modules.staging\material-design-icons-d7808840\iconfont\MaterialIcons-Regular.svg'] {
18582 error errno: -4048,
18582 error code: 'EPERM',
18582 error syscall: 'unlink',
18582 error path: 'D:\a\1\s\Client\app\node_modules\.staging\material-design-icons-d7808840\iconfont\MaterialIcons-Regular.svg'
18582 error },
18582 error stack: "Error: EPERM: operation not permitted, unlink 'D:\a\1\s\Client\app\node_modules\.staging\material-design-icons-d7808840\iconfont\MaterialIcons-Regular.svg'",
18582 error errno: -4048,
18582 error code: 'EPERM',
18582 error syscall: 'unlink',
18582 error path: 'D:\a\1\s\Client\app\node_modules\.staging\material-design-icons-d7808840\iconfont\MaterialIcons-Regular.svg',
18582 error parent: 'app'
18582 error }
18583 error The operation was rejected by your operating system.
18583 error It's possible that the file was already in use (by a text editor or antivirus),
18583 error or that you lack permissions to access it.
18583 error
18583 error If you believe this might be a permissions issue, please double-check the
18583 error permissions of the file and its containing directories, or try running
18583 error the command again as root/Administrator.
18584 verbose exit [ -4048, true ]

@ghost
Copy link

ghost commented Apr 24, 2020

I have also seen an increased failures this week. Before that never a problem.
Have anyone a fix?

@rosshamish
Copy link

I've also started seeing this issue more often in the last month or so, during a pipeline step that is running npm ci. We work around it by retrying but it's a productivity loss for us. Any help would be much appreciated!

npm WARN tarball tarball data for office-ui-fabric-react@7.113.2 (sha512-U/TwourjGpxZePGVEis7+ZCsnBSGK6OC74PA4nJ8ryObFbc6zvMXJyOsSqYkn6FtenTt89absSp0f53FKOcjUA==) seems to be corrupted. Trying one more time.
npm ERR! code EPERM
npm ERR! syscall unlink
npm ERR! path D:\a\1\s\app\client\node_modules\office-ui-fabric-react\lib-amd\components\KeytipLayer\KeytipLayer.base.d.ts
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, unlink 'D:\a\1\s\app\client\node_modules\office-ui-fabric-react\lib-amd\components\KeytipLayer\KeytipLayer.base.d.ts'
npm ERR!  [OperationalError: EPERM: operation not permitted, unlink 'D:\a\1\s\app\client\node_modules\office-ui-fabric-react\lib-amd\components\KeytipLayer\KeytipLayer.base.d.ts'] {
npm ERR!   cause: [Error: EPERM: operation not permitted, unlink 'D:\a\1\s\app\client\node_modules\office-ui-fabric-react\lib-amd\components\KeytipLayer\KeytipLayer.base.d.ts'] {
npm ERR!     errno: -4048,
npm ERR!     code: 'EPERM',
npm ERR!     syscall: 'unlink',
npm ERR!     path: 'D:\\a\\1\\s\\app\\client\\node_modules\\office-ui-fabric-react\\lib-amd\\components\\KeytipLayer\\KeytipLayer.base.d.ts'
npm ERR!   },
npm ERR!   stack: "Error: EPERM: operation not permitted, unlink 'D:\\a\\1\\s\\app\\client\\node_modules\\office-ui-fabric-react\\lib-amd\\components\\KeytipLayer\\KeytipLayer.base.d.ts'",
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'unlink',
npm ERR!   path: 'D:\\a\\1\\s\\app\\client\\node_modules\\office-ui-fabric-react\\lib-amd\\components\\KeytipLayer\\KeytipLayer.base.d.ts'
npm ERR! }
npm ERR! 
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a text editor or antivirus),
npm ERR! or that you lack permissions to access it.
npm ERR! 
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

@SaiKrishnaTej23
Copy link

I am facing this issue on a regular basis.

@littleninja
Copy link

npm/cli#417

Some of the comments like this one mention disabling anti-virus on the working directory. Similar description from Microsoft docs on when to use anti-virus exclusion, but no mention how to apply this change to Microsoft-hosted agents (if there is a way):

Anti-virus exclusion

Anti-virus software scanning your files can cause file or folder in use errors during a build or release. Adding an anti-virus exclusion for your agent directory and configured "work folder" may help to identify anti-virus software as the interfering process.

@anatolybolshakov
Copy link
Contributor

Hi @memao @Rahkola @kdvtrifork @rosshamish @littleninja is this issue still actual for you? This error usually happens when some process locks file. Do you use npm pipelines task or cmd to run npm install?

@anatolybolshakov
Copy link
Contributor

Hi @memao @Rahkola @kdvtrifork @rosshamish @littleninja is this issue still actual for you?

@ghost
Copy link

ghost commented Jan 11, 2021

Hi @anatolybolshakov !

We have rewritten most of our testing code, since then we didn't experience it anymore.

@littleninja
Copy link

littleninja commented Jan 11, 2021

It failed as recently as Jan 4. We're using the NPM task. Our build pipeline is configured to use queue "Hosted VS2017".

  - task: Npm@1
    displayName: 'Install Dependencies'
    inputs:
      command: custom
      verbose: false
      customCommand: 'ci'

Possibly unrelated but worth mentioning: We've had a similar issue but on "ubuntu-latest", both installing node modules on the build agent and building a docker image that includes an npm ci step.

@anatolybolshakov
Copy link
Contributor

@littleninja could you share error details also?

@littleninja
Copy link

I've collected what I can find. Since we usually rerun the failed job, it's a bit more difficult to find details. That's on me, sorry for not collecting and including errors in my first comment. The following are ENOENT, not EPERM.

2021-01-07

17951 verbose stack Error: ENOENT: no such file or directory, open 'D:\a\1\s\node_modules\npm\node_modules\nopt\package.json'
17952 verbose cwd D:\a\1\s
17953 verbose Windows_NT 10.0.14393
17954 verbose argv "C:\\hostedtoolcache\\windows\\node\\12.15.0\\x64\\node.exe" "C:\\hostedtoolcache\\windows\\node\\12.15.0\\x64\\node_modules\\npm\\bin\\npm-cli.js" "ci"
17955 verbose node v12.15.0
17956 verbose npm  v6.13.4
17957 error code ENOENT
17958 error syscall open
17959 error path D:\a\1\s\node_modules\npm\node_modules\nopt\package.json
17960 error errno -4058
17961 error enoent ENOENT: no such file or directory, open 'D:\a\1\s\node_modules\npm\node_modules\nopt\package.json'
17962 error enoent This is related to npm not being able to find a file.
17963 verbose exit [ -4058, true ]

##[error]Error: Npm failed with return code: 4294963238

Another 2021-01-07

17956 verbose stack Error: ENOENT: no such file or directory, open 'D:\a\1\s\node_modules\npm\node_modules\duplexify\package.json'
17957 verbose cwd D:\a\1\s
17958 verbose Windows_NT 10.0.14393
17959 verbose argv "C:\\hostedtoolcache\\windows\\node\\12.15.0\\x64\\node.exe" "C:\\hostedtoolcache\\windows\\node\\12.15.0\\x64\\node_modules\\npm\\bin\\npm-cli.js" "ci"
17960 verbose node v12.15.0
17961 verbose npm  v6.13.4
17962 error code ENOENT
17963 error syscall open
17964 error path D:\a\1\s\node_modules\npm\node_modules\duplexify\package.json
17965 error errno -4058
17966 error enoent ENOENT: no such file or directory, open 'D:\a\1\s\node_modules\npm\node_modules\duplexify\package.json'
17967 error enoent This is related to npm not being able to find a file.
17968 verbose exit [ -4058, true ]

##[error]Error: Npm failed with return code: 4294963238

@anatolybolshakov
Copy link
Contributor

anatolybolshakov commented Jan 19, 2021

@littleninja ok thanks - these error seem to happen for many reasons, one of them could be related to issue
This error usually happens when package.json is missing - I reproduced this exact error by simply removing it, but can't reproduce if it exists...
Let me close this at the moment since it doesn't seem to be related to agent - please feel free to ask any further questions/attach some repro steps if issue still persists.

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

7 participants