sbt / sbt

sbt, the interactive build tool
https://scala-sbt.org
Apache License 2.0
4.81k stars 937 forks source link

Projects "successfully" initialize without plugins after de-caching. #5155

Open swaldman opened 5 years ago

swaldman commented 5 years ago

problem

Trying to move things to the 1.3.x series, I've sometimes had trouble getting plugin SNAPSHOTs to update as I republish them. (That may become a separate issue.)

Using the oldest, ugliest trick for circumventing a cache, I tried just deleting them from the Coursier cache.

Rather than forcing a reload of the plugins, the projects silently "succeed" at initializing, despite the absence of the plugin dependency. This doesn't seem like great behavior, as plug-in dependencies are real dependencies and builds may behave badly in ways users fail to anticipate if the plugins are not there.

steps

sbt version: 1.3.2

build.sbt:

name := "ghost-plugin"

project/build.properties

sbt.version=1.3.2

project/plugins.sbt

addSbtPlugin("com.orrsella" % "sbt-stats" % "1.0.7")

Then run sbt in the project...

$ sbt
[info] Loading settings for project global-plugins from dependency-graph.sbt,metals.sbt,gpg.sbt ...
[info] Loading global plugins from /Users/swaldman/.sbt/1.0/plugins
[info] Loading settings for project ghost-plugin-build from plugins.sbt ...
[info] Loading project definition from /Users/swaldman/tmp/ghost-plugin/project
[info] Loading settings for project ghost-plugin from build.sbt ...
[info] Set current project to ghost-plugin (in build file:/Users/swaldman/tmp/ghost-plugin/)
[info] sbt server started at local:///Users/swaldman/.sbt/1.0/server/1fae12c9df76ab1c13bb/sock
sbt:ghost-plugin> stats
[info] Code Statistics for project:
[info] Files
[info] - Total:      0 files
...

Hooray! But now...

$ rm -rf ~/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/orrsella/sbt-stats_2.12_1.0/1.0.7/
$ sbt
[info] Loading settings for project global-plugins from dependency-graph.sbt,metals.sbt,gpg.sbt ...
[info] Loading global plugins from /Users/swaldman/.sbt/1.0/plugins
[info] Loading settings for project ghost-plugin-build from plugins.sbt ...
[info] Loading project definition from /Users/swaldman/tmp/ghost-plugin/project
[info] Loading settings for project ghost-plugin from build.sbt ...
[info] Set current project to ghost-plugin (in build file:/Users/swaldman/tmp/ghost-plugin/)
[info] sbt server started at local:///Users/swaldman/.sbt/1.0/server/1fae12c9df76ab1c13bb/sock
sbt:ghost-plugin> stats
[error] Expected ';'
[error] Not a valid command: stats (similar: tasks, settings, set)
...

expectation

The build should notice that the plugin dependency is not in fact present, and either reload it or report a failure.

notes

A round of reload plugins / update / reload return cures the problem.

Adding to build.sbt an explicit enablePlugins(StatsPlugin) is a workaround, correctly forces the build to fail to initialize if the plugin is not present.

eed3si9n commented 5 years ago

@swaldman Thanks for the report. This looks like update task in the metabuild caches the result without checking for the still- existence of the JAR files. I wonder if this has always been the case or if it regressed at some point.