Quick start
If you install Scala 3.5.0 or newer on your machine, you can use Scala CLI under the scala
command.
For Scala 3 installation instructions refer here.
Note that even when installing the latest Scala 3 version, its scala
command may refer to an older Scala CLI version.
For the latest stable Scala CLI release it usually is necessary to install it separately.
Pick the installation method:
- Windows
- MacOs
- Linux
- BSD
- Manual
- Apt
- Deb
- Yum
- Rpm
- Alpine
- Nix
- SDKMAN
Download the launcher from GitHub release assets with
curl -fL https://github.com/Virtuslab/scala-cli/releases/latest/download/scala-cli-x86_64-pc-linux.gz | gzip -d > scala-cli
chmod +x scala-cli
sudo mv scala-cli /usr/local/bin/scala-cli
Check that it runs fine by running its version
command:
scala-cli version
Scala CLI can be installed via apt packager tool.
curl -sS "https://virtuslab.github.io/scala-cli-packages/KEY.gpg" | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/scala-cli.gpg 2>/dev/null
sudo curl -s --compressed -o /etc/apt/sources.list.d/scala_cli_packages.list "https://virtuslab.github.io/scala-cli-packages/debian/scala_cli_packages.list"
sudo apt update
sudo apt install scala-cli
The Debian package can be downloaded at this address.
Alternatively, you can download it and install it manually with:
curl -fLo scala-cli.deb https://github.com/Virtuslab/scala-cli/releases/latest/download/scala-cli-x86_64-pc-linux.deb
sudo dpkg -i scala-cli.deb
Scala CLI can be installed via yum packager tool.
cat << EOF | sudo tee /etc/yum.repos.d/virtuslab.repo
[virtuslab-repo]
name=VirtusLab Repo
baseurl=https://virtuslab.github.io/scala-cli-packages/CentOS/Packages
enabled=1
gpgcheck=1
gpgkey=https://virtuslab.github.io/scala-cli-packages/KEY.gpg
EOF
sudo yum repo-pkgs virtuslab-repo list
sudo yum install scala-cli
The RPM package can be downloaded at this address.
Alternatively, you can download it and install it manually with:
curl -fLo scala-cli.rpm https://github.com/Virtuslab/scala-cli/releases/latest/download/scala-cli-x86_64-pc-linux.rpm
sudo rpm -i scala-cli.rpm
Download the launcher from GitHub release assets with
wget -q -O scala-cli.gz https://github.com/Virtuslab/scala-cli/releases/latest/download/scala-cli-x86_64-pc-linux-static.gz && gunzip scala-cli.gz
chmod +x scala-cli
mv scala-cli /usr/bin/
Check that it runs fine by running its version
command:
scala-cli version
This method is provided and supported by the community, not the core team of Scala CLI
Scala CLI can be installed with Nix with
nix-env -iA nixpkgs.scala-cli
Scala CLI can be installed via SDKMAN with
sdk install scalacli
- Manual
- Installer
- SDKMAN
- Chocolatey
- Scoop
- WinGet
Note that the Windows manual installation requires Visual C++ redistributable to be installed. See below for how to install it.
Download the launcher from GitHub release assets with
curl -fLo scala-cli.zip https://github.com/Virtuslab/scala-cli/releases/latest/download/scala-cli-x86_64-pc-win32.zip
jar -xf scala-cli.zip
Check that it runs fine by running its version
command:
scala-cli version
If you get an error about MSVCR100.dll
being missing, you have to install
Visual C++ redistributable. A valid version is distributed with the Scala CLI launchers.
You can download it here,
and install it by double-clicking on it. Once the Visual C++ redistributable runtime is installed,
check that the Scala CLI runs fine by running its version
command:
scala-cli version
Note that the commands above don't put the scala-cli
command in the PATH
. For that, you can create a directory, move the
launcher there, and add the directory to the PATH
with
md "%USERPROFILE%/scala-cli"
scala-cli add-path "%USERPROFILE%/scala-cli"
move scala-cli.exe "%USERPROFILE%/scala-cli"
Download MSI installer with Scala CLI for Windows
Scala CLI can be installed via SDKMAN with
sdk install scalacli
To install Scala CLI via Chocolatey, run the following command from the command line or from PowerShell:
choco install scala-cli
Third-party Chocolatey packages may not provide the latest version.
To install Scala CLI via Scoop, run the following command from the command line or from PowerShell:
scoop install scala-cli
To install Scala CLI via WinGet, run the following command from the command line or from PowerShell:
winget install virtuslab.scalacli
- Manual
- Installer
- Brew
- Nix
- SDKMAN
For a Mac with the arm64 architecture run the following commands:
curl -fL https://github.com/Virtuslab/scala-cli/releases/latest/download/scala-cli-aarch64-apple-darwin.gz | gzip -d > scala-cli
chmod +x scala-cli
mv scala-cli /usr/local/bin/scala-cli
Otherwise, for a Mac with non-arm64 architecture (pre-M1) run the following commands:
curl -fL https://github.com/Virtuslab/scala-cli/releases/latest/download/scala-cli-x86_64-apple-darwin.gz | gzip -d > scala-cli
chmod +x scala-cli
mv scala-cli /usr/local/bin/scala-cli
Check that it runs fine by running its version
command:
scala-cli version
Download the PKG installer with Scala CLI for MacOS
Once downloaded, right-click on the downloaded file from Finder and then choose "Open".
Scala CLI can be installed via homebrew with
brew install Virtuslab/scala-cli/scala-cli
This method is provided and supported by the community, not the core team of Scala CLI
Scala CLI can be installed via Nix with:
nix-env -iA nixpkgs.scala-cli
Scala CLI can be installed via SDKMAN with
sdk install scalacli
- Manual
FreeBSD support (and support for other BSDs) is currently experimental and not stable. Scala CLI is not being distributed for FreeBSD, but you can install it via Coursier's standalone JAR.
Before running Coursier and installing Scala CLI, make sure you have Java 17 or higher installed and in your $PATH:
pkg install openjdk17
Note: Java 17 has to be installed manually on BSD systems at this time.
Download Coursier via the Any JAR option.
After downloading Coursier, you can use it to install Scala CLI:
chmod +x coursier
./coursier install scala-cli
Scala CLI is now installed on your system. It is installed as a JAR rather than a native binary, and so the startup time is slightly longer.
To run scala-cli anywhere on your system, you need to add its binary path to the $PATH variable. For a given user-directory:
export PATH="$PATH:/home/user-directory/.local/share/coursier/bin"
Add this command to your shell's RC file to make the setting permanent.
Depending on the Java distribution you are using, it has been observed that Bloop (the build server used by Scala CLI) may have trouble starting on FreeBSD. You may try to customise Bloop JVM options with the BLOOP_JAVA_OPTS
environment variable. Alternatively, you may skip using the build server altogether and use the compiler directly by passing the --server=false
option. Please note that doing this will noticably extend project build times.
scala-cli run -e 'println("Hello FreeBSD")' --server=false
Any features relying on third-party JVMs (such as --jvm
and package --native-image
) may not work on FreeBSD, as those JVMs may not have BSD distributions provided. They may be made to work when a compatible JVM path is provided directly (refer to individual sub-commands' --help
).
Script to automatically download and cache standalone scala-cli
launcher.
- macOS/Linux
- Windows
In certain restricted environments, jar files may only be accessible through Nexus or a specific Artifactory, making it cumbersome to manually load each dependency and construct the classpath. To simplify this process, run the bootstrapped Scala CLI standalone fat jar using Coursier, follow the command below:
cs launch org.virtuslab.scala-cli:cliBootstrapped:latest.release -M scala.cli.ScalaCli
Alternatively, you can directly download it from the Maven repository here.
Try the completions with
- Bash
- zsh
- fish
eval "$(scala-cli install completions --env --shell bash)"
scala-cli --<TAB>
eval "$(scala-cli install completions --env --shell zsh)"
scala-cli --<TAB>
eval "$(scala-cli install completions --env --shell fish)"
fish
scala-cli --<TAB>
Install them on your system with
scala-cli install completions
If any of the scala-cli install completions
command complained that your shell cannot be determined, specify it
with --shell
- Bash
- zsh
- fish
scala-cli install completions --shell bash
scala-cli install completions --shell zsh
scala-cli install completions --shell fish
To run Scala.js applications Node.js needs to be installed. Scala CLI at this moment does not manage Node.js however it may change in the future.
Clang is required to compile and run Scala Native applications. Using some functionalities known from JDK (like using java.util.zip
package) require additional packages to be installed.
Scala Native page contains detailed installation guide.
Pick the uninstallation method:
- Windows
- MacOs
- Linux
- Installation script
- Manual
- Apt
- Deb
- Yum
- Rpm
- Alpine
If Scala CLI was installed via the installation script, you can uninstall it with:
scala-cli uninstall
If you have installed Scala CLI completions into your shell, uninstall
command uninstalls them by running uninstall-completions
command under the hood.
If Scala CLI was installed manually you can uninstall it with:
rm /usr/local/bin/scala-cli
If Scala CLI was installed via apt you can uninstall it with:
sudo apt purge scala-cli
If Scala CLI was installed via dpkg you can uninstall it with:
sudo dpkg --remove scala-cli
If Scala CLI was installed via yum you can uninstall it with:
yum remove scala-cli
If Scala CLI was installed via rpm you can uninstall it with:
rpm -e scala-cli
For Alpine Linux you can uninstall scala-cli with:
rm /usr/bin/scala-cli
- Manual
- Installer
- Chocolatey
If Scala CLI was installed manually you can uninstall it with:
rmdir "%USERPROFILE%/scala-cli"
If Scala CLI was installed via the installer, you can uninstall it in the Control Panel.
To uninstall Scala CLI via Chocolatey, run the following command from the command line or from PowerShell:
choco uninstall scala-cli
- Installation script
- Manual
- Brew
If Scala CLI was installed via the installation script, you can uninstall it with:
scala-cli uninstall
If you have installed Scala CLI completions into your shell, uninstall
command uninstalls them by running uninstall-completions
command under the hood.
If Scala CLI was installed manually you can uninstall it with:
rm /usr/local/bin/scala-cli
If Scala CLI was installed via homebrew you can uninstall it with:
brew uninstall scala-cli