Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LastOnEmptyPath when installing in Alpine #2758

Closed
DavidPerezIngeniero opened this issue Feb 26, 2024 · 9 comments · Fixed by #3131
Closed

LastOnEmptyPath when installing in Alpine #2758

DavidPerezIngeniero opened this issue Feb 26, 2024 · 9 comments · Fixed by #3131
Assignees
Labels
bug Something isn't working

Comments

@DavidPerezIngeniero
Copy link

Version(s)

Describe the bug
I'm following this guide to install scala-cli on Alpine:
https://scala-cli.virtuslab.org/install

wget -q -O scala-cli.gz  https://github.com/Virtuslab/scala-cli/releases/latest/download/scala-cli-x86_64-pc-linux-static.gz && gunzip scala-cli.gz
chmod +x scala-cli
mv scala-cli /usr/bin/

It works ok, but when trying to run it:

# scala-cli repl
Error: os.PathError$LastOnEmptyPath: empty path has no last segment
For more details, please see '/.scala-build/stacktraces/1708946925-1039453487471597717.log'

# cat /.scala-build/stacktraces/1708946925-1039453487471597717.log
os.PathError$LastOnEmptyPath: empty path has no last segment
  os.PathError$LastOnEmptyPath$.apply(Path.scala:228)
  os.BasePathImpl.last$$anonfun$1(Path.scala:210)
  scala.Option.getOrElse(Option.scala:201)
  os.BasePathImpl.last(Path.scala:210)
  os.BasePathImpl.last$(Path.scala:190)
  os.Path.last(Path.scala:483)
  os.BasePathImpl.baseName(Path.scala:205)
  os.BasePathImpl.baseName$(Path.scala:190)
  os.Path.baseName(Path.scala:483)
  scala.build.input.Inputs$.empty(Inputs.scala:469)
  scala.cli.commands.repl.Repl$.default$1$$anonfun$1(Repl.scala:108)
  scala.Option.getOrElse(Option.scala:201)
  scala.cli.commands.repl.Repl$.default$1(Repl.scala:109)
  scala.cli.commands.repl.Repl$.$anonfun$9(Repl.scala:111)
  scala.build.input.Inputs$.apply(Inputs.scala:442)
  scala.cli.commands.shared.SharedOptions$.inputs(SharedOptions.scala:680)
  scala.cli.commands.shared.SharedOptions.inputs(SharedOptions.scala:600)
  scala.cli.commands.repl.Repl$.runCommand(Repl.scala:111)
  scala.cli.commands.repl.Repl$.runCommand(Repl.scala:105)
  scala.cli.commands.ScalaCommand.run(ScalaCommand.scala:368)
  scala.cli.commands.ScalaCommand.run(ScalaCommand.scala:350)
  caseapp.core.app.CaseApp.main(CaseApp.scala:157)
  scala.cli.commands.ScalaCommand.main(ScalaCommand.scala:335)
  caseapp.core.app.CommandsEntryPoint.main(CommandsEntryPoint.scala:166)
  scala.cli.ScalaCliCommands.main(ScalaCliCommands.scala:125)
  scala.cli.ScalaCli$.main0(ScalaCli.scala:269)
  scala.cli.ScalaCli$.main(ScalaCli.scala:108)
  scala.cli.ScalaCli.main(ScalaCli.scala)

To Reproduce

docker run -ti --rm --entrypoint ash bellsoft/liberica-openjdk-alpine:21.0.2-cd
wget -q -O scala-cli.gz  https://github.com/Virtuslab/scala-cli/releases/latest/download/scala-cli-x86_64-pc-linux-static.gz && gunzip scala-cli.gz
chmod +x scala-cli
mv scala-cli /usr/bin/

Expected behaviour
I can use scala-cli.

@DavidPerezIngeniero DavidPerezIngeniero added the bug Something isn't working label Feb 26, 2024
@DavidPerezIngeniero
Copy link
Author

In addition, it would be interesting to execute:

rm -f scala-cli.gz

@DavidPerezIngeniero
Copy link
Author

Same problem happens with this image:

docker run -ti --rm --entrypoint ash alpine

Latest alpine 3.19.1.

@DavidPerezIngeniero
Copy link
Author

@francisdb
Copy link

francisdb commented Aug 26, 2024

@Gedochao we are encountering this issue when trying to build the scala sbt docker image since Scala 3.5.0. Any hints on how to fix this? See sbt/docker-sbt#298

root@00eff3a8e8f5:/# scala
Error: os.PathError$LastOnEmptyPath: empty path has no last segment
For more details, please see '/.scala-build/stacktraces/1724705569-3531744079478753600.log'

edit: a workaround is not running a script in the fs root

@francisdb
Copy link

Also happens on some non-alpine systems when running a script in the root of the filesystem.

tgodzik added a commit to tgodzik/scala-cli that referenced this issue Aug 27, 2024
I am not sure why this wouldn't work with `os.root`, but at least this should not throw.

Should fix VirtusLab#2758
@tgodzik
Copy link
Member

tgodzik commented Aug 27, 2024

This is interesting, it should not happen since we already check for root. I added additional check in #3131

@lbialy
Copy link

lbialy commented Aug 27, 2024

Isn't that related to com-lihaoyi/os-lib#276 ?

@tgodzik
Copy link
Member

tgodzik commented Aug 27, 2024

I think this one is different, since we already check for root and return empty string in the case.

@francisdb
Copy link

francisdb commented Aug 27, 2024

For reference I'm pasting the stack trace we got using the scala 3.5.0 sbt docker build:

root@00eff3a8e8f5:/# scala run test.scala
Error: os.PathError$LastOnEmptyPath: empty path has no last segment
For more details, please see '/.scala-build/stacktraces/1724704787-6633636436291166558.log'
root@00eff3a8e8f5:/# cat /.scala-build/stacktraces/1724704787-6633636436291166558.log
os.PathError$LastOnEmptyPath: empty path has no last segment
  os.PathError$LastOnEmptyPath$.apply(Path.scala:228)
  os.BasePathImpl.last$$anonfun$1(Path.scala:210)
  scala.Option.getOrElse(Option.scala:201)
  os.BasePathImpl.last(Path.scala:210)
  os.BasePathImpl.last$(Path.scala:190)
  os.Path.last(Path.scala:483)
  os.BasePathImpl.baseName(Path.scala:205)
  os.BasePathImpl.baseName$(Path.scala:190)
  os.Path.baseName(Path.scala:483)
  scala.build.input.Inputs$.forValidatedElems(Inputs.scala:155)
  scala.build.input.Inputs$.forNonEmptyArgs(Inputs.scala:415)
  scala.build.input.Inputs$.apply(Inputs.scala:460)
  scala.cli.commands.shared.SharedOptions$.inputs(SharedOptions.scala:692)
  scala.cli.commands.shared.SharedOptions.inputs(SharedOptions.scala:612)
  scala.cli.commands.run.Run$.runCommand(Run.scala:140)
  scala.cli.commands.run.Run$.runCommand(Run.scala:68)
  scala.cli.commands.run.Run$.runCommand(Run.scala:61)
  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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants