Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ThisBuild / crossScalaVersions results in error on project load #615

Open
bpholt opened this issue Jul 20, 2023 · 4 comments
Open

ThisBuild / crossScalaVersions results in error on project load #615

bpholt opened this issue Jul 20, 2023 · 4 comments

Comments

@bpholt
Copy link
Member

bpholt commented Jul 20, 2023

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:

Def.derive(scalaVersion := crossScalaVersions.value.last, default = true)

@armanbilge
Copy link
Member

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

@j-mie6
Copy link
Collaborator

j-mie6 commented Jul 20, 2023

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.

@bpholt
Copy link
Member Author

bpholt commented Jul 20, 2023

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
Copy link
Member Author

bpholt commented Jul 20, 2023

@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.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants