Weird Behaviour of scala.sys.process.Process.cat

I am attempting to concatenate the content of two files using scala.sys.process.Process.cat and pipe the result as an input to a process. While doing so, I encountered very weird behaviour with only the first file being taken into account.

To figure out what exactly was going wrong, I created the following minimal example:

import scala.sys.process.Process
import java.io.File

object HelloWorld {
  def main(args: Array[String]): Unit = {
    (Process.cat(List(new File("hello"), new File("world"))) #> new File("helloworld")).!
  }
}

When run, I would expect this code to concatenate the content of the files “hello” and “world”, and write them into the file “helloworld” (i.e. cat hello world > helloworld in bash terms).

However when I run this code, the following happens:

bash-3.2$ scala -version
Scala code runner version 2.12.5 -- Copyright 2002-2018, LAMP/EPFL and Lightbend, Inc.
bash-3.2$ echo "hello" > hello
bash-3.2$ echo "world" > world
bash-3.2$ scala example.scala
bash-3.2$ cat helloworld
hello
bash-3.2$

It seems that Process.cat() simply ignores the second file and only uses the first one.
Can anybody help me and tell me what I am doing wrong?

It works in 2.11, hangs in 2.12.0, and acquires its current behavior in 2.12.1.

This works:

Process.cat(List(new File("hello"), new File("world"))).!!

I’ll take a look. If you specify in your last will and testament who among your descendants will inherit this problem, I’ll try to make sure they receive a solution in the event one is found. We should probably put a contemporary computer into secure storage with latest Java and Scala installed, so that they will be able to run the fix. Also leave instructions for them to plug it in first, as it won’t work like the bio-implanted computing devices of the future.

ticket now at https://github.com/scala/bug/issues/10823