VirtusLab/scala-cli

`--classpath` fails when it contains a directory in command `package` but works with `compile`

joan38 opened this issue · 0 comments

Version(s)
1.4.3

Describe the bug
--classpath is not handled the same between the commands package and compile.
package fails if it contains directories which is what compile --print-classpath outputs.

To Reproduce

# Install scala cli
curl -o scala https://raw.githubusercontent.com/VirtusLab/scala-cli/main/scala-cli.sh && chmod +x scala

# Setup projects
mkdir lib  && cd $_
echo "def displayMessage = println(\"Lib\")" > displayMessage.scala

mkdir app && cd $_
echo "@main def run = displayMessage" > run.scala

# Compile, package...
cd ..
./scala compile --print-classpath lib
# Copy the output classpath

# The following works:
./scala compile --classpath <past the previously copied classpath here> app
# Whereas the following does not:
./scala --power package --classpath <past the previously copied classpath here> app
Error: java.io.IOException: Is a directory
For more details, please see '...'
java.io.IOException: Is a directory
  java.base@17.0.6/sun.nio.ch.FileDispatcherImpl.read0(FileDispatcherImpl.java)
  java.base@17.0.6/sun.nio.ch.FileDispatcherImpl.read(FileDispatcherImpl.java:48)
  java.base@17.0.6/sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:330)
  java.base@17.0.6/sun.nio.ch.IOUtil.read(IOUtil.java:296)
  java.base@17.0.6/sun.nio.ch.IOUtil.read(IOUtil.java:273)
  java.base@17.0.6/sun.nio.ch.FileChannelImpl.read(FileChannelImpl.java:232)
  java.base@17.0.6/sun.nio.ch.ChannelInputStream.read(ChannelInputStream.java:65)
  java.base@17.0.6/sun.nio.ch.ChannelInputStream.read(ChannelInputStream.java:107)
  java.base@17.0.6/sun.nio.ch.ChannelInputStream.read(ChannelInputStream.java:101)
  java.base@17.0.6/java.io.InputStream.read(InputStream.java:218)
  os.Internals$.transfer0(Internals.scala:14)
  os.Internals$.transfer(Internals.scala:22)
  os.read$bytes$.apply(ReadWriteOps.scala:273)
  scala.cli.commands.package0.Package$.$anonfun$27(Package.scala:749)
  scala.collection.immutable.List.map(List.scala:247)
  scala.collection.immutable.List.map(List.scala:79)
  scala.cli.commands.package0.Package$.bootstrap$$anonfun$1(Package.scala:749)
  scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
  scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
  scala.build.EitherCps$Helper.apply(EitherCps.scala:19)
  scala.cli.commands.package0.Package$.bootstrap(Package.scala:796)
  scala.cli.commands.package0.Package$.doPackage$$anonfun$1(Package.scala:316)
  scala.build.EitherCps$Helper.apply(EitherCps.scala:19)
  scala.cli.commands.package0.Package$.doPackage(Package.scala:526)
  scala.cli.commands.package0.Package$.runCommand(Package.scala:155)
  scala.cli.commands.package0.Package$.runCommand(Package.scala:71)
  scala.cli.commands.ScalaCommand.run(ScalaCommand.scala:379)
  scala.cli.commands.ScalaCommand.run(ScalaCommand.scala:361)
  caseapp.core.app.CaseApp.main(CaseApp.scala:157)
  scala.cli.commands.ScalaCommand.main(ScalaCommand.scala:346)
  caseapp.core.app.CommandsEntryPoint.main(CommandsEntryPoint.scala:169)
  scala.cli.ScalaCliCommands.main(ScalaCliCommands.scala:125)
  scala.cli.ScalaCli$.main0(ScalaCli.scala:291)
  scala.cli.ScalaCli$.main(ScalaCli.scala:117)
  scala.cli.ScalaCli.main(ScalaCli.scala)

Expected behaviour
--classpath should handle directories

Thanks