Install sbt on ubuntu

ScalaDebianUbuntu 12.04SbtDeb

Scala Problem Overview


I have installed sbt on Ubuntu.

:~/bin/sbt/bin$ ls
classes    sbt      sbt-launch.jar       target
jansi.jar  sbt.bat  sbt-launch-lib.bash  win-sbt

However, whenever I try to launch sbt (from the same directory where sbt is located) it does not work:

No command 'sbt' found, did you mean:
 Command 'skt' from package 'latex-sanskrit' (universe)
 Command 'sb2' from package 'scratchbox2' (universe)
 Command 'sbd' from package 'cluster-glue' (main)
 Command 'mbt' from package 'mbt' (universe)
 Command 'sbmt' from package 'atfs' (universe)
 Command 'lbt' from package 'lbt' (universe)
 Command 'st' from package 'suckless-tools' (universe)
 Command 'sb' from package 'lrzsz' (universe)

I am new to linux and I have no idea how to tackle this issue.

Scala Solutions


Solution 1 - Scala

The simplest way of installing SBT on ubuntu is the deb package provided by Typesafe.

Run the following shell commands:

  1. wget http://apt.typesafe.com/repo-deb-build-0002.deb
  2. sudo dpkg -i repo-deb-build-0002.deb
  3. sudo apt-get update
  4. sudo apt-get install sbt

And you're done !

Solution 2 - Scala

It seems like you installed a zip version of sbt, which is fine. But I suggest you install the native debian package if you are on Ubuntu. That is how I managed to install it on my Ubuntu 12.04. Check it out here: http://www.scala-sbt.org/release/docs/Installing-sbt-on-Linux.html Or simply directly download it from here.

Solution 3 - Scala

> No command sbt found

It's saying that sbt is not on your path. Try to run ./sbt from ~/bin/sbt/bin or wherever the sbt executable is to verify that it runs correctly. Also check that you have execute permissions on the sbt executable. If this works , then add ~/bin/sbt/bin to your path and sbt should run from anywhere.

See this question about adding a directory to your path.

To verify the path is set correctly use the which command on LINUX. The output will look something like this:

$ which sbt
/usr/bin/sbt

Lastly, to verify sbt is working try running sbt -help or likewise. The output with -help will look something like this:

$ sbt -help
Usage: sbt [options]

  -h | -help         print this message
  ...

Solution 4 - Scala

As an alternative approach, you can save the SBT Extras script to a file called sbt.sh and set the permission to executable. Then add this file to your path, or just put it under your ~/bin directory.

The bonus here, is that it will download and use the correct version of SBT depending on your project properties. This is a nice convenience if you tend to compile open source projects that you pull from GitHub and other.

Solution 5 - Scala

My guess is that the directory ~/bin/sbt/bin is not in your PATH.

To execute programs or scripts that are in the current directory you need to prefix the command with ./, as in:

./sbt

This is a security feature in linux, so to prevent overriding of system commands (and other programs) by a malicious party dropping a file in your home directory (for example). Imagine a script called 'ls' that emails your /etc/passwd file to 3rd party before executing the ls command... Or one that executes 'rm -rf .'...

That said, unless you need something specific from the latest source code, you're best off doing what paradigmatic said in his post, and install it from the Typesafe repository.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionNoIdeaHowToFixThisView Question on Stackoverflow
Solution 1 - ScalaparadigmaticView Answer on Stackoverflow
Solution 2 - ScalaLiang ZhouView Answer on Stackoverflow
Solution 3 - ScalaBrianView Answer on Stackoverflow
Solution 4 - ScalaJackView Answer on Stackoverflow
Solution 5 - ScalaBarney GovanView Answer on Stackoverflow