Search code examples
scalaemacsinstallationensime

Installing ensime in existing project cannot resolve dependency


I started an android project in scala recently, I'm an emacs nerd, and I wanted to use ensime in emacs instead of IntelliJ. Per the installation instructions, and this post:

Installing Ensime for Scala Development on emacs: sbt.ResolveException: unresolved dependency: org.ensime#ensime-sbtt-cmd;0.12: not found

my ~/.sbt/plugins/plugins.sbt looks like this:

resolvers += "Sonatype releases" at "https://oss.sonatype.org/content/repositories/snapshots"

addSbtPlugin("org.ensime" % "ensime-sbt-cmd" % "0.1.2")

and my project's project/plugins.sbt looks like this:

addSbtPlugin("org.scala-sbt" % "sbt-android" % "0.7.1-SNAPSHOT")

(though I don't think that's related).

When I run sbt, the output looks like the following:

[info] Loading global plugins from /Users/jmiles/.sbt/plugins
[info] Updating {file:/Users/jmiles/.sbt/plugins/}default-bdeac8...
[info] Resolving org.ensime#ensime-sbt-cmd;0.1.2 ...
[warn]  module not found: org.ensime#ensime-sbt-cmd;0.1.2
[warn] ==== typesafe-ivy-releases: tried
[warn]   http://repo.typesafe.com/typesafe/ivy-releases/org.ensime/ensime-sbt-cmd/scala_2.9.2/sbt_0.12/0.1.2/ivys/ivy.xml
[warn] ==== sbt-plugin-releases: tried
[warn]   http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases/org.ensime/ensime-sbt-cmd/scala_2.9.2/sbt_0.12/0.1.2/ivys/ivy.xml
[warn] ==== local: tried
[warn]   /Users/jmiles/.ivy2/local/org.ensime/ensime-sbt-cmd/scala_2.9.2/sbt_0.12/0.1.2/ivys/ivy.xml
[warn] ==== Sonatype releases: tried
[warn]   https://oss.sonatype.org/content/repositories/snapshots/org/ensime/ensime-sbt-cmd_2.9.2_0.12/0.1.2/ensime-sbt-cmd-0.1.2.pom
[warn] ==== public: tried
[warn]   http://repo1.maven.org/maven2/org/ensime/ensime-sbt-cmd_2.9.2_0.12/0.1.2/ensime-sbt-cmd-0.1.2.pom
[info] Resolving org.scala-sbt#precompiled-2_10_0-m7;0.12.1 ...
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  ::          UNRESOLVED DEPENDENCIES         ::
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  :: org.ensime#ensime-sbt-cmd;0.1.2: not found
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn] 
[warn]  Note: Some unresolved dependencies have extra attributes.  Check that these dependencies exist with the requested attributes.
[warn]      org.ensime:ensime-sbt-cmd:0.1.2 (sbtVersion=0.12, scalaVersion=2.9.2)
[warn] 
sbt.ResolveException: unresolved dependency: org.ensime#ensime-sbt-cmd;0.1.2: not found
    at sbt.IvyActions$.sbt$IvyActions$$resolve(IvyActions.scala:214)
    at sbt.IvyActions$$anonfun$update$1.apply(IvyActions.scala:122)
    at sbt.IvyActions$$anonfun$update$1.apply(IvyActions.scala:121)
    at sbt.IvySbt$Module$$anonfun$withModule$1.apply(Ivy.scala:114)
    at sbt.IvySbt$Module$$anonfun$withModule$1.apply(Ivy.scala:114)
    at sbt.IvySbt$$anonfun$withIvy$1.apply(Ivy.scala:102)
    at sbt.IvySbt.liftedTree1$1(Ivy.scala:49)

        (etc.)

Any help?


Solution

  • I get this all the time with dependencies. While I have no explanation for it, here are the common patterns that recur over and over.

    Often, the code given by the plugin/library developer is wrong. When I go to their maven repository the version they have listed doesn't exist in the repository. I just update it to the right version and then boom it works. Also, for some reason some plugins work when I put them in plugins.sbt (the suggested place). While others only work if I stick them in project/build.sbt. It doesn't make sense, but as soon as I move it there it suddenly installs and runs. Combined dependency listings. If you are hacking stuff together and stick a dependency in both build.scala and build.sbt, it will throw a generic error that is completely unhelpful. Remove one or the other and suddenly it runs.

    Also keep in mind that % causes a scala version to be appended to the name of it. whereas %% defines the name explicitly. Sometimes this causes errors when using % because it doesn't have a version available for that scala version. Go to the repository and enter the name of the package explicitly to fix this.