Marcus
Marcus

Reputation: 2103

Shell scripts with Scala 2.12.12 broken?

I have some shell scripts running with Scala 2.12.11. After updating to Scala 2.12.12 they don't do anymore.

Example:

#!/bin/bash
echo "in Bash"
exec scala "$0" "$@"
!#
object Example { def main(args: Array[String]) = println("in Scala") }

Result with Scala 2.12.11:

in Bash
in Scala

Result with 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

Any idea?

Upvotes: 2

Views: 109

Answers (1)

Marcus
Marcus

Reputation: 2103

Uninstalling Scala does not stop the compiler daemon. Thus after the update the running daemon does not match the Scala version anymore. Stopping the old daemon (once) with fsc -shutdown solves the problem.

Alternatively, you can avoid the daemon altogether by adding -nocompdaemon to the scala call. Starting with Scala 2.13.0 this is done by default (according to issue 12102).

#!/bin/bash
echo "in Bash"
exec scala -nocompdaemon "$0" "$@"
!#
object Example { def main(args: Array[String]) = println("in Scala") }

Upvotes: 2

Related Questions