bash - Scala 2.12.12 的 Shell 脚本损坏了?

标签 bash scala

我有一些使用 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/

相关文章:

bash - 检查 bash 中是否存在远程文件

regex - 在egrep的正则表达式中管道bash输入参数

linux - 在另一个脚本中使用脚本的结果

linux - 使用 HEREDOC 的 OPENSSL 自动应答密码

xml - 如何在Scala XML中使用not操作进行选择?

linux - 从 shell 脚本获取完整命令

Scala向量拼接(维护排序序列)

scala - SBT 和 Scala-IDE 中的同步增量编译

scala - 如何从映射中按原样检索派生类?

scala - scala中的私有(private)字段 setter