Error downloading org.scalameta:semanticdb-scalac_2.13.6:4.4.10 - scala

I recently upgraded to Scala 2.13.6 and I am seeing:
Error downloading org.scalameta:semanticdb-scalac_2.13.6:4.4.10
when I try to build.
I had a similar error when I upgraded to 2.13.5, but was able to add semanticdbVersion := "4.4.11" to build.sbt to get it to work.
This is not working this time.

You can check on the central Maven repository which versions of the project is available for which version of Scala:
https://mvnrepository.com/artifact/org.scalameta/semanticdb-scalac
The only version built for Scala 2.13.6 is 4.4.18 as of today.
This info is probably also available on their GitHub release note oages

I assume you are using the sbt-scalafix plugin in your build. This kind of error can happen if you update the scala version before you update the scalafix plugin to the latest version because the semanticdb version is usually set via this setting in your build.sbt (At least this is the official recommendation):
semanticdbVersion := scalafixSemanticdb.revision
In case of scala v2.13.6 I needed to bump the version of sbt-scalafix to v0.9.28 to fix the error you described.

Related

What scala-library dependenecy version can be used with Gradle 7.2 for Gatling performance testing

I am trying to do performance testing for my API using Gatling and Scala.
Below are the plugins/libraries I am using
gradle version : 7.2
gradle.plugin.com.github.lkishalmi.gatling:gradle-gatling-plugin:3.3.0
dependency : gatling 'org.scala-lang:scala-library:2.13.10'
I get the below error when I try to resolve dependencies
A problem occurred evaluating project ':performance-test'.
> Could not find method compile() for arguments [org.scala-lang:scala-library:2.13.10] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
My guess is that the scala version 2.13.10 is not compatible with the gradle version 7.2. I tried changing the scala version to latest and many others, but nothing seems to work.
I have also seen another project using gradle 6.6 and scala version 2.12.2 which works. In my case I can't downgrade the gradle version, unfortunately.
Does anyone know what scala version is compatible with gradle 7.2?
The com.github.lkishalmi.gatling:gradle-gatling-plugin plugin has been deprecated for a long time. Please use the official plugin: https://gatling.io/docs/gatling/reference/current/extensions/gradle_plugin/

Scala, Sbt - download wrong version of library even if it is set in build.sbt

I have a weird problem with Sbt. I have a Scala zio version set to 1.0.12 in build.sbt:
val zio = "1.0.12"
But when I ran application with sbt it downloaded zio in version 2.x (screen):
I have no idea why. I removed .ivy2 and .sbt directories from user directory. I restarted intellij many times, invalided cached. Even with clear project it always downloads version 2.0.0. Whole code is inspected with this version.
Other zio related lib's versions I use:
val scalaVersion = "2.13.8"
val zio = "1.0.12"
val zioInteropCats = "3.2.9.0"
val zioInteropLog = "1.0.1"
Do you have any ideas why it works like this? I do not need to use ZIO in newest version.
I see in your comment you already solved this, but here's how you'd solve it in general:
This kind of thing is caused when two of your dependencies require different versions of a library. Your explicitly-set version is being "evicted" in favor of a higher version that something else requires
You can find this info by running sbt evicted. If your sbt version is recent (as of 2022), it should be able to use the versionScheme for scala libraries (if they are versions published after the feature was added) in order to alert you with an error when an eviction is likely to be incompatible.
The solution as you've found is to locate the dependency which is bringing in the incompatible version and then resolve the conflict by changing the version of either that dependency or the others

Cross-compiled with an incompatible version

I am using eclipse with m2eclipse-scala plugin. Currently, I get the following error message:
exampleA_2.10-2.0.1.jar of module build path is cross-compiled with an incompatible version of Scala (2.10.0). In case this report is mistaken, this check can be disabled in the compiler preference page
It looks like the versions of extracted Scala and Scala IDE match. I just wanted to make sure that this is a "false-negative" as described here and can be safely turned off.
As #The Archetypal Paul suggested, it was because I was using wrong Scala library.
If you are using Scala 2.11 (check at About Scala IDE -> installation details), you can downgrade by following instruction here. It's a lot easier than uninstalling and re-installing Scala IDE as other Stackoverflow posts recommend.
I also faced the same issue->
I am trying to use casbah jar in scala to integrate with mongodb.
After analyzing the problem i found that ->
i am trying to use casbah 2.9.1 version and my scala version is 2.11.8
Root-Cause of such error is : your jar is compiled in 2.9.0 version and you are using scala 2.11.8 version
So, to resolve that i use the jar that is compiled into 2.11 scala version-
<groupId>org.mongodb</groupId>
<artifactId>casbah-core_2.11</artifactId>
<version>3.1.1</version>
I was facing similar issue in Eclipse IDE where I had built a Spark scala project in Maven. The scala version was set to 2.11.
Later, I upgraded Scala-Ide plugin in Eclipse after which my project marked below errors,
exampleA_2.10-2.0.1.jar of module build path is cross-compiled with an incompatible version of Scala (2.10.0). In case this report is mistaken, this check can be disabled in the compiler preference page
Right click project folder > scala > set scala version. Here my scala version was displayed as 2.10. I selected 2.11 and removed all the error messages.

Sbt 0.12.4+ required on project import

I'm currently reading the Play for Scala: Covers Play 2 book by Peter Hilton (publisher: Manning) , and trying to stick to the versions they've outlined in the book (Play version 2.1.1).
I downloaded the new IntelliJ IDEA 14 CE app and installed it. I'm currently importing the project, and it's failing because it wants a version of sbt that is 0.12.4 or greater.
This issue occurred in 13 the other day, but I haven't had time to resolve it, so please, no recommendations to go back to 13 :)
Here is the meat of the issue:
When I type sbt --version on the CLI, it prints sbt launcher version 0.13.6. I have a "greater" version, but it appears that IDEA doesn't recognize this.
In an effort to specify my own SBT launcher JAR, I pointed my custom launcher (in IDEAs global settings) to the one in /usr/local/Cellar/sbt/0.13.6/libexec/sbt-launch.jar, but the build also failed with the same error.
As you may have guessed at this point, I have used Homebrew to install and manage Scala and sbt. When I first started working with Scala back in February, I remember having to make a few small tweaks in my settings to get IDEA to find Scala, but my version of IDEA 14 is totally fresh -- I did not import any previous settings. I downloaded the Scala and sbt plugins and they appear to be properly configured after a cursory look and creation of a new test project.
Here is what I'm failing to understand:
First, and most obvious, why would an sbt version that meets the supposed requirement (0.12.4+) fail with version 0.13.*?
Second, is the bundled sbt with IDEA also greater than this version? Is there possibly an sbt flag somewhere in my system that's pointing it to an earlier version? A side note, I have a few versions of sbt in my "Cellar", but all are greater than 0.13.
Many thanks for your help!
I had a look at the code samples from Manning's website, and the project/build.properties files for each project specify sbt.version=0.12.2. My guess is that the Intellij Scala plugin only supports SBT 0.12.4, and cannot import you project which is configured to use an older version (hence why it recommends that you "update your project definition").
You should try using sbt.version=0.12.4 in the project/build.properties file.
Generally speaking, keep in mind that when an SBT version is specified in project/build.properties, the SBT launcher downloads the specified version and uses it to build the project. In your case, that means that the SBT 0.13.6 launcher will download SBT 0.12.2 and use that version to build the project.

How to upgrade Scala to a newer version from the command line?

Is there away to upgrade the installed Scala version via sbt / other command line tool?
I'm sure there is a way, but I couldn't find any after a quick search, am I missing anything?
Each SBT project specifies the version of Scala to use to compile and run its code. It defaults to being the version of Scala that SBT uses internally, but is always overridable.
E.g.
scalaVersion := "2.10.0"
As Connor Doyle mentioned, if your OS has a package system that includes Scala (some Linux distros I know of do) and you are, for some reason obligated to use that, you are pretty much at their mercy to provide a new version on a timely basis. The Scala Web Site (downloads here) provides a variety of installers and tarballs / Zip archives for every release they've made.
Mac OS X users can use HomeBrew to get up-to-date SBT and Scala.
To set the project version temporarily from the command line:
++ 2.10.4
To set the project version permanently from the command line:
set scalaVersion := "2.10.4"
session save
I just executed one command line"homebrew remove scala;homebrew install scala" to update to the latest version. Isn't this enought?
I also found this link (http://wkmacura.tumblr.com/post/11577309978/installing-specific-versions-with-homebrew) and hope it works for you.