compiler-explorer / compiler-explorer/compiler-explorer

[BUG]: Scala Main/App execution throws "java.lang.ClassNotFoundException: scala.Predef$"

Open
#5,520 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
TypeScript
Stars
19.1k
Forks
2.1k
Avg merge
3d 15h
Merged PRs (30d)
67

Description

### Describe the bug

Godbolt cannot run executable Scala programs, even those from [the official docs.scala-lang page](https://docs.scala-lang.org/scala3/book/taste-hello-world.html)

Instead `java.lang.ClassNotFoundException: scala.Predef$` is thrown, which (after some light searching) indicates an incorrect class path.

However, the scala examples indicate that it should be (or it is at least easier to) run with the `scala` command after compiling with the `scalac` command.
For example:
```
> cat hello.scala
object hello {
def main(args: Array[String]) = {
println("Hello, World!")
}
}%
> scalac hello.scala
> scala hello
Hello, World!
```

### Steps to reproduce

Example:
1. Start new Scala source view
2. Copy/paste the Scala 2 Hello World example from [the official docs.scala-lang page](https://docs.scala-lang.org/scala3/book/taste-hello-world.html)
3. add new "Execution Only"
4. Choose your favorite Scala 2 version (I've replicated this with 2.12.14, 2.13.6, and 3.0.0)
5. Observe the `java.lang.ClassNotFoundException: scala.Predef$` exception

### Expected behavior

The program should run and print "Hello, World!"

### Reproduction link

https://godbolt.org/z/fc8Tfh1oY

### Screenshots

![Screenshot 2023-09-25 at 4 06 08 PM](https://github.com/compiler-explorer/compiler-explorer/assets/5678062/d0e74ccd-7ea9-4c3f-9a55-0ac5a1d0dd9b)

### Operating System

_No response_

### Browser version

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.