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.
[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
- Add the plugin to
project/plugins.sbt. - Enable it on the project if the plugin requires
enablePlugins. - Re-run the task.
// 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.
sbt 'set assembly / test := {}' clean assemblyHow to prevent it
- Enable required plugins in
project/plugins.sbtand commit it. - Quote compound sbt commands as a single shell argument.
- Run the exact CI sbt command locally before pushing.