我最近在scala中启动了一个android项目,我是一个emacs书呆子,我想在emacs中使用ensime而不是IntelliJ。根据安装说明和本帖:
在emacs:sbt上安装Ensime for Scala Development。ResolveException:未解析的依赖项:org.ensime#ensime sbtt cmd;0.12:未找到
my~/.sbt/plugins/plugins.sbt看起来像这样:
resolvers += "Sonatype releases" at "https://oss.sonatype.org/content/repositories/snapshots"
addSbtPlugin("org.ensime" % "ensime-sbt-cmd" % "0.1.2")
我的项目的project/plugins.sbt看起来是这样的:
addSbtPlugin("org.scala-sbt" % "sbt-android" % "0.7.1-SNAPSHOT")
(尽管我认为这与此无关)。
当我运行sbt时,输出如下所示:
[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.)
有什么帮助吗?
我总是通过依赖关系得到这个。虽然我对此没有任何解释,但以下是反复出现的常见模式。
通常,插件/库开发人员给出的代码是错误的。当我转到他们的maven存储库时,存储库中不存在他们列出的版本。我只是把它更新到正确的版本,然后就可以工作了。此外,由于某些原因,当我把一些插件放在plugins.sbt(建议的位置)中时,它们可以工作。而其他人只有当我把它们放在project/build.sbt中时才能工作。这没有意义,但我一把它移到那里,它就会突然安装并运行。组合的依赖项列表。如果你把东西拼凑在一起,并在build.scala和build.sbt中都粘贴一个依赖项,它会抛出一个完全没有帮助的通用错误。取下其中一个,它就会突然运行。
还要记住,%会导致一个scala版本附加到它的名称。而%%会显式定义名称。有时,使用%时会导致错误,因为它没有可用于该scala版本的版本。转到存储库并明确输入包的名称以解决此问题。
ensime 0.1.2仅适用于sbt 0.13.x版本。如果这是一个新项目,您可以考虑使用当前版本的sbt。通常,您可以通过创建包含sbt.version=0.13.0
的project/build.properties
来完成此操作