【问题标题】:sbt console how to update to latest Scala version?sbt 控制台如何更新到最新的 Scala 版本?
【发布时间】:2018-03-14 14:03:22
【问题描述】:

我已经按照Installing sbt on Linux 中的说明安装了 sbt。

$ sbt --version
sbt launcher version **0.13.8**
$ sbt console
[info] Starting scala interpreter...
[info] 
Welcome to Scala version 2.10.4 (OpenJDK 64-Bit Server VM, Java 1.7.0_79).

如何配置(或更新)sbt 以便sbt console 使用最新的Scala 版本2.11.6

【问题讨论】:

    标签: sbt


    【解决方案1】:

    创建build.sbt文件并输入scalaVersion

    scalaVersion := "2.11.5"
    

    在与build.sbt 相同的目录中运行sbt console,它将加载您指定的版本。

    ...:sbttest/ $ sbt console                                                                                                                                                                                                    [10:55:53]
    [info] Loading global plugins from /home/.../.sbt/0.13/plugins
    [info] Set current project to sbttest (in build file:/tmp/sbttest/)
    [info] Starting scala interpreter...
    [info] 
    Welcome to Scala version 2.11.5 (OpenJDK 64-Bit Server VM, Java 1.7.0_79).
    Type in expressions to have them evaluated.
    Type :help for more information.
    
    scala> 
    

    【讨论】:

    • 完美运行。首先sbt console 新的 Scala 2.11.6 二进制文件和依赖项会自动下载和安装。非常感谢先生的帮助。
    【解决方案2】:

    在与您的 build.sbt 相同的目录中运行 sbt 控制台,它将加载您指定的版本。

    也可以将build.sbt文件放到.sbt/0.13/目录下:

    cat <<END > ~/.sbt/0.13/build.sbt
    scalaVersion := "2.11.8"
    END
    

    然后,从其他任何地方执行sbt console 将为您提供您最喜欢的scala 版本。 (如果你执行sbt的目录中有本地的build.sbt文件,则本地指定的版本将覆盖全局)。

    【讨论】:

    • 对于 windows 转到 .sbt 文件夹(默认为 C:\Users\&lt;user&gt;\.sbt\0.13 )并使用 scalaVersion 信息创建一个新的 build.sbt 文件。这仍然需要在每次新的 scala 版本发布时手动更新;如果有办法将其指向“最新”,那就太好了。
    【解决方案3】:

    sbt ++ 2.11.11 console

    将 2.11.11 更改为您选择的 Scala 版本。

    来自sbt help ++

    ++ <scala-version> [<command>]
        Changes the Scala version and runs a command.
    
        Sets the `scalaVersion` of all projects to <scala-version> and 
        reloads the build.
        If <command> is provided, it is then executed.
    
    ++ [<scala-version>=]<scala-home> [<command>]
        Uses the Scala installation at <scala-home> by configuring the 
        scalaHome setting for
        all projects.
    
        If <scala-version> is specified, it is used as the value of the 
        scalaVersion setting.
        This is important when using managed dependencies.  This version 
        will determine the
        cross-version used as well as transitive dependencies.
    
        If <command> is provided, it is then executed.
    
        See also `help +`
    

    【讨论】:

    • 哇,这是一个令人讨厌的解决方案。非常感谢。
    猜你喜欢
    • 2019-06-15
    • 2012-09-24
    • 2020-06-22
    • 1970-01-01
    • 2018-12-03
    • 2018-02-06
    • 1970-01-01
    • 1970-01-01
    • 2016-03-06
    相关资源
    最近更新 更多