【问题标题】:SBT asks for credentials when creating a projectSBT 在创建项目时要求提供凭据
【发布时间】:2021-08-04 03:03:57
【问题描述】:

我对 Scala 和 SBT 完全陌生。我有 SBT 1.3.2 的 downloaded .tgz 存档,将其解压缩并将其 bin 目录添加到我在 Ubuntu 18.04 上的 PATH 中。

我正在关注official Getting Started guide,它提供了一个创建简单项目的命令。它应该这样运行:

$ sbt new sbt/scala-seed.g8
....
Minimum Scala build.

name [My Something Project]: hello

Template applied in ./hello

相反,它要求我提供凭据:

$ sbt new sbt/scala_seed.g8
[info] Set current project to code (in build file:/home/user/code/)
[info] Set current project to code (in build file:/home/user/code/)
Username:

我不知道该输入什么。我什至无法猜测,因为在它要求输入密码之前我只能输入一个字符。如果我再次输入一个字符,我会再次收到用户名提示。这是按两个键后的输出:

$ sbt new sbt/scala_seed.g8
[info] Set current project to code (in build file:/home/user/code/)
[info] Set current project to code (in build file:/home/user/code/)
Username: Password:
Username:

我只想设置一个基本项目。我做错了什么?

【问题讨论】:

  • 可能是底层的 git checkout 要求提供凭据。尝试独立的 git checkout/clone:git clone git@github.com:scala/scala-seed.g8.git /tmp/scala-seed.g8 看看是否可行。
  • 当我进一步前进时收到此消息时,似乎有些东西正在尝试与 github 帐户连接:https://github.com/scala/imba-hello.g8.git: not authorized 所以为了回答这个问题,我们需要知道如何绕过 github 登录过程,而只是下载项目。
  • @mana 的答案可以解决问题,但对于新人来说,这很简单:git clone git@github.com:scala/scala-seed.g8.git scala-seed.g8(或您可能喜欢的项目名称
  • 这里的问题是模板名称不正确,所以我在下面回答得很清楚。

标签: sbt


【解决方案1】:

如果您收到sbt new user/some.g8 询问Username:,那么您就知道您输入了模板路径,例如user/some.g8 不正确,因此它不作为 g8 模板存在。

请检查您是否必须更正模板路径并重试。

【讨论】:

    【解决方案2】:

    当我尝试按照https://docs.scala-lang.org/getting-started/sbt-track/getting-started-with-scala-and-sbt-on-the-command-line.html 的指令使用 sbt cli 创建一个新项目时,我也遇到了同样的错误。 我运行如下命令,

    sbt new hw/hello-world.g8
    

    按照上面的命令,我被提示输入用户名和密码。然后我再次运行它

    sbt new scala/hello-world.g8
    

    这次项目创建成功。 输出:

    hello-world.g8
    [info] welcome to sbt 1.3.13 (Oracle Corporation Java 1.8.0_261)
    [info] set current project to scala (in build file:/C:/scala/)
    [info] set current project to scala (in build file:/C:/scala/)
    
    A template to demonstrate a minimal Scala application
    
    name [Hello World template]: hello-world
    
    Template applied in C:\scala\.\hello-world
    

    所以命令“sbt new hw/hello-world.g8”中的hw是不正确的,它只能是“sbt new scala /hello-world.g8"。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-09-13
      • 2020-08-03
      • 1970-01-01
      • 2013-01-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多