Why does activator fail with "Could not retrieve Scala 2.11.5: missing scala.Option, scala.tools.nsc.Global" at startup? - scala

I'm using Typesafe Activator 1.3.2 on Windows 8.
Whenever I try to start activator using activator command, I am getting the following error:
C:\path>activator
Getting Scala 2.11.5 (for activator-launcher)...
:: retrieving :: org.scala-sbt#boot-scala
confs: [default]
0 artifacts copied, 6 already retrieved (0kB/15ms)
Error: Could not retrieve Scala 2.11.5: missing scala.Option, scala.tools.nsc.Global
Can any one help me on this issue?

Deleting ~/.sbt/boot fixes this issue.

I'm pretty sure the following directories have been corrupted and should be removed in that order:
~/.ivy2
~/.sbt
You may also want to rename them first before deleting (in case deleting them does not help and could be restored easily rather than downloading the whole Internet again).
I'm not on Windows and can't tell you exactly what ~ is resolved to on Windows 8 - it's the home directory of the logged-in user, and unless I'm mistaken it was something like %userprofile%.

Uninstall and Install
1) Scala plugin in intelliJ
2) SBT plugin in intelliJ
Restart the intelliJ and run the apps agian.

The below solution has worked for me.
NOTE: Below answer is specific to IntelliJ. But trying the same approach in Eclipse or other IDEs will also work.
In most cases your project JDK is not compatible with Scala or sbt version, try to change the Scala Compile Server SDK.
Press Ctrl+Alt+S to open Settings/Preferences dialog.
From the options on the left, select Build, Execution, Deployment | Compiler | Scala | Scala Compiler Server.
In the JVM SDK field specify the appropriate SDK.
I recommend that you switch to Java 8 SDK since the Scala version 2.12, and sbt versions 1.10 and later are not compatible with older Java SDK versions.

Deleting below two folders fixed the intelliJ error for me
rm -rf ~/.ivy2
cd ~/.sbt
rm -rf boot

Related

Multiple scala libraies causing error in intellij?

I am using intellij 14 with scala 2.11.6 installed using home brew and symlink using
ln -s /usr/local/Cellar/scala/2.11.6/libexec/src /usr/local/Cellar/scala/2.11.6/src
ln -s /usr/local/Cellar/scala/2.11.6/libexec/lib /usr/local/Cellar/scala/2.11.6/lib
mkdir -p /usr/local/Cellar/scala/2.11.6/doc/scala-devel-docs
ln -s /usr/local/Cellar/scala/2.11.6/share/doc/scala /usr/local/Cellar/scala/2.11.6/doc/scala-devel-docs/api
I tried running a simple hello world but run into the following issue.
Error:scalac: Multiple 'scala-library*.jar' files (scala-library.jar, scala-library.jar, scala-library.jar) in Scala compiler classpath in Scala SDK scala-sdk-2.11.6
Edit:
So I check the compiler class path on global libraries and apparently there are multiple scal-library.jar
file:///usr/local/Cellar/scala/2.11.6/idea/lib/scala-library.jar
file:///usr/local/Cellar/scala/2.11.6/lib/scala-library.jar
file:///usr/local/Cellar/scala/2.11.6/libexec/lib/scala-library.jar
Does anyone know why?
Maybe you have used
/usr/local/Cellar/scala/2.11.6/
as the path for Scala SDK?
When you install scala with homebrew that path will contain not only the scala libraries, but also a symlink with the relevant libraries for intellij. So if you use the top-level install directory intellij will find the libraries twice.
Instead you should use
/usr/local/Cellar/scala/2.11.6/idea/lib
I had the same issue than you experimented and the solution, actually very easy, was actually erasing the .idea folder from the project, the problem is that the configuration inside of this folder (containing the set ups for example for the test, VCS, the runs, etc) gets corrupted with double entries (probably cos you update your Scala version), once you do this and reopen the project in Intellij the IDEA will generate a fresh new configuration for you.
This worked for me.
I'm using Idea 2019.2.2 and Windows 10.
In the folder .idea/libraries/ I had two files: sbt__org_scala_lang_scala_library_2_13_0_jar.xml and sbt__org_scala_lang_scala_library_2_13_0_jar2.xml.
I deleted the second file.
Then I opend the first one and there were duplicate lines:
<root url="file://$USER_HOME$/AppData/Local/Coursier/cache/v1/https/repo1.maven.org/maven2/jline/jline/2.14.6/jline-2.14.6.jar" />
<root url="file://$USER_HOME$/AppData/Local/Coursier/cache/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-compiler/2.13.0/scala-compiler-2.13.0.jar" />
<root url="file://$USER_HOME$/AppData/Local/Coursier/cache/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-compiler/2.13.0/scala-compiler-2.13.0.jar" />
<root url="file://$USER_HOME$/AppData/Local/Coursier/cache/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.13.0/scala-library-2.13.0.jar" />
<root url="file://$USER_HOME$/AppData/Local/Coursier/cache/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.13.0/scala-library-2.13.0.jar" />
<root url="file://$USER_HOME$/AppData/Local/Coursier/cache/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-reflect/2.13.0/scala-reflect-2.13.0.jar" />
So I deleted duplicates and errors disappeared.
Hope this will help someone else.
I also ran into that error. The fix I found was to remove the duplicate scala-library in the .iml file generated by intellij.
Basically I located the relevant .iml file by grepping the scala version, and found that two scala-library in that file. I removed the scala 2.11 version, and then it works.
Remove the following line in build.sbt:
...
scalaVersion := "2.13.0"
...
Try rebuilding and running it again
2019 update... I'm running Ubuntu Linux and IntelliJ community 2019.1 with sbt 2.13.1 and got the exact same error. I also found that if I built directly from sbt with "runMain package.MyClass" it worked, so I knew it must be an IntelliJ problem, not a "real" problem.
Anyway, I found the file .idea/libraries/sbt.. lots of crazy long name ... scala_library_2_13_1_jar.xml.
In it, there was an XML block , and in that block, two entries were duplicated:
I first noticed the scala-library one, and after deleting that, the error report came up about the scala-compiler duplicate too.
After deleting both duplicates, my build is now working.
To fix the problem go to project structure in intellij and go to global libraries
It should be like this
After that remove all the scala SDKs by hitting the - mark
Next, click the + and choose your Scala SDK version to add
After that please make sure to apply the changes and re-run the program
You have JAR files from multiple versions of scala-library.jar. In order to make the error go away you will have to delete the duplicates. To figure out which version you want to keep, you can view the manifest file inside each JAR:
META-INF/MANIFEST.MF
Inside the manifest file you should see something like this:
Manifest-Version: 1.0
Class-Path:
Implementation-Title: Scala-Library
Implementation-Version: 2.11.4
The error is happening because IntelliJ cannot figure out which version of a given Scala class to use.
Delete multiple versions of scala-library in sbt, leaving one.
Having similar symptoms, but on a Ubuntu machine, not using brew:
I am using /usr/share/sbt/bin/sbt-launch.jar as launcher. To fix the mentioned problem, I've had to purge the directories 1) project, 2) target and 3) .idea of the relevant Scala projects, doing sbt refresh in IntelliJ (View - Tool Windows -> sbt, hit the Reimport all sbt projects icon), and rebuild all modules afterwards.
As a last step, when the error occurs further, switch over to Ubuntu shell / terminal, and do a sbt clean compile in the problematic project folder. Fix the compile issues if some are occuring. If this does not help, change scalaVersion in build.sbt e.g. from 2.12.9 to 2.12.8 (the error occurs more often with 2.12.9), remove scalaOrganization definition (but keep organization). Repeat the sbt refresh of IntelliJ. OMG.
This worked for me:
In IDEA
Preferences -> Plugins -> Scala -> Update
Restart IDEA

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.

Error: scala: No 'scala-library*.jar' in Scala compiler library

Environment: Play 2.3.0/Scala 2.11.1/IntelliJ 13.1
I used Typesafe Activator 1.2.1 to create a new project with Scala 2.11.1. After the project was created, I ran gen-idea. The generated IDEA project fails to compile with the error:
Error: scala: No 'scala-library*.jar' in Scala compiler library in test
Am I doing something wrong? Workaround?
Open File -> Project Structures -> Libraries, remove any scala sdk in it, e.g. scala-sdk-2.11.8 in the following image.
Click on +, then Scala SDK.
Select the right Scala SDK from the list, for me, it's Ivy-Scala-2.11.8 shown in the picture.
Select the current project(mine is spark-test), click OK.
Then click OK to close it.
Run again, it should work now.
Since IDEA 13 you should use SBT support which is bundled with Scala plugin.
With it there is no need to add third-party SBT plugins and run special commands; just import the project using "File -> Import project..." menu item, and it will automatically load SBT project structure and its dependencies.
I had the same issue with the .idea files generated by ./activator idea with play 2.3. A quick fix is to look in "Project Structure->modules" and note the name of the compiler library. For me it was "SBT: scala2.11.1". The look in "Project Structure->Libraries" and check the contents of this library. It should contain scala-compiler.jar, scala-library.jar, scala-reflect.jar. If this libraries are not present, add them (in my case they are located in ~/.sbt/boot/scala-2.11.1/lib).
For IDEA 15 and project exported from Activator 1.3.5 only Russell's solution helped at the moment.
I have fixed scala compiler library with adding 3 libraries located in ~/.sbt/boot/scala-2.11.1/lib to library's compiler classpath and classes. After indexing project I moved this library to global libraries of IDEA and it was saved there.
I had the same issue.
If you are building your project using external sbt i.e sbt compile then it will create or add dependencies in libraries(all external dependency also) and scala sdk will be added as SBT:scala* based on version of your scala.
So you can remove SDK with SBT as prefix and add proper SDK through Intellij.
File->Project Structure->Libraries
Remove SBT SDK and add it manually.
For me with IDEA 12, I fixed this issue when I unchecked the box for "Use external build" in Settings.Compiler.
now is 2021 year, in Mac, use IntelliJ to run scala:
core logic
Mac: brew install scala
IntelliJ: open *.scala file, then according notice to auto config java JDK and Scala SDK
detailed steps: pls refer another post's answer
I'm an absolute Scala beginner. I was wanting to get up and running. I needed to create a Scala project, not a Java project with Scala library:

play -help gives Error: Could not retrieve sbt 0.13.0: missing sbt.xMain

I created a new app using command play new hello and cd'ed into the directory. When I type play in the directory, I receive the following error:
akshay#Akshay:~/play/testn$ play -help
Java HotSpot(TM) Server VM warning: ignoring option MaxPermSize=512M; support was removed in 8.0
Getting org.scala-sbt sbt 0.13.0 ...
:: retrieving :: org.scala-sbt#boot-app
confs: [default]
0 artifacts copied, 43 already retrieved (0kB/45ms)
Error: Could not retrieve sbt 0.13.0: missing sbt.xMain
Play was working fine in my old Ubuntu box. Today only I got a fresh copy of Ubuntu 12.04 32 bit. I know it is error due to change in version, but certainly, I am not able to solve this. Please help me on this.
In checked .sbt/boot/update.log and I can see this :
trying http://repo.typesafe.com/typesafe/ivy-releases/org.sonatype.oss/oss-parent/7/jars/oss-parent.jar
tried http://repo.typesafe.com/typesafe/ivy-releases/org.sonatype.oss/oss-parent/7/jars/oss-parent.jar
HTTP response status: 404 url=http://repo.typesafe.com/typesafe/ivy-releases/org.sonatype.oss/oss-parent/7/jars/oss-parent.jar
CLIENT ERROR: Not Found url=http://repo.typesafe.com/typesafe/ivy-releases/org.sonatype.oss/oss-parent/7/jars/oss-parent.jar
typesafe-ivy-releases: resource not reachable for org.sonatype.oss#oss-parent;7: res=http://repo.typesafe.com/typesafe/ivy-releases/org.$
trying http://repo1.maven.org/maven2/org/sonatype/oss/oss-parent/
Though error was coming from a fresh ubuntu installation with oracle jdk 8, I tried completely removing jdk and then installing jdk 7, but still no solution. Since it was a fresh installation, I reinstalled ubuntu and installed jdk 7 and problem is solved. Not sure why is it contradictory to Play's recomendation of using Jdk 6 or above. Notifying Play Google Groups about this.
I was getting the same error while trying to build using sbt-launcher.jar which was invoked through jenkins. In my case there were two Scala versions within ~/.sbt/boot/ and removing the older version solved the issue.
I was trying to setup my development environment for one of our projects when I hit this issue. The problem was the sbt.version parameter in the build.properties file of our project which specifically mentioned the version of sbt as 0.13.8 and I had sbt 0.13.11.
After removing sbt 0.13.11 and installing 0.13.8, the issue got resolved. Or if it is possible for you to change the sbt version in your build.properties file, you can do that as well.

How to fix NoSuchMethodError?

I use Scala 2.10.0RC1 and sbt 0.12.1.
What causes and how can I fix this runtime error (runs fine on 2.9.2)?
The exact error message is:
java.lang.NoSuchMethodError: scala.Predef$ArrowAssoc$.extension$$minus$greater(Ljava/lang/Object;Ljava/lang/Object;)Lscala/Tuple2;
You're running the code with the wrong Scala version. This can have several causes:
misconfiguration of the project with sbt – search for 2.9.2 in config files
stale cache used by sbt – sbt reboot
something else?
If you meticulously check all your sbt configuration files for 2.9.2 and then wipe out all caches, things should run better. Dependencies usually have a version number in the name of the jar file, so running a find on your system will likely point you to the ones you missed.