How to check sbt version?

Sbt

Sbt Problem Overview


How do I check which version of sbt I'm running?

I have the bash file set up that uses sbt-launch.jar, and it works, but

$ sbt version

only shows the "project version" (0.1) and

$ sbt --version

does nothing.

Sbt Solutions


Solution 1 - Sbt

$ sbt sbtVersion

This prints the sbt version used in your current project, or if it is a multi-module project for each module.

$ sbt 'inspect sbtVersion'
[info] Set current project to jacek (in build file:/Users/jacek/)
[info] Setting: java.lang.String = 0.13.1
[info] Description:
[info] 	Provides the version of sbt.  This setting should be not be modified.
[info] Provided by:
[info] 	*/*:sbtVersion
[info] Defined at:
[info] 	(sbt.Defaults) Defaults.scala:68
[info] Delegates:
[info] 	*:sbtVersion
[info] 	{.}/*:sbtVersion
[info] 	*/*:sbtVersion
[info] Related:
[info] 	*/*:sbtVersion

You may also want to use sbt about that (copying Mark Harrah's comment):

> The about command was added recently to try to succinctly print the > most relevant information, including the sbt version.

Solution 2 - Sbt

sbt about then enter to get SBT version

enter image description here

Solution 3 - Sbt

Running the command, "sbt sbt-version" will simply output your current directory and the version number.

$ sbt sbt-version
[info] Set current project to spark (in build file:/home/morgan/code/spark/)
[info] 0.13.8
 

Solution 4 - Sbt

In SBT 0.13 and above, you can use the sbtVersion task (as pointed out by @steffen) or about command (as pointed out by @mark-harrah)

There's a difference how the sbtVersion task works in and outside a SBT project. When in a SBT project, sbtVersion displays the version of SBT used by the project and its subprojects.

$ sbt sbtVersion
[info] Loading global plugins from /Users/jacek/.sbt/0.13/plugins
[info] Updating {file:/Users/jacek/.sbt/0.13/plugins/}global-plugins...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.
[info] Loading project definition from /Users/jacek/oss/scalania/project
[info] Set current project to scalania (in build file:/Users/jacek/oss/scalania/)
[info] exercises/*:sbtVersion
[info] 	0.13.1-RC5
[info] scalania/*:sbtVersion
[info] 	0.13.1-RC5

It's set in project/build.properties:

jacek:~/oss/scalania
$ cat project/build.properties
sbt.version=0.13.1-RC5

The same task executed outside a SBT project shows the current version of the executable itself.

jacek:~
$ sbt sbtVersion
[info] Loading global plugins from /Users/jacek/.sbt/0.13/plugins
[info] Updating {file:/Users/jacek/.sbt/0.13/plugins/}global-plugins...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.
[info] Set current project to jacek (in build file:/Users/jacek/)
[info] 0.13.0

When you're outside, the about command seems to be a better fit as it shows the sbt version as well as Scala's and available plugins.

jacek:~
$ sbt about
[info] Loading global plugins from /Users/jacek/.sbt/0.13/plugins
[info] Set current project to jacek (in build file:/Users/jacek/)
[info] This is sbt 0.13.0
[info] The current project is {file:/Users/jacek/}jacek 0.1-SNAPSHOT
[info] The current project is built against Scala 2.10.2
[info] Available Plugins: com.typesafe.sbt.SbtGit, com.typesafe.sbt.SbtProguard, growl.GrowlingTests, org.sbtidea.SbtIdeaPlugin, com.timushev.sbt.updates.UpdatesPlugin
[info] sbt, sbt plugins, and build definitions are using Scala 2.10.2

You may want to run 'help about' to read its documentation:

jacek:~
$ sbt 'help about'
[info] Loading global plugins from /Users/jacek/.sbt/0.13/plugins
[info] Set current project to jacek (in build file:/Users/jacek/)
Displays basic information about sbt and the build.

For the sbtVersion setting, the inspect command can help.

$ sbt 'inspect sbtVersion'
[info] Loading global plugins from /Users/jacek/.sbt/0.13/plugins
[info] Set current project to jacek (in build file:/Users/jacek/)
[info] Setting: java.lang.String = 0.13.0
[info] Description:
[info] 	Provides the version of sbt.  This setting should be not be modified.
[info] Provided by:
[info] 	*/*:sbtVersion
[info] Defined at:
[info] 	(sbt.Defaults) Defaults.scala:67
[info] Delegates:
[info] 	*:sbtVersion
[info] 	{.}/*:sbtVersion
[info] 	*/*:sbtVersion
[info] Related:
[info] 	*/*:sbtVersion

The version setting that people seem to expect to inspect to know the SBT version is to set The version/revision of the current module.

$ sbt 'inspect version'
[info] Loading global plugins from /Users/jacek/.sbt/0.13/plugins
[info] Set current project to jacek (in build file:/Users/jacek/)
[info] Setting: java.lang.String = 0.1-SNAPSHOT
[info] Description:
[info] 	The version/revision of the current module.
[info] Provided by:
[info] 	*/*:version
[info] Defined at:
[info] 	(sbt.Defaults) Defaults.scala:102
[info] Reverse dependencies:
[info] 	*:projectId
[info] 	*:isSnapshot
[info] Delegates:
[info] 	*:version
[info] 	{.}/*:version
[info] 	*/*:version
[info] Related:
[info] 	*/*:version

When used in a SBT project the tasks/settings may show different outputs.

Solution 5 - Sbt

You can use sbt about

Example:
C:\Users\smala>sbt about
[info] Set current project to smala (in build file:/C:/Users/smala/)
[info] This is sbt 0.13.6
[info] The current project is {file:/C:/Users/smala/}smala 0.1-SNAPSHOT
[info] The current project is built against Scala 2.10.4
[info] Available Plugins: sbt.plugins.IvyPlugin, sbt.plugins.JvmPlugin,   sbt.plugins.CorePlugin, sbt.plugins.JUnitXmlReportPlugin
[info] sbt, sbt plugins, and build definitions are using Scala 2.10.4"

Solution 6 - Sbt

From within the sbt shell

sbt:venkat> about
[info] This is sbt 1.3.3
...

Solution 7 - Sbt

run sbt console then type sbtVersion to check sbt version, and scalaVersion for scala version

Solution 8 - Sbt

What happens when you run sbt from the command line might have changed a bit over the 9 years since the question was originally posted.

Today, you will always be interacting with at least two "versions":

  • the launcher script (e.g. /usr/local/bin/sbt) version.[1] Check with sbt --script-version.
  • the default SBT version (=sbt-launcher JAR version), decided primarily by the project SBT version (in project/build.properties), secondarily by the launcher script itself. Check with sbt --script-version (or sbtVersion in the SBT shell)

Fortunately, in most day-to-day scenarios, the project SBT version is the only one that you need to be aware of.


1 It used to be just java -jar sbt-launcher.jar, then there was/is sbt-extras/sbt (aka "rebel cut"), then there was the "official" sbt script but in a separate github project called sbt-launcher-packaging (now archived). Today, the default script sits in the root folder of the sbt/sbt GH project and is generally the only version you need to worry about.

Solution 9 - Sbt

Doing sbt sbt-version led to some error as

[error] Not a valid command: sbt-version (similar: writeSbtVersion, session)
[error] Not a valid project ID: sbt-version
[error] Expected ':'
[error] Not a valid key: sbt-version (similar: sbtVersion, version, sbtBinaryVersion)
[error] sbt-version
[error]            ^

As you can see the hint similar: sbtVersion, version, sbtBinaryVersion, all of them work but the correct one is generated by sbt sbtVersion

Solution 10 - Sbt

Recent versions of SBT finally support a standard --version flag!

$ sbt --version
sbt version in this project:    1.6.2
sbt script version: 1.6.2

(tested with 1.6+ but it seems that it exists since at least 1.3.3)

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
QuestionjpswainView Question on Stackoverflow
Solution 1 - SbtSteffenView Answer on Stackoverflow
Solution 2 - SbtPrasadView Answer on Stackoverflow
Solution 3 - SbtMorgan KenyonView Answer on Stackoverflow
Solution 4 - SbtJacek LaskowskiView Answer on Stackoverflow
Solution 5 - SbtSandeep MView Answer on Stackoverflow
Solution 6 - SbtVenkat KotraView Answer on Stackoverflow
Solution 7 - SbtAbdelwahed HouboubyView Answer on Stackoverflow
Solution 8 - SbtconnyView Answer on Stackoverflow
Solution 9 - SbtRamesh MaharjanView Answer on Stackoverflow
Solution 10 - SbtElectronWillView Answer on Stackoverflow