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

EPERM: operation not permitted, lstat 'C:\Program Files\Windows Defender Advanced Threat Protection\Classification\Configuration' Try running again as Administrator. #217

Closed
Maxim-Mazurok opened this issue Sep 5, 2021 · 9 comments

Comments

@Maxim-Mazurok
Copy link

It was working fine until recently.
When I try to run nvs ls or nvs menu, it throws this error:

EPERM: operation not permitted, lstat 'C:\Program Files\Windows Defender Advanced Threat Protection\Classification\Configuration'
Try running again as Administrator.

My env:

C:\Users\maxim>echo %PATH%
C:\Python39\Scripts\;C:\Python39\;C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\intel64\compiler;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\bin;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\libnvvp;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\bin;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\libnvvp;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\Git\cmd;C:\Program Files\NVIDIA Corporation\Nsight Compute 2019.4.0\;C:\HashiCorp\Vagrant\bin;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files\Docker\Docker\resources\bin;C:\ProgramData\DockerDesktop\version-bin;C:\Program Files\dotnet\;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\ProgramData\chocolatey\bin;C:\Program Files\PowerShell\7\;C:\Users\maxim\scoop\shims;C:\Users\maxim\AppData\Local\Programs\Python\Python38\Scripts\;C:\Users\maxim\AppData\Local\Programs\Python\Python38\;C:\Users\maxim\.windows-build-tools\python27\;C:\Users\maxim\AppData\Local\Programs\Python\Python38-32\Scripts\;C:\Users\maxim\AppData\Local\Programs\Python\Python38-32\;C:\Users\maxim\AppData\Local\Microsoft\WindowsApps;C:\Users\maxim\.dotnet\tools;C:\Users\maxim\AppData\Local\GitHubDesktop\bin;C:\Program Files\nodejs;C:\Users\maxim\AppData\Local\Programs\Microsoft VS Code\bin;C:\Program Files (x86)\Nmap;C:\Users\maxim\.dotnet\tools;C:\Users\maxim\.deno\bin;C:\Users\maxim\.dotnet\tools;C:\Users\maxim\.dotnet\tools;C:\Users\maxim\AppData\Local\nvs\;C:\Users\maxim\AppData\Local\nvs\default;C:\Users\maxim\.dotnet\tools
C:\Users\maxim>nvs --version
1.5.2
OS Name:	Microsoft Windows 10 Pro N
Version:	10.0.19043 Build 19043

I don't recall changing any defender rules. One suspicion: windows update fails for me for a while now, maybe during the last "try and revert" cycle it affected something somehow... Will be happy to provide additional info.

@Maxim-Mazurok
Copy link
Author

Maxim-Mazurok commented Sep 5, 2021

I have uninstalled old nvs with choco, installed new 1.6.0, it hangs on "Publishing product information" for hours and doesn't let me cancel the installation.

When I tried to use nvs, it said:

Remove-Item: C:\Users\maxim\AppData\Local\nvs\nvs.ps1:105:2
Line |
 105 |      Remove-Item "$bootstrapNodePath"
     |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Access to the path 'C:\Program Files\cache\node.exe' is denied.

I removed C:\Program Files\cache manually.

Now I'm back to the square one:

C:\Windows\system32>nvs
Downloading boostrap node from https://nodejs.org/dist/v12.18.2/node-v12.18.2-win-x64.7z

EPERM: operation not permitted, lstat 'C:\Program Files\Windows Defender Advanced Threat Protection\Classification\Configuration'
Try running again as Administrator.

and this in cmd ran as administrator.

@Maxim-Mazurok
Copy link
Author

Related to #209 I guess

@jasongin
Copy link
Owner

jasongin commented Sep 5, 2021

I don't understand why it would be trying to access that directory. To help diagnose, can you set the NVS_DEBUG environment variable?

set NVS_DEBUG=1

Then run nvs again, and it should print a stack trace along with the error. Hopefully that will give us a better clue about what is causing the problem.

@Maxim-Mazurok
Copy link
Author

Maxim-Mazurok commented Sep 6, 2021

Sure, here you go (for 1.5.4):

C:\Users\maxim>set NVS_DEBUG=1

C:\Users\maxim>nvs
Error: EPERM: operation not permitted, lstat 'C:\Program Files\Windows Defender Advanced Threat Protection\Classification\Configuration'
    at Object.lstatSync (fs.js:838:3)
    at childNames.forEach.childName (C:\Users\maxim\AppData\Local\nvs\lib\list.js:175:19)
    at Array.forEach (<anonymous>)
    at getVersionsInternal (C:\Users\maxim\AppData\Local\nvs\lib\list.js:173:14)
    at childNames.forEach.childName (C:\Users\maxim\AppData\Local\nvs\lib\list.js:166:28)
    at Array.forEach (<anonymous>)
    at getVersionsInternal (C:\Users\maxim\AppData\Local\nvs\lib\list.js:162:14)
    at childNames.forEach.childName (C:\Users\maxim\AppData\Local\nvs\lib\list.js:156:28)
    at Array.forEach (<anonymous>)
    at getVersionsInternal (C:\Users\maxim\AppData\Local\nvs\lib\list.js:152:14)
Try running again as Administrator.

@Maxim-Mazurok
Copy link
Author

Maxim-Mazurok commented Sep 6, 2021

Also, installing and uninstalling 1.6.0 for all users worked without hanging/freezing.

@Maxim-Mazurok
Copy link
Author

This is from 1.6.0 all users install:

C:\Users\maxim>set NVS_DEBUG=1

C:\Users\maxim>nvs
Error: EPERM: operation not permitted, lstat 'C:\Program Files\Windows Defender Advanced Threat Protection\Classification\Configuration'
    at Object.lstatSync (fs.js:1000:3)
    at C:\ProgramData\nvs\lib\list.js:210:19
    at Array.forEach (<anonymous>)
    at getVersionsInternal (C:\ProgramData\nvs\lib\list.js:208:14)
    at C:\ProgramData\nvs\lib\list.js:201:28
    at Array.forEach (<anonymous>)
    at getVersionsInternal (C:\ProgramData\nvs\lib\list.js:197:14)
    at C:\ProgramData\nvs\lib\list.js:191:28
    at Array.forEach (<anonymous>)
    at getVersionsInternal (C:\ProgramData\nvs\lib\list.js:187:14)
Try running again as Administrator.

@jasongin
Copy link
Owner

jasongin commented Sep 6, 2021

What are the values of the NVS_ROOT and NVS_HOME env variables, if any?

I suspect some change/misconfiguration of one of those variables might be causing this problem. It should be possible to improve the code to detect that and report a better error message, instead of scan the wrong directories.

@Maxim-Mazurok
Copy link
Author

C:\Users\maxim>echo %NVS_ROOT%
%NVS_ROOT%

C:\Users\maxim>echo %NVS_HOME%
C:\Program Files

@Maxim-Mazurok
Copy link
Author

I've deleted NVS_HOME env var. Installed 1.6.0 for local user - worked fine.
And it now works fine: listed node versions and installed one.

C:\Users\maxim>echo %NVS_HOME%
C:\Users\maxim\AppData\Local\nvs\

Thanks for the help, not sure why NVS_HOME was invalid. I don't recall changing it manually.

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

No branches or pull requests

2 participants