runfinch / finch

The Finch CLI is an open source client for container development
https://www.runfinch.com
Apache License 2.0
3.47k stars 87 forks source link

Unable to start VM after closing command prompt on Windows #977

Open jasmaa opened 2 weeks ago

jasmaa commented 2 weeks ago

Describe the bug

On Windows, if the command prompt window used to start the Finch VM is closed without manually stopping the VM, Finch VM fails to restart with error saying it cannot attach disk.

The only workaround for this seems to be to remove and re-initialize the VM every time this happens.

Steps to reproduce

Open command prompt and initialize Finch VM:

finch vm init

Close and reopen command prompt. Start VM:

finch vm start

Expected behavior

Finch VM should attach disk and successfully start.

Screenshots or logs

Finch VM runs after init:

C:\Users\Jason>finch vm init
time="2024-06-12T06:47:30-04:00" level=info msg="attaching disk at path: C:\\Users\\Jason\\AppData\\Local\\.finch\\.disks\\6b456cb759bdbc3f.vhdx"
time="2024-06-12T06:47:32-04:00" level=info msg="Initializing and starting Finch virtual machine..."
time="2024-06-12T06:48:11-04:00" level=info msg="Finch virtual machine started successfully"

C:\Users\Jason>finch image ls
REPOSITORY                          TAG       IMAGE ID        CREATED           PLATFORM       SIZE       BLOB SIZE
public.ecr.aws/finch/hello-finch    latest    a71e474da9ff    24 minutes ago    linux/amd64    1.7 MiB    1.0 MiB

Finch VM fails to start after exiting and re-opening in CMD:

C:\Users\Jason>finch image ls
time="2024-06-12T06:51:15-04:00" level=fatal msg="instance \"finch\" is stopped, run `finch vm start` to start the instance"

C:\Users\Jason>finch vm start
time="2024-06-12T06:51:33-04:00" level=info msg="attaching disk at path: C:\\Users\\Jason\\AppData\\Local\\.finch\\.disks\\6b456cb759bdbc3f.vhdx"
time="2024-06-12T06:51:33-04:00" level=fatal msg="could not attach persistent disk: failed to attach disk: exit status 0xffffffff, command output: Failed to attach disk '\\\\?\\C:\\Users\\Jason\\AppData\\Local\\.finch\\.disks\\6b456cb759bdbc3f.vhdx' to WSL2: Error: 0x80040312\r\nError code: Wsl/Service/AttachDisk/MountVhd/WSL_E_USER_VHD_ALREADY_ATTACHED\r\n"

Additional context

Support bundle: finch-support-20240612065332.zip

Finch version:

C:\Users\Jason>finch -v
finch version v1.1.3

WSL version:

C:\Users\Jason>wsl -v
WSL version: 2.1.5.0
Kernel version: 5.15.146.1-2
WSLg version: 1.0.60
MSRDC version: 1.2.5105
Direct3D version: 1.611.1-81528511
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.22621.3593