DEV Community

Yulin
Yulin

Posted on

WSL Error: no space left on device

Are you running Ubuntu or some kind of Linux distribution inside of Windows Operating System, and all of a sudden you're getting the error while you are on your code editor



nospc ENOSPC: no space left on device


Enter fullscreen mode Exit fullscreen mode

Your code editor, let's say VS Code server, won't connect to WSL anymore and you're stuck with local changes you haven't yet commit to Github.

Run wsl df -h / in your Powershell and you shall see that the assigned virtual hard disk for your Linux distribution has reached 100% - it is time to expand the allowed space for file storage within the Linux environment. Learn to manage WSL disk space and resize virtual hard disk here.

After you have expanded the virtual disk for the Linux distribution following the link above, when you are attempting to spawn VS Code from WSL using code ., you could encounter a module not found error if your VS Code closed unexpectedly as a downstream consequence of the no space left inside your WSL instance, an example of such error is



Loading "minimist" failed
Error: Cannot find module 'minimist'


Enter fullscreen mode Exit fullscreen mode

Image description

The reason for this error could be that the remote WSL connection was closed off and killed the VS Code server on WSL, and then the module is removed/corrupted on the remote host.

You should first try to reboot and shutdown all wsl instances using wsl --shutdown. If none of that worked, you can delete the .vscode-server folder entirely in your WSL home directory, and then spawn VS Code from a WSL prompt as usual using code . to initiate a reinstallation of the VS Code remote.

Be aware that the deletion of .vscode-server folder will remove all your extensions as well, so it's better to keep a backup of the extensions before you remove the .vscode-server folder



mv ~/.vscode-server/extensions ~/.vscode-server-backup/extensions


Enter fullscreen mode Exit fullscreen mode


rm -rf ~/.vscode-server


Enter fullscreen mode Exit fullscreen mode

VS Code should now open up successfully from WSL, close it off so we can recover the extensions with the following commands.

Remove the new automatically created extensions folder:



rm -rf ~/.vscode-server/extensions


Enter fullscreen mode Exit fullscreen mode

and copy over the backed up extensions:



mv ~/.vscode-server-backup/extensions ~/.vscode-server/extensions


Enter fullscreen mode Exit fullscreen mode

Now if you start up VS Code again, it should connect and work as well as before.

Top comments (0)