我对 Scala 和 SBT 完全陌生。我有 downloaded .tgz
SBT 1.3.2 存档,解压并添加 bin
目录到我的 PATH
在 Ubuntu 18.04 上。
我正在关注 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:
我只想设置一个基本项目。我究竟做错了什么?
最佳答案
当我尝试按照 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”中是不正确的,它只能是“sbt new scala /hello-world.g8”。
关于SBT 在创建项目时要求提供凭据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58057826/