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

Cannot index into a null array. #7

Closed
jerodway opened this issue Feb 13, 2023 · 7 comments
Closed

Cannot index into a null array. #7

jerodway opened this issue Feb 13, 2023 · 7 comments

Comments

@jerodway
Copy link

Has anyone encountered this error:

PS C:\Users\rodwjam> wslcompact
WslCompact v7.0 2023.02.08
(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\canso\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState\ext4.vhdx
Current size: 28691 MB
Cannot index into a null array.
At C:\Users\canso\scoop\apps\wslcompact\current\wslcompact.ps1:79 char:17

  • ... $estimated = ((wsl --system -d "$wsl_distro" -e df /mnt/w ...
  •             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (:) [], RuntimeException
    • FullyQualifiedErrorId : NullArray

Estimated size: 0 +/- 0 MB
The estimated process time using an SSD is about 0 minutes.

@okibcn
Copy link
Owner

okibcn commented Feb 13, 2023

@jerodway, do you have any special user configuration within your Ubuntu? the Estimated size is provided by wsl, so it might be a configuration colliding with it. Do you have other distros installed and running at the same time? It shouldn't be a issue, but I need more data to know what is going on in your system.

Please try these two commands from PowerShell:

wsl --system -d Ubuntu -e df /mnt/wslg/distro
wsl -d Ubuntu -e df /

And this one from within a WSL shell session inside Ubuntu:

\df /

They should return the same text, but for some reason, in your case, it is behaving differently. It would be nice if you copy-n-paste the output of these three tests into a reply here.

@jerodway
Copy link
Author

Well, initially I could not get the first command to work at all. After a bit of playing around with it, I sorted out that problem and then wslcompact seemed to just start working. Sorry for bothering you

@okibcn
Copy link
Owner

okibcn commented Feb 15, 2023

@Aldo-f , we can continue the conversation here from the duplicated issue #8. It seems you have the same problem @jerodway had. I ask you to do the same test. We need to know what is going on.

@jerodway, maybe you could help with the solution you found in your system.

Thanks.

@okibcn
Copy link
Owner

okibcn commented Feb 15, 2023

@Aldo-f , these are the lines compatible with your distro's name. Do you have any special user configuration within your Ubuntu? the Estimated size is provided by wsl, so it might be a configuration colliding with it. Do you have other distros installed and running at the same time? It shouldn't be a issue, but I need more data to know what is going on in your system.

Please try these two commands from PowerShell:

wsl --system -d Ubuntu-18.04 -e df /mnt/wslg/distro
wsl -d Ubuntu-18.04 -e df /

And this one from within a WSL shell session inside Ubuntu-18.04:

\df /

They should return the same text, but for some reason, in your case, it is behaving differently. It would be nice if you copy-n-paste the output of these three tests into a reply here. Please.

@Aldo-f
Copy link

Aldo-f commented Feb 16, 2023

Not aware of any special configuration.
Installed Lando with Hyperspace (so that installs docker, lando, ...)

Seems GUI support is disabled on host, don't know if that's a requirement.

I could however use wslcompact to reduce my ext4.vhdx from 15GB to 13GB. (many thanks ;) )
(had to use $env:TEMP="D:\tmp" 'cause I'm out of space on C: )

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

 Distro's name:  Ubuntu-18.04
 Image file:     C:\Users\aldo\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc\LocalState\ext4.vhdx
 Current size:   13479 MB
InvalidOperation: C:\Users\aldo\scoop\apps\wslcompact\current\wslcompact.ps1:79
Line |
  79 |  …             $estimated = ((wsl --system -d "$wsl_distro" -e df /mnt/w …
     |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Cannot index into a null array.
 Estimated size: 0 +/- 0 MB
 The estimated process time using an SSD is about 0 minutes.
> wsl --system -d Ubuntu-18.04 -e df /mnt/wslg/distro
GUI application support is disabled via C:\Users\aldo\.wslconfig or /etc/wsl.conf.
Error code: Wsl/Service/CreateInstance/WSL_E_GUI_APPLICATIONS_DISABLED
> wsl -d Ubuntu-18.04 -e df /
Filesystem      1K-blocks     Used Available Use% Mounted on
/dev/sdc       1055762868 13180200 988879196   2% /

Inside WSL

> \df /
Filesystem      1K-blocks     Used Available Use% Mounted on
/dev/sdc       1055762868 13180200 988879196   2% /
Details of my .wslconfig (GUI disabled)
# Settings apply across all Linux distros running on WSL 2
[wsl2]

# Limits VM memory to use no more than 4 GB, this can be set as whole numbers using GB or MB
memory=3GB 

# Sets the VM to use two virtual processors
# processors=2

# Specify a custom Linux kernel to use with your installed distros. The default kernel used can be found at https://github.com/microsoft/WSL2-Linux-Kernel
# kernel=C:\\temp\\myCustomKernel

# Sets additional kernel parameters, in this case enabling older Linux base images such as Centos 6
# kernelCommandLine = vsyscall=emulate

# Sets amount of swap storage space to 8GB, default is 25% of available RAM
swap=8GB

# Sets swapfile path location, default is %USERPROFILE%\AppData\Local\Temp\swap.vhdx
# swapfile=C:\\temp\\wsl-swap.vhdx

# Disable page reporting so WSL retains all allocated memory claimed from Windows and releases none back when free
# pageReporting=false

# Turn off default connection to bind WSL 2 localhost to Windows localhost
localhostforwarding=true

# Disables nested virtualization
nestedVirtualization=false

# Turns on output console showing contents of dmesg when opening a WSL 2 distro for debugging
debugConsole=false

# Disable use of GUI? 
guiApplications=false  # <------ this line

@okibcn
Copy link
Owner

okibcn commented Feb 16, 2023

Thanks!

Finally We know what is going on. With this info I am sure I will be able to solve the issue of size detection.

@okibcn
Copy link
Owner

okibcn commented Feb 16, 2023

Release 8.5 fixes the issue.

Thanks for helping with it.

@okibcn okibcn closed this as completed Feb 16, 2023
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

3 participants