【问题标题】:Is there any way to install Scala Ammonite-REPL in Windows 8.1有没有办法在 Windows 8.1 中安装 Scala Ammonite-REPL
【发布时间】:2020-11-19 03:06:23
【问题描述】:

我正在寻找如何在Windows 8.1 中安装Scala Ammonite-REPL,但我没有在网上找到任何东西。

有人知道这方面的相关吗?

有什么办法吗?

【问题讨论】:

  • 我只是建议您使用类似 WSL 或虚拟机之类的东西。 Windows 并不是一个真正适合开发的操作系统。
  • 嗨@Luis 谢谢你的回复,这是真的,我同意你关于Windows的看法,但我在Windows 8中没有WSL,我相信WSL不能安装在Window中8.1github.com/Microsoft/WSL/issues/3115。问题是我也无法在该 PC 中安装任何虚拟机。我安装了经典的 Scala REPL,但我想要 Ammonite,因为我认为它更好。
  • 也许 ammonite 可以在 git bash 上工作?其他选择是 cygwing。
  • 谢谢@Luis。我发现了这个:github.com/lihaoyi/Ammonite/issues/119 似乎它在 Windows 8.1 上不起作用。但是我通过 SBT 找到了一种方法。

标签: windows scala ammonite scala-repl


【解决方案1】:

我终于找到了自己问题的答案。

好像是Ammonite-REPL doesn't work on Windows 8.1

但是,它仍然可以通过 SBT 实现。

如果您有现有的 SBT 项目,则可以在 Windows 8.1 上运行 Ammonite。为此,请将以下内容添加到您的 build.sbt

libraryDependencies += {
  val version = scalaBinaryVersion.value match {
    case "2.10" => "1.0.3"
    case _ => "2.2.0"
  }
  "com.lihaoyi" % "ammonite" % version % "test" cross CrossVersion.full
}

sourceGenerators in Test += Def.task {
  val file = (sourceManaged in Test).value / "amm.scala"
  IO.write(file, """object amm extends App { ammonite.Main.main(args) }""")
  Seq(file)
}.taskValue

// Optional, required for the `source` command to work
(fullClasspath in Test) ++= {
  (updateClassifiers in Test).value
    .configurations
    .find(_.configuration.name == Test.name)
    .get
    .modules
    .flatMap(_.artifacts)
    .collect{case (a, f) if a.classifier == Some("sources") => f}
}

之后,只需点击

C:\Dir\...\projectName> sbt projectName/test:run

在我的情况下,如下图所示,它工作正常

【讨论】:

    猜你喜欢
    • 2012-08-24
    • 2017-04-29
    • 2019-03-01
    • 1970-01-01
    • 2020-06-06
    • 2012-08-17
    • 1970-01-01
    • 2020-11-11
    • 1970-01-01
    相关资源
    最近更新 更多