scala: command not found
scala: command not found
DodaTech
2 min read
The “scala: command not found” error means your shell cannot locate the scala runner or scalac compiler binaries needed to compile Scala code.
What It Means
Scala provides two main command-line tools: scala for running compiled classes and scripts, and scalac for compiling .scala source files into JVM bytecode. Both are distributed with the Scala compiler installation. When neither is found in your PATH, the shell returns “command not found.”
Why It Happens
- Scala is not installed on your system.
- Coursier (the recommended Launcher) installed Scala but did not update your PATH.
- SDKMAN installed Scala but the terminal session wasn’t reloaded.
- The Scala binary directory is not in your
PATHenvironment variable. - You installed Scala via a package manager that puts binaries in a non-standard location.
- The installation was interrupted or incomplete.
How to Fix It
1. Install Scala via Coursier (recommended)
Coursier is the standard Scala installer. It manages both the JVM and Scala versions:
# Install Coursier
curl -fL https://github.com/coursier/coursier/releases/latest/download/cs-x86_64-pc-linux.gz | gzip -d > cs
chmod +x cs
./cs setup
# This installs Scala, sbt, and updates ~/.profile
# Then reload your shell:
source ~/.profile
# Verify
scala -version
# Output: Scala code runner version 3.5.02. Install Scala via SDKMAN
# Install SDKMAN
curl -s https://get.sdkman.io | bash
source "$HOME/.sdkman/bin/sdkman-init.sh"
# Install Scala
sdk install scala
# Verify
scala -version3. Install Scala via sbt launcher
If you already have sbt, it can download Scala for you:
# sbt automatically downloads the Scala version specified in build.sbt
echo 'scalaVersion := "3.5.0"' > build.sbt
sbt compile4. Manually add Scala to your PATH
If Scala is installed but not found:
# For Coursier installation
export PATH="$PATH:$HOME/.local/share/coursier/bin"
# For SDKMAN
export PATH="$PATH:$HOME/.sdkman/candidates/scala/current/bin"
# Add the appropriate line to ~/.bashrc or ~/.zshrc5. Verify Java is installed
Scala runs on the JVM. Ensure JDK 11+ is available:
java -version
# If not found, install a JDK:
# Via Coursier: cs install java
# Via SDKMAN: sdk install java Previous
Redis: Could not connect to Redis at 127.0.0.1:6379: Connection refused
Next
SSL: certificate verify failed (unable to get local issuer certificate)
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro