64

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.

jopasserat
  • 5,721
  • 4
  • 31
  • 50
NoIdeaHowToFixThis
  • 4,484
  • 2
  • 34
  • 69
  • 1
    to execute a file in the current directory you have to write a "./" in front of the name, or else it will try to search for the executables inside the classpath. So to do that in particular you should have typed "./sbt". That's what was going wrong here, however it's obviously best to follow the other answers below and actually install it. – leinaD_natipaC Dec 11 '13 at 18:06
  • 12
    I don't see any reason to close this question. sbt is very useful programming tool for scala and maybe it fits the StackOverflow rules. – Daniel Cukier Feb 17 '14 at 14:09
  • 7
    Who made the decision to close this question?? Why do you not first consider what would be the alternatives. Superuser is *not* the place. `sbt` does not belong there. This is the correct place - and I am among the persons interested in this question/answer. I am a server side programmer is that not "on topic" enough? – WestCoastProjects Feb 20 '16 at 22:29
  • 5
    This is ridiculous that this question is closed. SBT is a tool for programming. – Ivan -Oats- Storck Nov 02 '16 at 17:17
  • 2
    Official instructions on installing for Linux are here: https://www.scala-sbt.org/1.x/docs/Installing-sbt-on-Linux.html – MichaelChirico Nov 24 '18 at 13:27

5 Answers5

162

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 !

Andrii Abramov
  • 10,019
  • 9
  • 74
  • 96
paradigmatic
  • 40,153
  • 18
  • 88
  • 147
  • 6
    Works great! But than I get: "Detected sbt version 0.12.2 Cannot find sbt launcher 0.12.2 Please download: From http://typesafe.artifactoryonline.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/0.12.2/sbt-launch.jar To /home/leo/.sbt/.lib/0.12.2/sbt-launch.jar" So it's already written what do do. But here for your reference: " mkdir -p /home/leo/.sbt/.lib/0.12.2/ wget -O /home/leo/.sbt/.lib/0.12.2/sbt-launch.jar http://typesafe.artifactoryonline.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/0.12.2/sbt-launch.jar" – leo Jun 14 '13 at 08:40
  • @leo Thanks for the addition. I won't add it to the answer because it's not specific to the question, but it is relevant for all sbt installation using the same `sbt` script. – paradigmatic Jun 14 '13 at 16:32
  • what the version of sbt is it? – Alan Coromano Sep 01 '13 at 16:37
  • 1
    @MariusKavansky It installs just a script which allows to run every version of sbt. You'll have to at specify which version you want to use in the file `project/build.properties`. Then you run `sbt` and the script will kick the launcher. Follow the instructions that will appear. – paradigmatic Oct 20 '13 at 14:08
  • 2
    @RémiM As I answered in the comments above, once you use the method I described to install an sbt launcher, you can choose the actual SBT version in the `project/build.properties` file. I am currently using SBT 13.6 with the proposed method without any trouble. – paradigmatic Oct 21 '14 at 17:26
  • 2
    That just installed a very old sbt 0.11.3. Any idea how to install the newest? – Ivan Balashov Feb 24 '16 at 15:55
  • Just follow the instructions on the accepted answer, that one installs the latest version. – Daniel Zolnai Mar 07 '16 at 10:29
  • @IvanBalashov this installed 0.13.13 for me – blue-sky Nov 15 '16 at 13:25
  • ```Reading package lists... Done W: GPG error: http://apt.typesafe.com unicorn InRelease: The following signatures were invalid: D2E3915347209000FA1C06D47CF8D72BE29DF322 E: The repository 'http://apt.typesafe.com unicorn InRelease' is not signed. N: Updating from such a repository can't be done securely, and is therefore disabled by default. N: See apt-secure(8) manpage for repository creation and user configuration details. ``` – Thomas Modeneis Mar 23 '18 at 08:40
  • 1
    I worked according to https://www.scala-sbt.org/1.0/docs/Installing-sbt-on-Linux.html – liam xu Sep 10 '18 at 12:48
  • This is dangerous. You should never install packages downloaded through http without checking the signatures or checksums through with ones downloaded through encrypted channel. – styrofoam fly Sep 17 '18 at 18:31
45

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.

Liang Zhou
  • 2,055
  • 19
  • 20
  • Yes, the problem was due to the fact that I have installed a zip version and the installation files were somehow "broken". – NoIdeaHowToFixThis May 19 '13 at 18:56
  • 1
    FYI: link is broken. Should be this: http://dl.bintray.com/sbt/debian/ I think. – Yuchen May 30 '17 at 03:11
  • 1
    You can also install sbt by writing the following commands if regular apt-get isn't working: wget https://dl.bintray.com/sbt/debian/sbt-0.13.15.deb sudo dpkg -i path/to/sbt.deb sudo apt-get install -f – Tom Piaggio Jan 07 '19 at 13:18
13

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
  ...
Community
  • 1
  • 1
Brian
  • 20,195
  • 6
  • 34
  • 55
4

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.

Jack
  • 16,506
  • 19
  • 100
  • 167
4

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.

Barney Govan
  • 644
  • 4
  • 5