Skip to content
Latchkey

sbt "Not a valid command" / "Not a valid key" in CI

sbt parsed your invocation and the command or key you typed is not defined in this build. Either a plugin that provides it is not enabled, or the CI command line has a typo or bad quoting.

What this error means

sbt exits with "[error] Not a valid command: X" or "[error] Not a valid key: X (similar: ...)" when a CI step runs an sbt task.

sbt
[error] Not a valid command: assembly
[error] Not a valid project ID: assembly
[error] Expected ':'
[error] Not a valid key: assembly (similar: assemblyJarName, aggregate)

Common causes

A plugin that defines the task is not enabled

Tasks like assembly or scalafmtCheck come from plugins; without the plugin in project/plugins.sbt (and enabled) sbt does not know the key.

A typo or bad quoting in the CI command

A misspelled task or shell quoting that splits a compound sbt command makes sbt parse an invalid command.

How to fix it

Enable the plugin that provides the task

  1. Add the plugin to project/plugins.sbt.
  2. Enable it on the project if the plugin requires enablePlugins.
  3. Re-run the task.
project/plugins.sbt
// project/plugins.sbt
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "2.2.0")

Quote compound commands correctly in CI

Wrap multi-word sbt invocations in single quotes so the shell passes them as one argument.

Terminal
sbt 'set assembly / test := {}' clean assembly

How to prevent it

  • Enable required plugins in project/plugins.sbt and commit it.
  • Quote compound sbt commands as a single shell argument.
  • Run the exact CI sbt command locally before pushing.

Frequently asked questions

What causes ""Not a valid command" / "Not a valid key""?
Tasks like assembly or scalafmtCheck come from plugins; without the plugin in project/plugins.sbt (and enabled) sbt does not know the key.
How do I fix "Not a valid command" / "Not a valid key"?
Enable the plugin that provides the task

Related guides

References

Run this faster and cheaper on Latchkey managed runners - self-healing included. Start free → 30-day trial · No credit card