I'd like to test the Scala code that I've just written by running small fragments of it separately in a Scala Worksheet. What sounds like a trivial affair isn't working because:
After updating the code, the Scala Worksheet keeps running the obsolete code. I've already ticked the Make Project checkbox and have even tried the enabling Use REPL Mode without luck. When even a complete cycle of sbt reload > sbt update > sbt clean > sbt compile doesn't fix the issue, I wonder what will.
Even if I manage to fix the above issue, next thing is that I'm unaware of any possible way to view the log messages generated by typesafe Logger within IntelliJ IDEA. There might be some file where these logs are being dumped but leaving the IDE to view log file sounds less-than-ideal in 2018. The only other alternative would be to manually replace (or augment) each log line throughout my project with println. Something makes me think that there's got to be a better way. The IntelliJ docs page for Setting Log Options isn't very helpful as it is outdated and I cannot find the same UI as shown in the screenshots over there
Assuming above two problems are sorted, there's yet another hurdle: the infamous Internal Error: null problem when trying to run the worksheet. And from what I've observed, once I hit this error, only restarting IntelliJ overcomes it.
Here are my configurations
IDE
- IntelliJ IDEA 2017.3.4 (Community Edition)
- Build #IC-173.4548.28, built on January 30, 2018
- JRE: 1.8.0_152-release-1024-b11 x86_64
- JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
- Mac OS X 10.13.3
- Scala Plugin Version: 2017.3.11.1
Project
- Scala 2.11.11
- SBT 1.0.3
- Typesafe Scala Logging "com.typesafe.scala-logging" %% "scala-logging" % "3.7.2"
Related
One fine day IntelliJ started highlighting my working Scala code in red. While following commands run without a hitch, IntelliJ thinks that code is full of errors an missing a lot of dependencies.
sbt clean
sbt reload
sbt update
sbt compile
sbt assembly
It reports a lot of Cannot resolve symbols in imports, classes and method-calls on objects like the following. Moreover, it thinks a lot of imports are unused (for the symbols that it can't find)
Interestingly, all this is happening in only one of my projects (that contains two submodules inside parent module), while other Scala projects (including those containing submodules) are working fine.
Things that I've tried without luck:
Delete (rm -rf) build-related directories like .idea, target, ~/.ivy2/caches
Invalidate Caches / Restart...
Update IntelliJ IDEA and Scala plugin to latest versions
Close and re-import the project, quit IntelliJ, reboot the PC (!)
I'm using:
IntelliJ IDEA 2017.3.2 (Community Edition)
Build #IC-173.4127.27, built on December 25, 2017
JRE: 1.8.0_152-release-1024-b8 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Mac OS X 10.13.2
My project configurations are:
Scala v2.11.11
SBT v1.0.3
Once again, I'd like to remind that my Scala code is completely functional and that I'm able to run the JAR generated by sbt assembly elsewhere without an issue.
This solution worked for me: Why does intellij IDEA highlight build.sbt?
Go to the menu: File > Invalidate Caches/Restart
Such things happen when project SDK is not set. Also make sure that you have Add Framework Support -> Scala enabled.
I'm new to working with both IntelliJ and Scala, so I've been trying to set up a basic HelloWorld project using it. However once I try to load the project I'm met with two problems
I get an error saying there was an "Error while importing SBT project"
No 'src' folder appears on the project tree
I've seen similar problems here and here, but I still can't get the project to load properly.
For some reason this site doesn't let you post an image until you have 10 reputation, so here is a link to the error message I'm receiving http://i.imgur.com/vDZB6SA.png.
From the looks of it, it seems like it's unable to download the necessary dependencies, however I was able to download the scala plugin earlier, so I can't see why there would be a problem now.
I tried following the advice here on updating the proxy settings, but that doesn't work either.
Has anyone encountered a similar problem? I'm really stuck here on how to proceed.
EDIT 1:
Details on IntelliJ
IntelliJ IDEA 2016.2.3
Build #IC-162.1812.17, built on August 30, 2016
JRE: 1.8.0_65-b17 amd64
JVM: Java HotSpot(TM) 64-Bit Server VM by Oracle Corporation
Setting up the proejct:
I just followed an example and went to New Project > Scala > SBT > name project and finish. Then once it loads I get the error displayed in the picture above. The SBT version is 0.13.8 and the Scala version is 2.11.8
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.
I've just generated a fresh Play! application, version 2.1-RC1.
This one includes two Scala compiler/library couple:
Scala 2.9.2
Scala 2.10.0-RC1
The whole well compiles within IntelliJ IDEA 12 but a warning occurs as the image shows it:
It would seem so that another compiler is used instead 2.10.0-RC1.
However, my Scala facet is configured as this:
What might be the warning cause?
I precise that I've got also a Scala variable environment (used for shell Scala commands) configured to point to scala-2.10.0-RC2, but I well imagine that IntelliJ is based on library that user indicates in Scala Facet.
You can remove that .jar from the libraries, it's not used because it's redundantly generated by IntelliJ SBT plubin.
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.