Published 2024-08-24.
Time to read: 1 minutes.
Mac and native Linux users can skip this lecture.
Attempting to work with Scala on native Windows is fraught with issues.
If you use Windows, and want to learn Scala, I strongly recommend that you install Windows Subsystem for Linux (WSL). Both WSL1 and WSL2 work just the same from a Scala programmer’s point of view. Wikipedia has a good overview.
WSL will use up to half of the available memory and all CPU/GPU cores.
If you are unsure which version of WSL to install, start with WSL1, which requires less CPU power; the upgrade to WSL2 is quick and easy.
New Linux installations, installed using the wsl --install
command, will be set to WSL 2 by default.
If you have a powerful computer, this is fine.
Otherwise, if your computer has less than 8GB RAM and 256GB storage, you should install WSL1.
Installing WSL1
Microsoft changed the default installation from WSL1 to WSL2 in 2022.
Wsl.exe
is used to install and manage WSL.
This is the help message:
$ wsl.exe --help Copyright (c) Microsoft Corporation. All rights reserved. For privacy information about this product please visit https://aka.ms/privacy.
Usage: wsl.exe [Argument] [Options...] [CommandLine]
Arguments for running Linux binaries:
If no command line is provided, wsl.exe launches the default shell.
--exec, -e <CommandLine> Execute the specified command without using the default Linux shell.
--shell-type <standard|login|none> Execute the specified command with the provided shell type.
-- Pass the remaining command line as-is.
Options: --cd <Directory> Sets the specified directory as the current working directory. If ~ is used the Linux user's home path will be used. If the path begins with a / character, it will be interpreted as an absolute Linux path. Otherwise, the value must be an absolute Windows path.
--distribution, -d <Distro> Run the specified distribution.
--user, -u <UserName> Run as the specified user.
--system Launches a shell for the system distribution.
Arguments for managing Windows Subsystem for Linux:
--help Display usage information.
--debug-shell Open a WSL2 debug shell for diagnostics purposes.
--install [Distro] [Options...] Install a Windows Subsystem for Linux distribution. For a list of valid distributions, use 'wsl.exe --list --online'.
Options: --no-launch, -n Do not launch the distribution after install.
--web-download Download the distribution from the internet instead of the Microsoft Store.
--no-distribution Only install the required optional components, does not install a distribution.
--enable-wsl1 Enable WSL1 support.
--manage <Distro> <Options...> Changes distro specific options.
Options: --set-sparse, -s <true|false> Set the vhdx of distro to be sparse, allowing disk space to be automatically reclaimed.
--mount <Disk> Attaches and mounts a physical or virtual disk in all WSL 2 distributions.
Options: --vhd Specifies that <Disk> refers to a virtual hard disk.
--bare Attach the disk to WSL2, but don't mount it.
--name <Name> Mount the disk using a custom name for the mountpoint.
--type <Type> Filesystem to use when mounting a disk, if not specified defaults to ext4.
--options <Options> Additional mount options.
--partition <Index> Index of the partition to mount, if not specified defaults to the whole disk.
--set-default-version <Version> Changes the default install version for new distributions.
--shutdown Immediately terminates all running distributions and the WSL 2 lightweight utility virtual machine.
--status Show the status of Windows Subsystem for Linux.
--unmount [Disk] Unmounts and detaches a disk from all WSL2 distributions. Unmounts and detaches all disks if called without argument.
--update Update the Windows Subsystem for Linux package.
Options: --pre-release Download a pre-release version if available.
--version, -v Display version information.
Arguments for managing distributions in Windows Subsystem for Linux:
--export <Distro> <FileName> [Options] Exports the distribution to a tar file. The filename can be - for stdout.
Options: --vhd Specifies that the distribution should be exported as a .vhdx file.
--import <Distro> <InstallLocation> <FileName> [Options] Imports the specified tar file as a new distribution. The filename can be - for stdin.
Options: --version <Version> Specifies the version to use for the new distribution.
--vhd Specifies that the provided file is a .vhdx file, not a tar file. This operation makes a copy of the .vhdx file at the specified install location.
--import-in-place <Distro> <FileName> Imports the specified .vhdx file as a new distribution. This virtual hard disk must be formatted with the ext4 filesystem type.
--list, -l [Options] Lists distributions.
Options: --all List all distributions, including distributions that are currently being installed or uninstalled.
--running List only distributions that are currently running.
--quiet, -q Only show distribution names.
--verbose, -v Show detailed information about all distributions.
--online, -o Displays a list of available distributions for install with 'wsl.exe --install'.
--set-default, -s <Distro> Sets the distribution as the default.
--set-version <Distro> <Version> Changes the version of the specified distribution.
--terminate, -t <Distro> Terminates the specified distribution.
--unregister <Distro> Unregisters the distribution and deletes the root filesystem.
To install WSL1, type:
$ wsl.exe --set-default-version 1
$ wsl.exe --install
© Copyright 1994-2024 Michael Slinn. All rights reserved.
If you would like to request to use this copyright-protected work in any manner,
please send an email.
This website was made using Jekyll and Mike Slinn’s Jekyll Plugins.