sbt-typelevel icon indicating copy to clipboard operation
sbt-typelevel copied to clipboard

ThisBuild / crossScalaVersions results in error on project load

Open bpholt opened this issue 2 years ago • 4 comments

Using sbt-typelevel-settings v0.5.0-RC9, is it expected that using

ThisBuild / crossScalaVersions := Seq(Scala_2_12, Scala_2_13)

will result in this error on load?

java.util.NoSuchElementException
	at scala.collection.LinearSeqOptimized.last(LinearSeqOptimized.scala:150)
	at scala.collection.LinearSeqOptimized.last$(LinearSeqOptimized.scala:149)
	at scala.collection.immutable.List.last(List.scala:91)
	at org.typelevel.sbt.TypelevelSettingsPlugin$.$anonfun$globalSettings$3(TypelevelSettingsPlugin.scala:49)
	at scala.Function1.$anonfun$compose$1(Function1.scala:49)
	at sbt.internal.util.EvaluateSettings$MixedNode.evaluate0(INode.scala:229)
	at sbt.internal.util.EvaluateSettings$INode.evaluate(INode.scala:171)
	at sbt.internal.util.EvaluateSettings.$anonfun$submitEvaluate$1(INode.scala:88)
	at sbt.internal.util.EvaluateSettings.sbt$internal$util$EvaluateSettings$$run0(INode.scala:100)
	at sbt.internal.util.EvaluateSettings$$anon$3.run(INode.scala:95)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:829)
[error] java.util.NoSuchElementException
[error] Use 'last' for the full log.
[warn] Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore? (default: r)

Removing ThisBuild / makes it work, but it's surprising that it matters:

crossScalaVersions := Seq(Scala_2_12, Scala_2_13)

This is the line in question:

https://github.com/typelevel/sbt-typelevel/blob/9309a656f0f3b97dfe2650fb6a8c99362a958fea/settings/src/main/scala/org/typelevel/sbt/TypelevelSettingsPlugin.scala#L49

bpholt avatar Jul 20 '23 16:07 bpholt

Hmm, no, that seems odd. Any chance you can link to the build?

armanbilge avatar Jul 20 '23 16:07 armanbilge

INFO: my Scala cross versions are specified as:

inThisBuild(List(
   ...
   crossScalaVersions := Seq(Scala213, Scala212, Scala3),
   ...
)

Which I believe should be equivalent to what you had: it works fine on RC9.

j-mie6 avatar Jul 20 '23 16:07 j-mie6

Any chance you can link to the build?

Unfortunately this is an internal library so I can't share the build. I'll see if I can minimize.

inThisBuild(List(
  ...
   crossScalaVersions := Seq(Scala213, Scala212, Scala3),
   ...
)

FWIW, I was under the impression that the inThisBuild macro has some subtle differences from the ThisBuild scope, so we've been moving things to use the scope directly. But in any event, in this build, I get the same NoSuchElementException using

inThisBuild(List(
  crossScalaVersions := Seq(Scala_2_12, Scala_2_13)
))

(albeit with a lot of other settings still set using the scope directly)

bpholt avatar Jul 20 '23 18:07 bpholt

@armanbilge I was able to minimize; check out this gist. tl;dr, it looks like it was caused by the root project explicitly setting crossScalaVersions := Seq.empty. (It did that to suppress publishing in the root project; I've since switched it to use the NoPublishPlugin instead.)

bpholt avatar Jul 20 '23 18:07 bpholt

This is stale; I'm closing it.

bpholt avatar Jul 09 '25 23:07 bpholt