scala / scala3

The Scala 3 compiler, also known as Dotty.
https://dotty.epfl.ch
Apache License 2.0
5.8k stars 1.05k forks source link

after `dist/mkPack`, running `./dist/bin/scalac` doesn't work #15588

Open som-snytt opened 2 years ago

som-snytt commented 2 years ago

Compiler version

Latest

Minimized code

Scala 2 repo:

$ sbt dist/mkPack

$ build/pack/bin/scalac -version
Scala compiler version 2.13.5-20201119-215247-c758143 -- Copyright 2002-2020, LAMP/EPFL and Lightbend, Inc.

Output

Scala 3 repo:

$ sbt -no-colors dist/pack
[fix CR-NL in script files]
$ dist/bin/scalac -version
Error: Could not find or load main class dotty.tools.MainGenericCompiler
Caused by: java.lang.ClassNotFoundException: dotty.tools.MainGenericCompiler

However, release versions work

$ sdk use scala 3.1.3
$ scalac -version
Scala compiler version 3.1.3 -- Copyright 2002-2022, LAMP/EPFL

Expectation

Just work.

Also we need to pun on dist/bin and dust/bin.

SethTisue commented 5 months ago

I'm able to reproduce the problem on MacOS by starting with a clean checkout and then doing sbt dist/pack followed by chmod +x dist/bin/scalac and finally ./dist/bin/scalac -version

if I edit dist/bin/scalac and add -v so I can see what it's doing, then I see

"/usr/bin/java" -Xmx768m -Xms768m -classpath ":::::::::::::" -Dscala.usejavacp=true -Dscala.home="/Users/tisue/scala3/dist" dotty.tools.MainGenericCompiler '-version'

all those colons seem like the culprit

somewhat related: https://github.com/scala/scala3/pull/19894 provides alternative scripts

perhaps dist/bin/scalac has bitrotted since compiler developers probably normally use the scalac task in sbt?

som-snytt commented 5 months ago

Not a Scala 3 contributor, but I use bin/scalac, which is slow but effective for occasional use.

~/projects/dotty/bin/scalac