Scala SBT Plugin Version Error During Build - scala

I keep getting the following error from my GitHub Actions workflow:
[info] welcome to sbt 1.7.1 (Eclipse Adoptium Java 11.0.16.1)
[info] loading settings for project plant-simulator-build from plugins.sbt ...
[info] loading project definition from /home/runner/work/plant-simulator/plant-simulator/project
[warn]
[warn] Note: Some unresolved dependencies have extra attributes. Check that these dependencies exist with the requested attributes.
[warn] org.scoverage:sbt-scoverage:2.0.7 (sbtVersion=1.0, scalaVersion=2.12)
[warn]
[warn] Note: Unresolved dependencies path:
[error] sbt.librarymanagement.ResolveException: Error downloading org.scoverage:sbt-scoverage;sbtVersion=1.0;scalaVersion=2.12:2.0.7
[error] Not found
[error] Not found
[error] not found: https://repo1.maven.org/maven2/org/scoverage/sbt-scoverage_2.12_1.0/2.0.7/sbt-scoverage-2.0.7.pom
[error] not found: /home/runner/.ivy2/localorg.scoverage/sbt-scoverage/scala_2.12/sbt_1.0/2.0.7/ivys/ivy.xml
[error] not found: https://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/org.scoverage/sbt-scoverage/scala_2.12/sbt_1.0/2.0.7/ivys/ivy.xml
[error] not found: https://repo.typesafe.com/typesafe/ivy-releases/org.scoverage/sbt-scoverage/scala_2.12/sbt_1.0/2.0.7/ivys/ivy.xml
[error] at lmcoursier.CoursierDependencyResolution.unresolvedWarningOrThrow(CoursierDependencyResolution.scala:345)
[error] at lmcoursier.CoursierDependencyResolution.$anonfun$update$38(CoursierDependencyResolution.scala:314)
[error] at scala.util.Either$LeftProjection.map(Either.scala:573)
[error] at lmcoursier.CoursierDependencyResolution.update(CoursierDependencyResolution.scala:314)
I have the following defined in my project/plugins.sbt file:
// For code coverage test
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.7")
My question is, why is it taking the 2.12_1.0 scoverage version instead of 2.12.17_2.0.7? This is ruining my build. Any ideas on how to fix this?

My question is, why is it taking the 2.12_1.0 scoverage version instead of 2.12.17_2.0.7?
It's not. It is trying to find version 2.0.7 of the plugin. The 2.12 refer to the Scala version of plugins expected by SBT (different from the version of your project), and 1.0 refer to SBT major version.
The error message is relatively clear:
Note: Some unresolved dependencies have extra attributes. Check that these dependencies exist with the requested attributes.
org.scoverage:sbt-scoverage:2.0.7 (sbtVersion=1.0, scalaVersion=2.12)
This is ruining my build. Any ideas on how to fix this?
There's no version 2.0.7 as of today. Latest is 2.0.5. Check out the GitHub page of the plugin for reference: https://github.com/scoverage/sbt-scoverage.

Related

How do I resolve a versioning error when compiling spark scala project with sbt?

I am working through the Apache Spark fundamentals course on pluralsight and trying to compile one of the example projects but am getting the following error. I have tried this now on two machines and am seeing the same thing. I can only assume this is some kind of versioning error for sbt and scala, and potentially spark?
I am using sbt 1.7.2, scala 2.12.15, spark 3.3.0
Any advice much appreciated!
[info] Updated file C:\Users\mg15\Documents\spark_stuff\LanguageEvaluator - PreTransform\project\build.properties: set sbt.version to 1.7.2
[info] welcome to sbt 1.7.2 (Oracle Corporation Java 16)
[info] loading settings for project languageevaluator-pretransform-build from assembly.sbt,plugins.sbt ...
[info] loading project definition from C:\Users\mg15\Documents\spark_stuff\LanguageEvaluator - PreTransform\project
[warn]
[warn] Note: Some unresolved dependencies have extra attributes. Check that these dependencies exist with the requested attributes.
[warn] com.eed3si9n:sbt-assembly:1.7.2 (sbtVersion=1.0, scalaVersion=2.12)
[warn] com.typesafe.sbteclipse:sbteclipse-plugin:4.0.0 (sbtVersion=1.0, scalaVersion=2.12)
[warn]
[warn] Note: Unresolved dependencies path:
[error] sbt.librarymanagement.ResolveException: Error downloading com.eed3si9n:sbt-assembly;sbtVersion=1.0;scalaVersion=2.12:1.7.2```

SBT ignored unmanaged directory for Scala js

I have an old Scala 2.11 project where one of the libraries for Scala.js is not available any more. It's a multiproject build so, I created a lib folder inside of my Scala js project and in the settings of that project set:
unmanagedBase := baseDirectory.value / "lib"
When I go in the SBT shell to js project and type: unmanagedBase it shows correct path to the lib folder. But when I try to import the project in Intellij I'm getting this error:
[warn] :: com.mediamath#scala-json_2.11;1.1: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn]
[warn] Note: Unresolved dependencies path:
[warn] com.mediamath:scala-json_2.11:1.1 (/home/my_project/pg/build.sbt#L59)
[warn] +- js:js_sjs0.6_2.11:0.1-SNAPSHOT
[trace] Stack trace suppressed: run 'last js/*:ssExtractDependencies' for the full output.
[trace] Stack trace suppressed: run 'last js/*:update' for the full output.
[error] (js/*:ssExtractDependencies) sbt.ResolveException: unresolved dependency: com.mediamath#scala-json_2.11;1.1: not found
[error] (js/*:update) sbt.ResolveException: unresolved dependency: com.mediamath#scala-json_2.11;1.1: not found
And I have scala-json_2.11-1.1.jar in my lib folder
This warning
[warn] Note: Unresolved dependencies path:
[warn] com.mediamath:scala-json_2.11:1.1 (/home/my_project/pg/build.sbt#L59)
[warn] +- js:js_sjs0.6_2.11:0.1-SNAPSHOT
suggest that the actual issue that requires js:js_sjs0.6_2.11:0.1-SNAPSHOT, so some dependency related to Scala.js 0.6, while you provided scala-json_2.11-1.1.jar, a JAR dedicated for Scala.js 1.1.
Since you added a JAR as unmanaged, resolvers cannot perform evictions or suggest incompatibilities, and can merely verify whether dependencies are there or not, so you'd have to resolve them on your own.
You have some options like editing the MANIFEST file (if code would happen to be compatible between versions), or (if it's open source) compile the offending library yourself for Scala.js 1.1.

issue with resolving sbt dependencies scalameta

I have created an sbt project. I am trying to add the org.scalameta dependency for scala code formatting. I added following dependency in project/plugins.sbt
addSbtPlugin("org.scalameta" %% "scalameta_2.11" % "4.5.3")
But I am getting following error:
[warn] Note: Some unresolved dependencies have extra attributes. Check that these dependencies exist with the requested attributes.
[warn] org.scalameta:scalameta_2.11:4.5.3 (sbtVersion=1.0, scalaVersion=2.12)
[warn]
[warn] Note: Unresolved dependencies path:
[error] sbt.librarymanagement.ResolveException: Error downloading org.scalameta:scalameta_2.11;sbtVersion=1.0;scalaVersion=2.12:4.5.3
[error] Not found
[error] Not found
[error] not found: https://repo1.maven.org/maven2/org/scalameta/scalameta_2.11_2.12_1.0/4.5.3/scalameta_2.11-4.5.3.pom
If a double percent symbol (%%) is used, sbt will resolve the relevant Scala version.
A single percent symbol (%) is used to resolve the dependencies to a specific Scala version.
I just copy and pasted the example from Maven, and it worked for me:
libraryDependencies += "org.scalameta" %% "scalameta" % "4.5.3"
You can find an example within the Maven repository page.

How to correctly prepare and setting preloaded sbt lib

In my situation, I cannot access internet in my office linux server. Therefore, I installed sbt in my personal computer. I followed instructions on sbt official web-site and run/compile a "hello world" for getting all dependency data.
Then, I copied ~/.ivy2 and ~/.sbt and sbt bin folders to my offline office desktop. But when I run sbt, I got these errors:
[info] welcome to sbt 1.4.9 (Oracle Corporation Java 1.8.0_25)
[info] loading project definition from /proj/mtk07847/test/scala/project
[info] Updating
[info] Resolved dependencies
[warn]
[warn] Note: Unresolved dependencies path:
[error] sbt.librarymanagement.ResolveException: Error downloading org.scala-lang:scala-library:2.12.12
[error] Not found
[error] Not found
[error] download error: Caught java.net.SocketException: Connection reset (Connection reset) while downloading https://repo1.maven.org/maven2/org/s
cala-lang/scala-library/2.12.12/scala-library-2.12.12.pom
[error] not found: ~/.ivy2/localorg.scala-lang/scala-library/2.12.12/ivys/ivy.xml
...
It seems that sbt tried to download missing scala-library:2.12.12 which I already prepared.
In my ~/.ivy2 folder,the structure and path looks like the following:
~/.ivy2/cache/org.scala-lang/scala-library/jars/scala-library-2.12.12.jar
~/.ivy2/cache/org.scala-lang/scala-library/ivy-2.12.12.xml
~/.ivy2/cache/org.scala-lang/scala-library/ivy-2.12.12.xml.original
~/.ivy2/cache/org.scala-lang/scala-library/ivydata-2.12.12.properties
which is different from above messages:
[error] not found: ~/.ivy2/localorg.scala-lang/scala-library/2.12.12/ivys/ivy.xml
should I modified any describing files to indicate searching path or rule for sbt? or this method
is totally wrong (if so, can anyone know the flow guide me the better way?)

sbt new RuntimeException

I got lost trying to start with a scala toy example, when running sbt new scala/hello-world.g8 or even sbt new, the program crashes with the following error. Any ideas what might be wrong? Thanks in advance!
(In fact, I am running sbt -java-home /usr/lib/jvm/jdk-8-oracle-x64 new since my system uses older version of jdk by defualt)
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: org.antlr#ST4;4.0.8: org.sonatype.oss#oss-parent;9!oss-parent.pom(pom.original) origin location must be absolute: file:/home/michal/.m2/repository/org/sonatype/oss/oss-parent/9/oss-parent-9.pom
[warn] :: com.googlecode.javaewah#JavaEWAH;0.7.9: org.sonatype.oss#oss-parent;5!oss-parent.pom(pom.original) origin location must be absolute: file:/home/michal/.m2/repository/org/sonatype/oss/oss-parent/5/oss-parent-5.pom
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[error] java.lang.RuntimeException: Retrieval of org.scala-sbt.sbt-giter8-resolver:sbt-giter8-resolver:0.1.3 failed.
[error] at scala.sys.package$.error(package.scala:27)
[error] at sbt.TemplateCommandUtil$.classpathForInfo(TemplateCommand.scala:119)
[error] at sbt.TemplateCommandUtil$.infoLoader(TemplateCommand.scala:81)
[error] at sbt.TemplateCommandUtil$.$anonfun$run$1(TemplateCommand.scala:48)
[error] at sbt.TemplateCommandUtil$.$anonfun$run$1$adapted(TemplateCommand.scala:47)
[error] at sbt.TemplateCommandUtil$$$Lambda$1762/658781536.apply(Unknown Source)
...
[error] at xsbt.boot.Boot$.runImpl(Boot.scala:41)
[error] at xsbt.boot.Boot$.main(Boot.scala:17)
[error] at xsbt.boot.Boot.main(Boot.scala)
[error] Retrieval of org.scala-sbt.sbt-giter8-resolver:sbt-giter8-resolver:0.1.3 failed.
[error] Use 'last' for the full log.
I had this problem too. I fixed it by blowing away my ~/.ivy2 directory
I had this problem too, had an out-of-date ~/.sbt/repositories file.
Either:
remove or rename ~/.sbt/repositories
add missing repositories to ~/.sbt/repositories from the current repositories list, see https://github.com/sbt/sbt/blob/v1.0.2/launch/src/main/input_resources/sbt/sbt.boot.properties
Upgrade your SBT version
Create a new user, to have a clean configuration, make sure that it is available for this user JDK and SBT with a "-version". I executed it and everything worked perfectly. Sometimes you have both installed or configured for your user that the programs conflict with each other.
P.S. I do not recommend using openjdk in this case.