IntelliJ IDEA 15 is reporting an unresolved symbol for my project definition in my build.sbt file
lazy val root = (project in file(".")).enablePlugins(PlayScala)
It's reporting an error with project and in.
Cannot resolve symbol project.
Cannot resolve symbol in.
Everything else resolves perfectly and the project is otherwise all set up, sbt builds fine, activator runs fine.
In my case, after upgrading Intellij forgot that the project was a Scala project.
Delete .idea/ and import the project to fix this.
To fix this issue, I imported: import sbt.project on top of my build.sbt
I am working with IntelliJ IDEA 16 EAP
I looked on jetbrains' error tracker and found this is a known bug.
"Cannot resolve symbol project" in build.sbt
https://youtrack.jetbrains.com/issue/SCL-9512
This happened to me when when the "external library" referenced was a different version than the one stated in the build.sbt file. Specifically:
External Libraries -> SBT: org.scala-lang:scala-library:2.12.1
build.sbt -> scalaVersion := "2.12.2"
I had an issue with http references in my ~/sbt/repositories file. When I changed this to https all was well.
typesafe-releases: https://repo.typesafe.com/typesafe/releases
typesafe-ivy-releasez: https://repo.typesafe.com/typesafe/ivy-releases, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]
Related
This is a problem that is really getting on my nerves. I'm writing proofs for the Welder proof assistant. I was doing so without the help of an IDE and following an SBT-based building approach. This is the build file:
name := "proofs"
scalaVersion := "2.11.8"
lazy val welder = RootProject(uri("git://github.com/epfl-lara/welder.git#2b9dd10a7a751777cc9cda543ce888294113c0b1"))
lazy val root = (project in file(".")).dependsOn(welder)
I tried to bring my project into an Intellij Idea project. However, while doing so, the IDE won't recognize the imports of the external library:
import inox._
How can I solve this issue?
Edit
I stress that the compile errors are produced in the files from Welder
Here is the welder project/Build.scala file
import sbt._
object WelderBuild extends Build {
lazy val root = Project("root", file(".")) dependsOn(inoxProject)
lazy val inoxProject = RootProject(uri("git://github.com/epfl-lara/inox.git#53ea4533a957050bd6a968d5a340890bd54998a5"))
}
See my answer to your other question and the issue on the Scala plugin issue tracker.
Renaming the modules and manually adding a dependency from the welder-root to the inox-root module will solve the compile path issue, but the build will still fail because one of the project uses source generators, which are not supported in IDEA directly.
Instead, enable the "use sbt for build and import" option in the sbt preferences:
Searching for examples of library use I downloaded this project.
https://github.com/marcusatbang/Hooks
I then moved the build.bat up one directory. Commented out the xsbt-gpg dependency lines in build.sbt and Build.scala since sbt couldn't find the package. I checked the source to comment out any imports of xsbt-gpg -- there were none. ( Surprise! )
So I managed to compile the project. I then did sbt publish-local. find ~/.ivy2 -iname "\*hooks*jar" generated the following line: .ivy2/local/cc.minotaur/hooks_2.9.0/0.1/jars/hooks_2.9.0.jar.
I then entered the examples folder and tried to build the example project.
The build.scala contains the line: libraryDependencies += "cc.minotaur" %% "hooks" % "0.1", and it generates the error: unresolved dependency: cc.minotaur#hooks_2.9.1;0.1: not found
So how do I fix this error? It seems to me it should be finding the hooks jar/
That could be that your resolver doesn't see local directory. Try something like:
val ivyLocal = Resolver.file("local", file(Path.userHome.absolutePath +
"/.ivy2/local"))(Resolver.ivyStylePatterns)
externalResolvers += ivyLocal
It seems to me that you are using two versions of Scala. The one you are generating the jar is 2.9.0 while the one you are using in the example project is 2.9.1. Probably will solve the problem setting the same version in both projects.
I think your scala version is 2.9.1, u have generated jar for version 2.9.0
change your library dependency as mentioned below.
libraryDependencies += "cc.minotaur" % "hooks_2.9.0" % "0.1"
or add scalaVersion := "2.9.0" in your build.sbt file
I have an sbt build that works when I run from the command line, but that Intellij does not like. My Intellij is running on Linux, its version is 14.1.4, my scala plugin is 1.5.2.
Intellij complains about my use of enablePlugins(JavaAppPackaging). The error is "Expression Type (DslEntry) must conform to Setting[_] in SBT file".
My project/build.properties file:
sbt.version=0.13.8
My project/plugins.sbt
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.0.3")
And the first few lines of my build.sbt
enablePlugins(JavaAppPackaging)
organization := "org.bodhi"
name := "jar-patch"
version := "1.0"
The answer by #lifeGoGoGo on another thread Intellij IDEA and SBT syntax error works for me (on Ubuntu, setting the custom sbt-launcher.jar in global settings and project settings of IntelliJ IDEA - as sensibly answered by #Mustafa on this thread - wasn't enough, but then adding the "lazy val" tactic was enough). So for example, this worked for me in build.sbt (obviously you change your plugin-details to suit what you are doing, as this issue is caused by IntelliJ and not by the specific plugin you want to enable):
lazy val root = (project in file(".")).
enablePlugins(ScalaJSPlugin).
settings(
name := "Scala.js Tutorial",
scalaVersion := "2.11.7",
version := "1.0"
)
IntelliJ uses a bundled SBT launcher which might be a different version than what you are running in the command line.
Since you already know that command line SBT works, you may point IntelliJ to use the command line SBT instead of the bundled one.
Go to settings page for SBT at Settings -> Build, Execution, Deployment -> Build Tools -> SBT.
In the launcher section, choose Custom and point to the SBT launcher installed in the OS. In Ubuntu, the default location is /usr/share/sbt-launcher-packaging/bin/sbt-launcher.jar
#karol: I had the same problem. I solved by choosing again at the moment of opening the project /usr/share/sbt-launcher-packaging/bin/sbt-launcher.jar in
"Import Project from SBT" -> Global SBT settings.
The issue is due to how IntelliJ IDEA marks syntax errors, which may mark valid code red. This particular error will be fixed soon.
I just installed Intellij 13 and tried importing some basic SBT project. However I received the following error:
The error message tells that org.jetbrains#sbt-structure;latest.integration cannot be found.
I am using SBT 0.13 and everything (compiling, running and etc..) seems to work from the CLI. I have also followed the installation instructions of the idea-sbt plugin (https://github.com/mpeltonen/sbt-idea).
build.sbt that I am using:
name := "demo"
version := "1.0"
scalaVersion := "2.9.2"
project/plugins.sbt:
addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.5.2")
Did anyone had this issue and managed to resolve it?
Thanks!
This was a known issue and is resolved in the latest version 0.26.327 (try to run 'Check for Updates...').
If the problem persists, it must be due to another issue but not dependency resolution. In that case you can resort to using the sbt-idea plugin. From a terminal inside your project directory execute sbt gen-idea, afterwards you should be able to use 'Open Project...' in IDEA.
i have problems top use sbteclipse
What I have done:
went to my global sbt folder.
created a plugins folder
created the file plugins.sbt with addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.1.0")
went to my eclipse project and created a build.sbt file
it contains:
name := "foo"
version := "1.0"
scalaVersion := "2.9.2"
libraryDependencies += "net.java.dev.jna" % "jna" % "3.4.0"
I am selecting the project folder in my cmd. and type sbt eclipse
But I always get the following error
[error] Not a valid command: eclipse (similar: help, alias)
[error] Not a valid project ID: eclipse
[error] Expected ':'
[error] Not a valid key: eclipse (similar: deliver, licenses, clean)
[error] eclipse
[error] ^
ps: I am using Windows. I am also using sbt 0.12
Your global sbt folder is at %USERPROFILE%\.sbt (C:\Users\<username>\.sbt most likely). So your plugins should be defined at %USERPROFILE%\.sbt\plugins\plugins.sbt
Failing this you can add it to your project directly. Add the file path is <project_root>\project\plugins.sbt. If the project directory doesn't exist you will need to create it.
I think that I might have found a solution. First, the default directory checked for plugins configuration is 'USER_HOME/.sbt/plugins' and NOT 'USER_HOME/.sbt/0.13/plugins'.
Secondly, the sbt version specified seems to matter. In 'PROJECT_HOME/project/build.properties', there's an 'sbt.version' property. If the version of sbt specified in this file is different from the actually installed version of sbt, there's likely to be an issue. I think I was affected more so by this because I'm using an Activator template and it already had 'sbt.version' specified in this 'build.properties' file.
While nosing around, I came across this
"Support for plugin configuration in project/plugins/ has been removed. It was deprecated since 0.11.2" from sbt website at http://www.scala-sbt.org/0.13.0/docs/Community/ChangeSummary_0.13.0.html. I still see a lot of guys pointing that it should be configured in 'PROJECT_HOME/projects/plugins.sbt'. I think this is very confusing.
I had similar a issue and answered to a similar question.
I tried "everything" and, eventually, I just had to update my sbt from 0.13.1 to 0.13.9.