[SalesForce] sfdx update fails, Error: EPERM: operation not permitted

Went to create a new scratch org, and got a warning:

Warning: sfdx-cli update available from 7.102.0 to 7.104.0.

The scratch org created without issue, but I figured I may as well update to latest CLI version. I ran sfdx update and get the following error:

PS C:\Users\A Person\Projects\BluVector\SalesVector> sfdx update
sfdx-cli: Updating CLI from 7.102.0-dd7aac3 to 7.104.0-8acfa0e... done
sfdx-cli: Updating CLI... done
    Error: EPERM: operation not permitted, unlink 'C:\Users\A Person\AppData\Local\sfdx\client\7.102.0-dd7aac3\bin\node.exe'
    Code: EPERM
The batch file cannot be found.

Hints?

Best Answer

I was facing the same error right now. I added the location to environment variables and its working fine now.

For those who didn't understand anything I said above, What I did was,

  • I went to the location specified in the error.
  • Copied the location.(Here, its here => C:\Users\A Person\AppData\Local\sfdx\client\7.102.0-dd7aac3\bin)
  • Search for environment variables in windows search bar
  • Select 'Edit the System Environment Variables' and press 'Environment Variables' button under 'Advanced' Tab.
  • Select path and click on edit.
  • Click New.
  • Paste the location. Here, it is => C:\Users\A Person\AppData\Local\sfdx\client\7.102.0-dd7aac3\bin
  • Click Ok for all windows and restart your VSCode.

Its Done !

Try this and correct me if I am wrong.

Related Topic