Intellij: Error while importing SBT project - scala

I used Intellij for 4 months without any problems. Yesterday I installed it on another PC but I can't create a SBT Scala project.
Here the steps:
I create the project:
When started it says me that "SBT project need to be imported" so I click on "Enable Auto-Import" but then I get this error:
If I try to add Scala SDK from modules settings I get this error:
I downloaded Scala and SBT externally, I also tried all the suggested solutions from other similar threads but I can't resolve it.
How can I do?
Thank you in advance!

Add sbt.version to project/build.properties. You can check SBT version using sbt sbtVersion.

Related

sbt Project name must be valid Scala identifier error while creating new project

I wanted to create a new project in scala in intellij. I have chosen Lightbend Project Starter and then Akka Quickstart Scala. On finish I got this error:
sbt Project name must be valid Scala identifier
The name of my project is "akka-demo" but "akkademo" and default "untitled" don't work either. Empty catalog is created. Same with other templates. How can I overcome this?
Env:
Intellij idea ultimate 18.3.4
sbt 1.2.6
As mentioned, akkademo should indeed work.
It sounds like an IntelliJ problem.
If a project directory was created, you can try to remove the .idea directory and reimport the project.
Furthermore, you can download the Akka Quickstart Scala project from Lightbend's website, and start the sbt shell in this directory.
Try to run and compile to make sure your environment is set up correctly.
If everything works with the sbt shell but not in IntelliJ, then open:
IntelliJ -> Preferences -> Build, Execution, Deployment -> Build Tools -> sbt and check the Use sbt shell for imports and for builds.
Then go to the sbt tab in IntelliJ and refresh.

Running Scala under Eclipse

I'm very new to Scala and I tried to run Scala project under Eclipse. I used sbt to create one, then ran sbteclipse to prepare it for Eclipse and imported it successfully. However when I try to run it I get
Error: Unable to initialize main class Main
Caused by: java.lang.NoClassDefFoundError: scala/Function0
error. Scala, sbt and Java are installed, because when I try to run the same project via console, using sbt, it works. What am I missing?
Thanks for any help!
It looks like the classpath of your Eclipse project is incomplete: it's missing the Scala library. Can you double check in Project Settings that the scala library is present?
If all you want to do is try a simple program, an simpler solution is to create a New Scala Project using the Eclipse wizard.

Play with Activator Issue on IntelliJ Idea 14

I have the following problem on IntelliJ IDEA 14:
I created a Play (Scala) project using the Activator (v1.2.10). Then, I converted it to an IDEA project using activator idea command. When, I opened the project with IDEA 14 (Community Edition) the SBT module is not enabled. Therefore, a new dependency in build.sbt file is not included in the classpath. Moreover, the project is not listed in IDEA's SBT view.
The following warning is shown by IDEA:
"This IDEA project is converted from an SBT project by gen-idea tool, which currently relies on a legacy Scala project model. Please consider using built-in SBT support via the Import project action."
Note that, the Scala and SBT plugins are already installed on IDEA.
I don't encounter with the same issue in IDEA 13.
Have you tried File | Import Project and select build.sbt file?
IDEA imports it as an SBT project, with all the dependencies properly resolved. It works fine for me on IDEA 14 and on 13.
Apparently, this is a bug in some versions of IntelliJ 14, that just got fixed (as of version 14.0.3). Updating IJ then updating the scala plugin seems to make things work.
In this case simply import manually the "build.sbt" from your project, so if the directory is ~/Documents/myPlayApp then choose to import ~/Documents/myPlayApp/build.sbt

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:

IntelliJ plugin for cucumber-scala

I am running Cucumber scala project in IntelliJ
IntelliJ IDEA - 13.0.2
I couldn't find separate plugin called cucumber for scala
In my project I am getting cannot resolve message for cucumber as below
Could see below errors as well
Existing plugins installed
What could be the solution
Cheers
You are missing dependencies for cucumber-core and cucumber-scala, please have a look at the documentation and add them to your build.sbt file.
Update:
There is a newer version available for sbt-cucumber-plugin (0.8.0): https://github.com/skipoleschris/xsbt-cucumber-plugin. Maybe that solves your problems.
Did you try the gen-idea plugin to create the IntelliJ IDEA project files ?