sbt / sbt-projectmatrix

MIT License
124 stars 14 forks source link

Can't load project? #72

Closed dvgica closed 2 years ago

dvgica commented 2 years ago

Hi, apologies for the probably stupid "issue", but I've run rather stuck.

I have a fairly complex (17 sub-projects) build with a mix of Scala 2.12 and 2.13. Most sub-projects are 2.12, and I've set ThisBuild / scalaVersion := scala212Version in build.sbt. There are a number of plugins already loaded as well. SBT version is 1.5.8 and sbt-projectmatrix is 0.9.0 (I tried with 0.8.0 as well).

After converting all sub-projects to use projectMatrix, I'm unable to load the project. Any pointers anyone can give would be much appreciated. Here's the full error log:

[warn] Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore? (default: r)
[debug] > Exec(reload, None, None)
[debug] > Exec(sbtStashOnFailure, None, None)
[debug] > Exec(onFailure loadFailed, None, None)
[debug] > Exec(loadp, None, None)
[info] welcome to sbt 1.5.8 (AdoptOpenJDK Java 1.8.0_242)
[debug]                               Load.loadUnit: plugins took 8.560204ms
[debug]                               Load.loadUnit: defsScala took 0.003998ms
[debug] [Loading] Scanning directory /home/dvg/.sbt/1.0/plugins
[debug]                                 Load.loadUnit: mkEval took 0.152548ms
[debug] [Loading] Found non-root projects 
[debug] [Loading] Done in /home/dvg/.sbt/1.0/plugins, returning: ()
[debug] deducing auto plugins based on known facts Set(Atom(sbt.plugins.CorePlugin)) and clauses Clauses(Clause(Atom(sbt.plugins.JvmPlugin),Set(Atom(sbt.plugins.IvyPlugin)))
[debug] Clause(Atom(sbt.ScriptedPlugin),Set(Atom(sbt.plugins.JvmPlugin)))
[debug] Clause(Atom(sbt.plugins.SbtPlugin),Set(Atom(sbt.ScriptedPlugin)))
[debug] Clause(Atom(sbt.plugins.SemanticdbPlugin),Set(Atom(sbt.plugins.JvmPlugin)))
[debug] Clause(Atom(sbt.plugins.JUnitXmlReportPlugin),Set(Atom(sbt.plugins.JvmPlugin)))
[debug] Clause(Atom(sbt.plugins.MiniDependencyTreePlugin),Set(Atom(sbt.plugins.JvmPlugin)))
[debug] Clause(Atom(sbt.plugins.CorePlugin),Set(Atom(sbt.plugins.IvyPlugin)))
[debug] Clause(Atom(sbt.plugins.IvyPlugin),Set(Atom(sbt.plugins.JvmPlugin)))
[debug] Clause(Atom(sbt.plugins.JvmPlugin),Set(Atom(sbt.plugins.SemanticdbPlugin)))
[debug] Clause(Atom(sbt.plugins.JvmPlugin),Set(Atom(sbt.plugins.JUnitXmlReportPlugin)))
[debug] Clause(Atom(sbt.plugins.CorePlugin),Set(Atom(sbt.plugins.Giter8TemplatePlugin)))
[debug] Clause(Atom(sbt.plugins.JvmPlugin),Set(Atom(sbt.plugins.MiniDependencyTreePlugin))))
[debug]   :: deduced result: Matched(sbt.plugins.CorePlugin,sbt.plugins.Giter8TemplatePlugin,sbt.plugins.IvyPlugin,sbt.plugins.JvmPlugin,sbt.plugins.MiniDependencyTreePlugin,sbt.plugins.JUnitXmlReportPlugin,sbt.plugins.SemanticdbPlugin)
[debug] Plugins.deducer#function took 0.809793 ms
[info] loading settings for project global-plugins from global-config.sbt ...
[debug]                                   Load.resolveProject(global-plugins) took 1.331664ms
[debug]                                 Load.loadTransitive: finalizeProject(Project(id global-plugins, base: /home/dvg/.sbt/1.0/plugins, plugins: List(<none>))) took 2.440397ms
[debug] [Loading] Done in /home/dvg/.sbt/1.0/plugins, returning: (global-plugins)
[debug]                               Load.loadUnit: loadedProjectsRaw took 7.335858ms
[debug]                               Load.loadUnit: cleanEvalClasses took 0.454889ms
[debug]                             Load.loadUnit(file:/home/dvg/.sbt/1.0/plugins/, ...) took 16.768054ms
[debug]                           Load.apply: load took 17.618033ms
[debug]                           Load.apply: resolveProjects took 0.160392ms
[debug]                           Load.apply: finalTransforms took 5.204949ms
[debug]                           Load.apply: config.delegates took 0.521487ms
[debug]                           Load.apply: Def.make(settings)... took 64.649389ms
[debug]                           Load.apply: structureIndex took 10.236073ms
[debug]                           Load.apply: mkStreams took 0.003111ms
[info] loading global plugins from /home/dvg/.sbt/1.0/plugins
[debug] Running task... Cancel: Signal, check cycles: false, forcegc: true
[debug]                         Load.defaultLoad until apply took 192.188905ms
[debug]                                   Load.loadUnit: plugins took 8.148465ms
[debug]                                   Load.loadUnit: defsScala took 0.005545ms
[debug] [Loading] Scanning directory /home/dvg/projects/thingy/project
[debug]                                     Load.loadUnit: mkEval took 0.142381ms
[debug] [Loading] Found non-root projects 
[debug] [Loading] Done in /home/dvg/projects/thingy/project, returning: ()
[debug] deducing auto plugins based on known facts Set(Atom(sbt.plugins.CorePlugin)) and clauses Clauses(Clause(Atom(sbt.plugins.JvmPlugin),Set(Atom(sbt.plugins.IvyPlugin)))
[debug] Clause(Atom(sbt.ScriptedPlugin),Set(Atom(sbt.plugins.JvmPlugin)))
[debug] Clause(Atom(sbt.plugins.SbtPlugin),Set(Atom(sbt.ScriptedPlugin)))
[debug] Clause(Atom(sbt.plugins.SemanticdbPlugin),Set(Atom(sbt.plugins.JvmPlugin)))
[debug] Clause(Atom(sbt.plugins.JUnitXmlReportPlugin),Set(Atom(sbt.plugins.JvmPlugin)))
[debug] Clause(Atom(sbt.plugins.MiniDependencyTreePlugin),Set(Atom(sbt.plugins.JvmPlugin)))
[debug] Clause(Atom(sbt.plugins.CorePlugin),Set(Atom(sbt.plugins.IvyPlugin)))
[debug] Clause(Atom(sbt.plugins.IvyPlugin),Set(Atom(sbt.plugins.JvmPlugin)))
[debug] Clause(Atom(sbt.plugins.JvmPlugin),Set(Atom(sbt.plugins.SemanticdbPlugin)))
[debug] Clause(Atom(sbt.plugins.JvmPlugin),Set(Atom(sbt.plugins.JUnitXmlReportPlugin)))
[debug] Clause(Atom(sbt.plugins.CorePlugin),Set(Atom(sbt.plugins.Giter8TemplatePlugin)))
[debug] Clause(Atom(sbt.plugins.JvmPlugin),Set(Atom(sbt.plugins.MiniDependencyTreePlugin))))
[debug]   :: deduced result: Matched(sbt.plugins.CorePlugin,sbt.plugins.Giter8TemplatePlugin,sbt.plugins.IvyPlugin,sbt.plugins.JvmPlugin,sbt.plugins.MiniDependencyTreePlugin,sbt.plugins.JUnitXmlReportPlugin,sbt.plugins.SemanticdbPlugin)
[debug] Plugins.deducer#function took 0.629298 ms
[info] loading settings for project thingy-build from build.sbt,plugins.sbt ...
[debug]                                       Load.resolveProject(thingy-build) took 0.88762ms
[debug]                                     Load.loadTransitive: finalizeProject(Project(id thingy-build, base: /home/dvg/projects/thingy/project, plugins: List(<none>))) took 1.785247ms
[debug] [Loading] Done in /home/dvg/projects/thingy/project, returning: (thingy-build)
[debug]                                   Load.loadUnit: loadedProjectsRaw took 131.862921ms
[debug]                                   Load.loadUnit: cleanEvalClasses took 1.363436ms
[debug]                                 Load.loadUnit(file:/home/dvg/projects/thingy/project/, ...) took 141.758413ms
[debug]                               Load.apply: load took 142.263742ms
[debug]                               Load.apply: resolveProjects took 0.082505ms
[debug]                               Load.apply: finalTransforms took 3.881884ms
[debug]                               Load.apply: config.delegates took 0.217893ms
[debug]                               Load.apply: Def.make(settings)... took 34.457463ms
[debug]                               Load.apply: structureIndex took 9.4953ms
[debug]                               Load.apply: mkStreams took 0.002996ms
[info] loading project definition from /home/dvg/projects/thingy/project
[debug] Running task... Cancel: Signal, check cycles: false, forcegc: true
[debug]                             Load.loadUnit: plugins took 971.738485ms
[debug]                             Load.loadUnit: defsScala took 0.00186ms
[debug] [Loading] Scanning directory /home/dvg/projects/thingy
[debug]                               Load.loadUnit: mkEval took 0.170795ms
[error] java.lang.RuntimeException: no rows were found in project matching ProjectRow(true, List(PlatformAxis(jvm,JVM,jvm), ScalaVersionAxis(2.12.12,2.12))): List(ProjectRow(true, List(PlatformAxis(jvm,JVM,jvm), ScalaVersionAxis(2.13.8,2.13))))
[error]         at scala.sys.package$.error(package.scala:30)
[error]         at sbt.internal.ProjectMatrix$ProjectMatrixDef.resolveMatch(ProjectMatrix.scala:331)
[error]         at sbt.internal.ProjectMatrix$ProjectMatrixDef.resolveMatrixDependency(ProjectMatrix.scala:323)
[error]         at sbt.internal.ProjectMatrix$ProjectMatrixDef.$anonfun$resolveMappings$7(ProjectMatrix.scala:242)
[error]         at scala.collection.immutable.List.map(List.scala:297)
[error]         at sbt.internal.ProjectMatrix$ProjectMatrixDef.$anonfun$resolveMappings$1(ProjectMatrix.scala:242)
[error]         at scala.collection.immutable.List.map(List.scala:293)
[error]         at sbt.internal.ProjectMatrix$ProjectMatrixDef.resolveMappings(ProjectMatrix.scala:229)
[error]         at sbt.internal.ProjectMatrix$ProjectMatrixDef.resolvedMappings$lzycompute(ProjectMatrix.scala:209)
[error]         at sbt.internal.ProjectMatrix$ProjectMatrixDef.resolvedMappings(ProjectMatrix.scala:209)
[error]         at sbt.internal.ProjectMatrix$ProjectMatrixDef.componentProjects$lzycompute(ProjectMatrix.scala:309)
[error]         at sbt.internal.ProjectMatrix$ProjectMatrixDef.componentProjects(ProjectMatrix.scala:309)
[error]         at sbt.CompositeProject$.$anonfun$expand$1(Project.scala:157)
[error]         at scala.collection.immutable.List.flatMap(List.scala:366)
[error]         at sbt.CompositeProject$.expand(Project.scala:157)
[error]         at sbt.internal.EvaluateConfigurations$.$anonfun$evaluateSbtFile$4(EvaluateConfigurations.scala:169)
[error]         at sbt.internal.Load$.loadSettingsFile$1(Load.scala:1108)
[error]         at sbt.internal.Load$.$anonfun$discoverProjects$2(Load.scala:1117)
[error]         at scala.collection.MapLike.getOrElse(MapLike.scala:131)
[error]         at scala.collection.MapLike.getOrElse$(MapLike.scala:129)
[error]         at scala.collection.AbstractMap.getOrElse(Map.scala:65)
[error]         at sbt.internal.Load$.memoLoadSettingsFile$1(Load.scala:1116)
[error]         at sbt.internal.Load$.$anonfun$discoverProjects$4(Load.scala:1124)
[error]         at scala.collection.immutable.List.map(List.scala:293)
[error]         at sbt.internal.Load$.loadFiles$1(Load.scala:1124)
[error]         at sbt.internal.Load$.discoverProjects(Load.scala:1138)
[error]         at sbt.internal.Load$.discover$1(Load.scala:890)
[error]         at sbt.internal.Load$.loadTransitive(Load.scala:944)
[error]         at sbt.internal.Load$.loadProjects$1(Load.scala:727)
[error]         at sbt.internal.Load$.$anonfun$loadUnit$11(Load.scala:730)
[error]         at sbt.internal.Load$.timed(Load.scala:1393)
[error]         at sbt.internal.Load$.$anonfun$loadUnit$1(Load.scala:730)
[error]         at sbt.internal.Load$.timed(Load.scala:1393)
[error]         at sbt.internal.Load$.loadUnit(Load.scala:689)
[error]         at sbt.internal.Load$.$anonfun$builtinLoader$4(Load.scala:487)
[error]         at sbt.internal.BuildLoader$.$anonfun$componentLoader$5(BuildLoader.scala:180)
[error]         at sbt.internal.BuildLoader.apply(BuildLoader.scala:245)
[error]         at sbt.internal.Load$.loadURI$1(Load.scala:549)
[error]         at sbt.internal.Load$.loadAll(Load.scala:565)
[error]         at sbt.internal.Load$.loadURI(Load.scala:495)
[error]         at sbt.internal.Load$.load(Load.scala:474)
[error]         at sbt.internal.Load$.$anonfun$apply$1(Load.scala:243)
[error]         at sbt.internal.Load$.timed(Load.scala:1393)
[error]         at sbt.internal.Load$.apply(Load.scala:243)
[error]         at sbt.internal.Load$.defaultLoad(Load.scala:56)
[error]         at sbt.BuiltinCommands$.liftedTree1$1(Main.scala:959)
[error]         at sbt.BuiltinCommands$.doLoadProject(Main.scala:959)
[error]         at sbt.BuiltinCommands$.$anonfun$loadProjectImpl$2(Main.scala:912)
[error]         at sbt.Command$.$anonfun$applyEffect$4(Command.scala:150)
[error]         at sbt.Command$.$anonfun$applyEffect$2(Command.scala:145)
[error]         at sbt.Command$.process(Command.scala:189)
[error]         at sbt.MainLoop$.$anonfun$processCommand$5(MainLoop.scala:245)
[error]         at scala.Option.getOrElse(Option.scala:189)
[error]         at sbt.MainLoop$.process$1(MainLoop.scala:245)
[error]         at sbt.MainLoop$.processCommand(MainLoop.scala:278)
[error]         at sbt.MainLoop$.$anonfun$next$5(MainLoop.scala:163)
[error]         at sbt.State$StateOpsImpl$.runCmd$1(State.scala:289)
[error]         at sbt.State$StateOpsImpl$.process$extension(State.scala:325)
[error]         at sbt.MainLoop$.$anonfun$next$4(MainLoop.scala:163)
[error]         at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:23)
[error]         at sbt.MainLoop$.next(MainLoop.scala:163)
[error]         at sbt.MainLoop$.run(MainLoop.scala:144)
[error]         at sbt.MainLoop$.$anonfun$runWithNewLog$1(MainLoop.scala:119)
[error]         at sbt.io.Using.apply(Using.scala:27)
[error]         at sbt.MainLoop$.runWithNewLog(MainLoop.scala:112)
[error]         at sbt.MainLoop$.runAndClearLast(MainLoop.scala:66)
[error]         at sbt.MainLoop$.runLoggedLoop(MainLoop.scala:51)
[error]         at sbt.MainLoop$.runLogged(MainLoop.scala:42)
[error]         at sbt.StandardMain$.runManaged(Main.scala:218)
[error]         at sbt.xMain$.$anonfun$run$11(Main.scala:133)
[error]         at scala.util.DynamicVariable.withValue(DynamicVariable.scala:62)
[error]         at scala.Console$.withIn(Console.scala:230)
[error]         at sbt.internal.util.Terminal$.withIn(Terminal.scala:569)
[error]         at sbt.internal.util.Terminal$.$anonfun$withStreams$1(Terminal.scala:350)
[error]         at scala.util.DynamicVariable.withValue(DynamicVariable.scala:62)
[error]         at scala.Console$.withOut(Console.scala:167)
[error]         at sbt.internal.util.Terminal$.$anonfun$withOut$2(Terminal.scala:559)
[error]         at scala.util.DynamicVariable.withValue(DynamicVariable.scala:62)
[error]         at scala.Console$.withErr(Console.scala:196)
[error]         at sbt.internal.util.Terminal$.withOut(Terminal.scala:559)
[error]         at sbt.internal.util.Terminal$.withStreams(Terminal.scala:350)
[error]         at sbt.xMain$.withStreams$1(Main.scala:87)
[error]         at sbt.xMain$.run(Main.scala:121)
[error]         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[error]         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[error]         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[error]         at java.lang.reflect.Method.invoke(Method.java:498)
[error]         at sbt.internal.XMainConfiguration.run(XMainConfiguration.java:56)
[error]         at sbt.xMain.run(Main.scala:46)
[error]         at xsbt.boot.Launch$$anonfun$run$1.apply(Launch.scala:111)
[error]         at xsbt.boot.Launch$.withContextLoader(Launch.scala:131)
[error]         at xsbt.boot.Launch$.run(Launch.scala:111)
[error]         at xsbt.boot.Launch$$anonfun$apply$1.apply(Launch.scala:37)
[error]         at xsbt.boot.Launch$.launch(Launch.scala:120)
[error]         at xsbt.boot.Launch$.apply(Launch.scala:20)
[error]         at xsbt.boot.Boot$.runImpl(Boot.scala:56)
[error]         at xsbt.boot.Boot$.main(Boot.scala:18)
[error]         at xsbt.boot.Boot.main(Boot.scala)
[error] no rows were found in project matching ProjectRow(true, List(PlatformAxis(jvm,JVM,jvm), ScalaVersionAxis(2.12.12,2.12))): List(ProjectRow(true, List(PlatformAxis(jvm,JVM,jvm), ScalaVersionAxis(2.13.8,2.13))))
[error] Use 'last' for the full log.

The best I can tell is that this has something to do with the meta-build? The meta-build contains a build.sbt like:

libraryDependencies ++= Seq("com.lihaoyi" %% "sjsonnet" % "0.2.6")

and an AutoPlugin. FWIW I tried removing them temporarily, and that didn't seem to help.

keynmol commented 2 years ago

ThisBuild / scalaVersion := scala212Version in build.sbt

With projectmatrix global Scala versions are not really something you should use (as the projects no longer have "crossScalaVersions" set, and you can't use stateful + or ++ to override scalaversions).

I would recommend removing that settings

The second issue is a somewhat easier to understand (albeit the error message is not fantastic):

[error] no rows were found in project matching ProjectRow(true, List(PlatformAxis(jvm,JVM,jvm), ScalaVersionAxis(2.12.12,2.12))): List(ProjectRow(true, List(PlatformAxis(jvm,JVM,jvm), ScalaVersionAxis(2.13.8,2.13))))

It means that in your build you have a projectMatrix which is only defined for Scala 2.13, but it depends on another projectMatrix that is only defined for 2.12. (or vice versa, basically a mismatch of scala versions)

Which means the plugin cannot reconcile the dependencies, and it crashes.

It might also be the global Scala setting.

I'd recommend removing the global scalaVersion first (as it has no effect on how projectmatrix works), and then checking your inter-project dependencies.

dvgica commented 2 years ago

Thanks for the reply @keynmol !

With projectmatrix global Scala versions are not really something you should use

Makes sense, but I will note that the README does include them - I was following that, but perhaps I misunderstood?

It means that in your build you have a projectMatrix which is only defined for Scala 2.13, but it depends on another projectMatrix that is only defined for 2.12.

I can't for the life of me find where I might have this mismatch. What is further confusing is the reference to project, which is dynamic. Doesn't that denote the meta-build? I don't actually have a project called project in my top-level build.

At any rate... I reverted to crossScalaVersions and got that to work (or rather my colleague did). I'll close out this issue since it's still probably an error on my end.

I appreciate the guidance nonetheless.