scala - 为什么 sbt 在 Play 项目中报告 "value enablePlugins is not a member of sbt.Project"?

标签 scala sbt playframework-2.3

在尝试编译任何 Play 应用程序时,我刚刚收到以下错误:

error: value enablePlugins is not a member of sbt.Project
lazy val root = (project in file(".")).enablePlugins(PlayScala)
                                       ^
sbt.compiler.EvalException: Type error in expression
    at sbt.compiler.Eval.checkError(Eval.scala:343)
    at sbt.compiler.Eval.compileAndLoad(Eval.scala:165)
    at sbt.compiler.Eval.evalCommon(Eval.scala:135)
    at sbt.compiler.Eval.evalDefinitions(Eval.scala:109)
     ...
     ...
   sbt.compiler.EvalException: Type error in expression
Use 'last' for the full log.
Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore?
Failed to reload source file list: sbt process never got in touch, 
so unable to handle request WatchTransitiveSourcesRequest(true)

我在其他地方看到过一些关于这个错误的讨论,但与那些示例不同的是,我没有任何额外的插件或项目依赖项——我在编译一个未修改的 play-scala 时遇到了这个错误。使用 activator new 选择后的模板.

以下是 project/plugins.sbt 模板中包含的插件:
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"

// The Play plugin
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.3.3")

// web plugins
addSbtPlugin("com.typesafe.sbt" % "sbt-coffeescript" % "1.0.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-less" % "1.0.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-jshint" % "1.0.1")
addSbtPlugin("com.typesafe.sbt" % "sbt-rjs" % "1.0.1")
addSbtPlugin("com.typesafe.sbt" % "sbt-digest" % "1.0.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-mocha" % "1.0.0")

我上一次构建 Play 应用程序是大约一个月前,我没有遇到任何问题,同时我一直在编译纯 Scala 应用程序(通常使用 Activator),没有任何问题。这可能与 Play-2.3 相关吗?

我有专线 sbt.version=0.13.5project/build.properties我确保我的 sbt 版本是最新的。

我的代码正是 play-scala 的代码模板,但如果它使事情变得更容易,这里是 build.sbt 的内容:
name := """my-first-app"""

version := "1.0-SNAPSHOT"

lazy val root = (project in file(".")).enablePlugins(PlayScala)

scalaVersion := "2.11.1"

libraryDependencies ++= Seq(
  jdbc,
  anorm,
  cache,
  ws
)

在此先感谢您的帮助。

编辑:

sbt about从应用程序根目录我收到此错误,我将完整包含:
$ sbt about
[info] Loading global plugins from /home/.sbt/0.13/plugins
[info] Loading project definition from /home/my-first-app/project
/home/my-first-app/build.sbt:5: error: value enablePlugins is not a member of sbt.Project
lazy val root = (project in file(".")).enablePlugins(PlayScala)
                                       ^
sbt.compiler.EvalException: Type error in expression
    at sbt.compiler.Eval.checkError(Eval.scala:343)
    at sbt.compiler.Eval.compileAndLoad(Eval.scala:165)
    at sbt.compiler.Eval.evalCommon(Eval.scala:135)
    at sbt.compiler.Eval.evalDefinitions(Eval.scala:109)
    at sbt.EvaluateConfigurations$.evaluateDefinitions(EvaluateConfigurations.scala:197)
    at sbt.EvaluateConfigurations$.evaluateSbtFile(EvaluateConfigurations.scala:99)
    at sbt.Load$.sbt$Load$$loadSettingsFile$1(Load.scala:507)
    at sbt.Load$$anonfun$sbt$Load$$memoLoadSettingsFile$1$1.apply(Load.scala:502)
    at sbt.Load$$anonfun$sbt$Load$$memoLoadSettingsFile$1$1.apply(Load.scala:501)
    at scala.Option.getOrElse(Option.scala:120)
    at sbt.Load$.sbt$Load$$memoLoadSettingsFile$1(Load.scala:501)
    at sbt.Load$$anonfun$loadSettings$1$2.apply(Load.scala:500)
    at sbt.Load$$anonfun$loadSettings$1$2.apply(Load.scala:500)
    at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)
    at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)
    at scala.collection.mutable.ResizableArray$class.foreach(ResizableArray.scala:59)
    at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:47)
    at scala.collection.TraversableLike$class.map(TraversableLike.scala:244)
    at scala.collection.AbstractTraversable.map(Traversable.scala:105)
    at sbt.Load$.loadSettings$1(Load.scala:500)
    at sbt.Load$.sbt$Load$$expand$1(Load.scala:523)
    at sbt.Load$.loadSettings(Load.scala:528)
    at sbt.Load$.sbt$Load$$loadSbtFiles$1(Load.scala:464)
    at sbt.Load$.defaultLoad$1(Load.scala:475)
    at sbt.Load$.loadTransitive(Load.scala:478)
    at sbt.Load$.loadProjects$1(Load.scala:418)
    at sbt.Load$.loadUnit(Load.scala:419)
    at sbt.Load$$anonfun$15$$anonfun$apply$11.apply(Load.scala:256)
    at sbt.Load$$anonfun$15$$anonfun$apply$11.apply(Load.scala:256)
    at sbt.BuildLoader$$anonfun$componentLoader$1$$anonfun$apply$4$$anonfun$apply$5$$anonfun$apply$6.apply(BuildLoader.scala:93)
    at sbt.BuildLoader$$anonfun$componentLoader$1$$anonfun$apply$4$$anonfun$apply$5$$anonfun$apply$6.apply(BuildLoader.scala:92)
    at sbt.BuildLoader.apply(BuildLoader.scala:143)
    at sbt.Load$.loadAll(Load.scala:312)
    at sbt.Load$.loadURI(Load.scala:264)
    at sbt.Load$.load(Load.scala:260)
    at sbt.Load$.load(Load.scala:251)
    at sbt.Load$.apply(Load.scala:134)
    at sbt.Load$.defaultLoad(Load.scala:37)
    at sbt.BuiltinCommands$.doLoadProject(Main.scala:473)
    at sbt.BuiltinCommands$$anonfun$loadProjectImpl$2.apply(Main.scala:467)
    at sbt.BuiltinCommands$$anonfun$loadProjectImpl$2.apply(Main.scala:467)
    at sbt.Command$$anonfun$applyEffect$1$$anonfun$apply$2.apply(Command.scala:60)
    at sbt.Command$$anonfun$applyEffect$1$$anonfun$apply$2.apply(Command.scala:60)
    at sbt.Command$$anonfun$applyEffect$2$$anonfun$apply$3.apply(Command.scala:62)
    at sbt.Command$$anonfun$applyEffect$2$$anonfun$apply$3.apply(Command.scala:62)
    at sbt.Command$.process(Command.scala:95)
    at sbt.MainLoop$$anonfun$1$$anonfun$apply$1.apply(MainLoop.scala:100)
    at sbt.MainLoop$$anonfun$1$$anonfun$apply$1.apply(MainLoop.scala:100)
    at sbt.State$$anon$1.process(State.scala:179)
    at sbt.MainLoop$$anonfun$1.apply(MainLoop.scala:100)
    at sbt.MainLoop$$anonfun$1.apply(MainLoop.scala:100)
    at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:18)
    at sbt.MainLoop$.next(MainLoop.scala:100)
    at sbt.MainLoop$.run(MainLoop.scala:93)
    at sbt.MainLoop$$anonfun$runWithNewLog$1.apply(MainLoop.scala:71)
    at sbt.MainLoop$$anonfun$runWithNewLog$1.apply(MainLoop.scala:66)
    at sbt.Using.apply(Using.scala:25)
    at sbt.MainLoop$.runWithNewLog(MainLoop.scala:66)
    at sbt.MainLoop$.runAndClearLast(MainLoop.scala:49)
    at sbt.MainLoop$.runLoggedLoop(MainLoop.scala:33)
    at sbt.MainLoop$.runLogged(MainLoop.scala:25)
    at sbt.StandardMain$.runManaged(Main.scala:57)
    at sbt.xMain.run(Main.scala:29)
    at xsbt.boot.Launch$$anonfun$run$1.apply(Launch.scala:109)
    at xsbt.boot.Launch$.withContextLoader(Launch.scala:129)
    at xsbt.boot.Launch$.run(Launch.scala:109)
    at xsbt.boot.Launch$$anonfun$apply$1.apply(Launch.scala:36)
    at xsbt.boot.Launch$.launch(Launch.scala:117)
    at xsbt.boot.Launch$.apply(Launch.scala:19)
    at xsbt.boot.Boot$.runImpl(Boot.scala:44)
    at xsbt.boot.Boot$.main(Boot.scala:20)
    at xsbt.boot.Boot.main(Boot.scala)
[error] sbt.compiler.EvalException: Type error in expression
[error] Use 'last' for the full log.
Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore? 

从应用程序目录外部执行此操作我得到:
$ sbt about
[info] Loading global plugins from /home/.sbt/0.13/plugins
[info] Set current project to / (in build file:/home/)
[info] This is sbt 0.13.5
[info] The current project is {file:/home/} 0.1-SNAPSHOT
[info] The current project is built against Scala 2.10.4
[info] Available Plugins: sbt.plugins.IvyPlugin, sbt.plugins.JvmPlugin, sbt.plugins.CorePlugin, sbt.plugins.JUnitXmlReportPlugin, EnsimePlugin, com.typesafe.sbt.SbtScalariform
[info] sbt, sbt plugins, and build definitions are using Scala 2.10.4

最佳答案

在评论之后,特别是。 the last one by the OP ,我相信原因可能是安装在~/.sbt/0.13/plugins下的插件。弄乱了 sbt.Project 的最新添加.这就是为什么我建议重命名特殊目录 ~/.sbt/0.13~/.sbt/0.13/plugins .

来自 Global plugins在 sbt 的官方文档中:

The ~/.sbt/0.13/plugins/ directory is treated as a global plugin definition project. It is a normal sbt project whose classpath is available to all sbt project definitions for that user as described above for per-project plugins.



至少有一个确认的案例过去发生过这样的插件 - sbt 在启用插件的情况下崩溃了,没有它它也能正常工作。见 print not accepted in task definition in SBT 0.13? .我想我看过另一个,但现在找不到它作为另一个引用。

关于scala - 为什么 sbt 在 Play 项目中报告 "value enablePlugins is not a member of sbt.Project"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25556143/

相关文章:

函数声明中的 Scala 元组提取

scala - 使用 Scala 的私有(private) final 修饰符?

Scala:隐式参数解析优先级

Scala:使用协变 Field[+T] 访问属性

scala - 将所有 SBT 目标目录更改为源外部

scala - 有没有办法通过命令行为 sbt 指定备用位置以查找构建配置?

json - 使用 Play JSON 的多个写入来呈现对象的不同 View

scala - 在正在运行的 Play 应用程序中获取所有事件的路由/路径

scala - 使用 Play Framework 的 Cached API 在多语言网站中缓存操作

scala - 从 sbt 运行 Play 项目