VirtusLab / scala-cli

Scala CLI is a command-line tool to interact with the Scala language. It lets you compile, run, test, and package your Scala code (and more!)
https://scala-cli.virtuslab.org
Apache License 2.0
542 stars 128 forks source link

` -siteroot ${.}` combined with `--server=false` crashes compiler #2496

Closed WojciechMazur closed 10 months ago

WojciechMazur commented 11 months ago

Version(s) 1.0.4

Describe the bug Usage of directive //> using options -siteroot ${.} crashes compiler when used with --server=false

bad option '-siteroot' was ignored
exception occurred while compiling enum-extensions, project.scala
java.io.IOException: Is a directory while compiling /workspace/enum-extensions, /workspace/enum-extensions/project.scala
Exception in thread "main" java.io.IOException: Is a directory
        at java.base/sun.nio.ch.FileDispatcherImpl.read0(Native Method)
        at java.base/sun.nio.ch.FileDispatcherImpl.read(FileDispatcherImpl.java:48)
        at java.base/sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:276)
        at java.base/sun.nio.ch.IOUtil.read(IOUtil.java:245)
        at java.base/sun.nio.ch.FileChannelImpl.read(FileChannelImpl.java:223)
        at java.base/sun.nio.ch.ChannelInputStream.read(ChannelInputStream.java:65)
        at java.base/sun.nio.ch.ChannelInputStream.read(ChannelInputStream.java:107)
        at java.base/sun.nio.ch.ChannelInputStream.read(ChannelInputStream.java:101)
        at dotty.tools.io.AbstractFile.toByteArray(AbstractFile.scala:178)
        at dotty.tools.dotc.util.SourceFile$.apply(SourceFile.scala:271)
        at dotty.tools.dotc.core.Contexts$Context.getSource$$anonfun$1(Contexts.scala:237)
        at dotty.tools.dotc.util.GenericHashMap.getOrElseUpdate(GenericHashMap.scala:134)
        at dotty.tools.dotc.core.Contexts$Context.getSource(Contexts.scala:237)
        at dotty.tools.dotc.Run.$anonfun$1(Run.scala:178)
        at scala.collection.immutable.List.map(List.scala:246)
        at dotty.tools.dotc.Run.compile(Run.scala:178)
        at dotty.tools.dotc.Driver.doCompile(Driver.scala:35)
        at dotty.tools.dotc.Driver.process(Driver.scala:195)
        at dotty.tools.dotc.Driver.process(Driver.scala:163)
        at dotty.tools.dotc.Driver.process(Driver.scala:175)
        at dotty.tools.dotc.Driver.main(Driver.scala:205)
        at dotty.tools.dotc.Main.main(Main.scala)
Compilation failed

To Reproduce

  1. Create a single project.scala file with following content:
    
    //> using options -siteroot ${.}
2. Try to compile it 
```bash
scala-cli compile . --server=false

or

scala-cli compile project.scala --server=false

Expected behaviour Should not crash compiler

Gedochao commented 10 months ago
scalac -siteroot
# bad option '-siteroot' was ignored
# (...)
scalac -h 2> >(grep siteroot)
# no output
scaladoc -h 2> >(grep siteroot)
#               -siteroot  A directory containing static files from which to

-siteroot seems to be a scaladoc option, not a compiler option. so no wonder it won't work. we do not yet support passing scaladoc options, that can be tracked under #1559

Closing this ticket as invalid