minikube: hyperv: Unable to remove machine directory: ....vmcx: The process cannot access the file because it is being used by another process.
I have the same problem and tried this:
> minikube stop
*
X Unable to stop VM: open C:\Users\Csongor Halmai\.minikube\machines\minikube\config.json: The system cannot find the file specified.
*
* minikube is exiting due to an error. If the above message is not useful, open an issue:
- https://github.com/kubernetes/minikube/issues/new/choose
and then
> minikube delete
* Removing C:\Users\Csongor Halmai\.minikube\machines\minikube ...
*
X Unable to remove machine directory: remove C:\Users\Csongor Halmai\.minikube\machines\minikube\minikube\Snapshots\0113C205-19E6-4E44-9903-D0AA9C750A39.vmcx: The process cannot access the file because it is being used by another process.
*
* minikube is exiting due to an error. If the above message is not useful, open an issue:
- https://github.com/kubernetes/minikube/issues/new/choose
This seems to be show-stopper for me. 😦
> minikube version
minikube version: v1.9.0
commit: 48fefd43444d2f8852f527c78f0141b377b1e42a
_Originally posted by @halmai in https://github.com/kubernetes/minikube/issues/4286#issuecomment-605488971_
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 16 (6 by maintainers)
I believe this is no longer an issue in more recent releases.
My solution
In my case, I installed minikube by Chocolatey. But it worked as below. Even though I ran commands on PowerShell, Chocolatey shell was executed!
So I found a process that uses the minikube directory,
and I killed the process.
PURGE MINIKUBE.
I installed minikube by Windows installer, not the Chocolatey. Finally, the command below was executed well.
stopping hyper-v service worked for me
I had the same issue, and in Hyper-V Manager I deleted the minikube instance running. I tried the command again:
and it works!
Stopping the service in hyper-v manager solved the problem for me.
I was also facing the same issue , but after Shutting down all the process related to Hyper V from task manager my problem got resolved
@tstromberg thanks for the quick response.
It is possible that the files it was unable to delete were coming from an earlier version of minikube. However, even after stopping Hyper-V Host Compute Service from the Task Manager, I was unable to delete the files, which is strange. Both
minikube deleteand manual delete via Explorer failed. The solution I chose was to reboot win10 in safe mode and delete all the Snapshots manually. After a normal reboot everything works fine.Hey @halmai -
I’m very curious about what happened here, because it’s not supposed to be possible, but clearly it is. From your stop output:
X Unable to stop VM: open C:\Users\Csongor Halmai\.minikube\machines\minikube\config.json: The system cannot find the file specified.minikube was asked to stop a cluster that does not have any local state associated to it, so it failed. Is it possible that you accidentally deleted or moved
C:\Users\Csongor Halmai\.minikube\machines, or do we have a bug somewhere?Alternatively, is it possible that you called
stopwith a pre-v1.9.0 version of minikube first? We didn’t handle Hyper-V deletion so well before.As far as your delete output:
X Unable to remove machine directory: remove C:\Users\Csongor Halmai\.minikube\machines\minikube\minikube\Snapshots\0113C205-19E6-4E44-9903-D0AA9C750A39.vmcx: The process cannot access the file because it is being used by another process.This is stating that Hyper-V does in fact have a virtual machine running from this directory, even if the minikube state is gone. This is recoverable by launching the Hyper-V console and shutting the minikube VM down. Then
minikube deleteshould function as expected.Let me know how it works out. If the instructions work, I’ll make sure the error message points users to the appropriate solution. We can do a lot better here.