Installing sbt on Linux
Install sbt with
cs setup
Follow
Install
page, and install Scala using Coursier. This should install the latest stable version of
sbt
.
Installing from SDKMAN
To install both JDK and sbt, consider using
SDKMAN
.
$ sdk install java $(sdk list java | grep -o "\b8\.[0-9]*\.[0-9]*\-tem" | head -1)
$ sdk install sbt
Using Coursier or SDKMAN has two advantages.
-
They will install the official packaging by Eclipse Adoptium, as opposed to the
“mystery meat OpenJDK builds“
.
-
They will install
tgz
packaging of sbt that contains all JAR files. (DEB and RPM packages do not to save bandwidth)
Install JDK
You must first install a JDK. We recommend
Eclipse Adoptium Temurin JDK 8
,
JDK 11
, or
JDK 17
.
The details around the package names differ from one distribution to another. For example, Ubuntu xenial (16.04LTS) has
openjdk-8-jdk
. Redhat family calls it
java-1.8.0-openjdk-devel
.
Installing from a universal package
Download
ZIP
or
TGZ
package and expand it.
Ubuntu and other Debian-based distributions
DEB
package is officially supported by sbt.
Ubuntu and other Debian-based distributions use the DEB format, but usually you don’t install your software from a local DEB file. Instead they come with package managers both for the command line (e.g.
apt-get
,
aptitude
) or with a graphical user interface (e.g. Synaptic).
Run the following from the terminal to install
sbt
(You’ll need superuser privileges to do so, hence the
sudo
).
sudo apt-get update
sudo apt-get install apt-transport-https curl gnupg -yqq
echo "deb https://repo.scala-sbt.org/scalasbt/debian all main" | sudo tee /etc/apt/sources.list.d/sbt.list
echo "deb https://repo.scala-sbt.org/scalasbt/debian /" | sudo tee /etc/apt/sources.list.d/sbt_old.list
curl -sL "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x2EE0EA64E40A89B84B2DF73499E82A75642AC823" | sudo -H gpg --no-default-keyring --keyring gnupg-ring:/etc/apt/trusted.gpg.d/scalasbt-release.gpg --import
sudo chmod 644 /etc/apt/trusted.gpg.d/scalasbt-release.gpg
sudo apt-get update
sudo apt-get install sbt
Package managers will check a number of configured repositories for packages to offer for installation. You just have to add the repository to the places your package manager will check.
Once
sbt
is installed, you’ll be able to manage the package in
aptitude
or Synaptic after you updated their package cache. You should also be able to see the added repository at the bottom of the list in System Settings -> Software & Updates -> Other Software:
Note
: There have been reports about SSL error using Ubuntu:
Server access Error: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty url=https://repo1.maven.org/maven2/org/scala-sbt/sbt/1.1.0/sbt-1.1.0.pom
, which apparently stems from OpenJDK 9 using PKCS12 format for
/etc/ssl/certs/java/cacerts
cert-bug
. According to
https://stackoverflow.com/a/50103533/3827
it is fixed in Ubuntu Cosmic (18.10), but Ubuntu Bionic LTS (18.04) is still waiting for a release. See the answer for a workaround.
Note
:
sudo apt-key adv --keyserver hkps://keyserver.ubuntu.com:443 --recv 2EE0EA64E40A89B84B2DF73499E82A75642AC823
may not work on Ubuntu Bionic LTS (18.04) since it’s using a buggy GnuPG, so we are advising to use web API to download the public key in the above.
Red Hat Enterprise Linux and other RPM-based distributions
RPM
package is officially supported by sbt.
Red Hat Enterprise Linux and other RPM-based distributions use the RPM format.
Run the following from the terminal to install
sbt
(You’ll need superuser privileges to do so, hence the
sudo
).
# remove old Bintray repo file
sudo rm -f /etc/yum.repos.d/bintray-rpm.repo
curl -L https://www.scala-sbt.org/sbt-rpm.repo > sbt-rpm.repo
sudo mv sbt-rpm.repo /etc/yum.repos.d/
sudo yum install sbt
On Fedora (31 and above), use
sbt-rpm.repo
:
# remove old Bintray repo file
sudo rm -f /etc/yum.repos.d/bintray-rpm.repo
curl -L https://www.scala-sbt.org/sbt-rpm.repo > sbt-rpm.repo
sudo mv sbt-rpm.repo /etc/yum.repos.d/
sudo dnf install sbt
Note:
Please report any issues with these to the
project.
Gentoo
The official tree contains ebuilds for sbt. To install the latest available version do:
emerge dev-java/sbt