我有一些使用 Scala 2.12.11 运行的 shell 脚本。更新到 Scala 2.12.12 后,它们不再执行此操作。
示例:
#!/bin/bash
echo "in Bash"
exec scala "$0" "$@"
!#
object Example { def main(args: Array[String]) = println("in Scala") }
Scala 2.12.11 的结果:
in Bash
in Scala
Scala 2.12.12 的结果:
in Bash
fscbad option: '-Ytrack-dependencies'
fsc -help gives more information
error: IO error while decoding /home/marcus/-Ytrack-dependencies with UTF-8: /home/marcus/-Ytrack-dependencies (No such file or directory)
Please try specifying another one using the -encoding option
error: IO error while decoding /home/marcus/-Xscript with UTF-8: /home/marcus/-Xscript (No such file or directory)
Please try specifying another one using the -encoding option
error: IO error while decoding /home/marcus/Main with UTF-8: /home/marcus/Main (No such file or directory)
Please try specifying another one using the -encoding option
three errors found
有什么想法吗?
最佳答案
卸载 Scala 不会停止编译器守护进程。因此,更新后运行的守护进程不再与 Scala 版本匹配。使用 fsc -shutdown
停止旧守护进程(一次)可以解决问题。
或者,您可以通过将 -nocompdaemon
添加到 scala
调用中来完全避免守护进程。从 Scala 2.13.0 开始,这是默认完成的(根据 issue 12102 )。
#!/bin/bash
echo "in Bash"
exec scala -nocompdaemon "$0" "$@"
!#
object Example { def main(args: Array[String]) = println("in Scala") }
关于bash - Scala 2.12.12 的 Shell 脚本损坏了?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63154499/