gpt4 book ai didi

sbt - SBT 中的控制台输入不回显到屏幕上

转载 作者:行者123 更新时间:2023-12-04 02:26:22 26 4
gpt4 key购买 nike

我希望我遗漏了一些东西,因为当程序在 sbt 中运行时,按键似乎不会回显到屏幕上。
下面是一个例子:

object ConsoleTest extends App {
println("Enter a line:")
val input = Console.readLine()
println("You entered: " + input)
}

当我编译这个简单的代码并从命令行(在 sbt 之外)运行它时,当我输入它们进行输入时,我看到了按键,并且一切正常。
不幸的是,当我使用 sbt 编译和运行相同的代码时,它根本不会将按键回显到屏幕上。这是一次令人不安的经历。
有没有其他人经历过这种差异?
我已经做了一些搜索,看看其他人是否遇到过这种情况,以及是否可能有一个 sbt 运行时参数来允许击键回显。到目前为止没有运气。
我正在使用 sbt-0.13.2 并且上述代码的 Java 版本也遇到了同样的差异,因此它似乎已本地化为在 sbt 环境中运行。
任何见解表示赞赏。

最佳答案

这个问题已经 2.5 年了,仍然没有答案,所以这里是 :)

我使用 Scala 2.12.1、SBT 0.13.13.1 在 Windows 10 上进行了测试。测试程序在 Cmd 和 WSL 的 bash 下运行良好。

从历史上看,此问题是 JLine 问题的征兆。您可以使用 jline.terminal 覆盖 JLine 设置Java 系统变量的值如 auto , nonewindows . Here are the complete docs .

以下是如何指定各种设置的一些示例:

C:\work\experiments\sbt\optionTest>sbt run
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
[info] Loading project definition from C:\work\experiments\sbt\optionTest\project
[info] Updating {file:/C:/work/experiments/sbt/optionTest/project/}optiontest-build...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.
[info] Set current project to change-me (in build file:/C:/work/experiments/sbt/optionTest/)
[warn] there was one deprecation warning (since 2.11.0); re-run with -deprecation for details
[warn] one warning found
Enter a line:
asdf
You entered: asdf
[success] Total time: 46 s, completed Jan 7, 2017 1:27:27 PM

C:\work\experiments\sbt\optionTest> sbt "-Djline.terminal=none" run
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
[info] Loading project definition from C:\work\experiments\sbt\optionTest\project
[info] Set current project to change-me (in build file:/C:/work/experiments/sbt/optionTest/)
Enter a line:
asdf
You entered: asdf
[success] Total time: 3 s, completed Jan 7, 2017 1:28:12 PM

C:\work\experiments\sbt\optionTest> sbt "-Djline.terminal=windows" run
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
[info] Loading project definition from C:\work\experiments\sbt\optionTest\project
[info] Set current project to change-me (in build file:/C:/work/experiments/sbt/optionTest/)
Enter a line:
asdf
You entered: asdf
[success] Total time: 3 s, completed Jan 7, 2017 1:28:26 PM

关于sbt - SBT 中的控制台输入不回显到屏幕上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23611588/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com