okibcn / wslcompact

Compacts the size of the ever-growing WSL vhdx images.
https://github.com/okibcn/wslcompact
GNU General Public License v3.0
800 stars 19 forks source link

Compact failed #14

Open Robula opened 1 year ago

Robula commented 1 year ago

Problem with the final copy commands:

Move-Item: An object at the specified path C:\Users\RD2A7~1.FIN does not exist.
Get-Item: Cannot find path 'C:\Users\RD2A7~1.FIN\AppData\Local\Temp\wslcompact\Ubuntu.vhdx' because it does not exist.

Full output:

wslcompact -c 
 WslCompact v8.7 2023.03.01
 (C) 2023 Oscar Lopez
 wslcompact -h for help. For more information visit: https://github.com/okibcn/wslcompact

 Distro's name:  Ubuntu
 Image file:     C:\Users\Robula\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState\ext4.vhdx
 Current size:   69524 MB
 Estimated size: 43648 +/- 1065 MB
 The estimated process time using an SSD is about 11 minutes.
 NOTE: You can safely cancel at any time by pressing Ctrl-C
 Import in progress, this may take a few minutes.
The operation completed successfully.
Move-Item: An object at the specified path C:\Users\RD2A7~1.FIN does not exist.
Get-Item: Cannot find path 'C:\Users\RD2A7~1.FIN\AppData\Local\Temp\wslcompact\Ubuntu.vhdx' because it does not exist.
 New Image compacted from 69524 MB to 0 MB
 Do you want to apply changes and use the new image (y/N): n

Here is my $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.3.4
PSEdition                      Core
GitCommitId                    7.3.4
OS                             Microsoft Windows 10.0.23430
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
okibcn commented 1 year ago

It is quite interesting that the local temp file is not C:\Users\Robula\AppData\Local\Temp\wslcompact\Ubuntu.vhdx

It seems that your temp folder is not under your user folder tree. wslcompact uses the TEMP variable. Can you check it by typing this in powershell:

ls env:T*

In normal conditions it should return something like:

Name                           Value
----                           -----
TMP                            C:\Users\Username\AppData\Local\Temp
TEMP                           C:\Users\Username\AppData\Local\Temp

I don't know what could be happening in your system, a virus, a software changing the temp folder, or an unknown problem with your Windows 11. The command above could bring some light on this issue.

lachiewalker commented 7 months ago

I have been having the same problem (when trying to compact my docker-desktop-data data image). I have successfully compacted this image before, however, I now cannot get past the above messages. I have tried:

Every time I got the same pair of errors: Move-Item... failed, causing line 101 $size2 = (Get-Item... to fail.