SBT 在创建项目时要求提供凭据

Elz*_*lzo 5 sbt

我对 Scala 和 SBT 完全陌生。我已经下载了SBT 1.3.2 的存档.tgz,将其解压并将其bin目录添加到我的PATHUbuntu 18.04 上。

我正在遵循官方的入门指南,该指南提供了创建一个简单项目的命令。它应该像这样运行:

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

name [My Something Project]: hello

Template applied in ./hello
Run Code Online (Sandbox Code Playgroud)

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

$ 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:
Run Code Online (Sandbox Code Playgroud)

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

$ 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:
Run Code Online (Sandbox Code Playgroud)

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

ekr*_*ich 6

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

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


Raj*_*r M 1

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

sbt new hw/hello-world.g8
Run Code Online (Sandbox Code Playgroud)

按照上述命令,系统会提示我输入用户名和密码。然后我再次运行它

sbt new scala/hello-world.g8
Run Code Online (Sandbox Code Playgroud)

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

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
Run Code Online (Sandbox Code Playgroud)

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