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

os/package.scala can throw a Fatal exception #24

Closed
virusdave opened this issue Jul 16, 2019 · 1 comment
Closed

os/package.scala can throw a Fatal exception #24

virusdave opened this issue Jul 16, 2019 · 1 comment

Comments

@virusdave
Copy link

Specifically

val pwd: Path = os.Path(new java.io.File("").getCanonicalPath)

This can fail by:

: java.lang.ExceptionInInitializerError: null
:         at os.proc$$anonfun$spawn$4.apply(ProcessOps.scala:219) ~[3rdparty.jvm.lihaoyi-os-lib-0.jar:?]
:         at scala.Option.getOrElse(Option.scala:121) ~[3rdparty.jvm.enumeratum-2.jar:?]
:         at os.proc.spawn(ProcessOps.scala:219) ~[3rdparty.jvm.lihaoyi-os-lib-0.jar:?]
:         at os.proc.stream(ProcessOps.scala:101) ~[3rdparty.jvm.lihaoyi-os-lib-0.jar:?]
:         at os.proc.call(ProcessOps.scala:61) ~[3rdparty.jvm.lihaoyi-os-lib-0.jar:?]
: Caused by: java.lang.IllegalArgumentException: requirement failed: ? is not an absolute path
:         at scala.Predef$.require(Predef.scala:224) ~[3rdparty.jvm.enumeratum-2.jar:?]
:         at os.Path.<init>(Path.scala:327) ~[3rdparty.jvm.lihaoyi-os-lib-0.jar:?]
:         at os.Path$.apply(Path.scala:287) ~[3rdparty.jvm.lihaoyi-os-lib-0.jar:?]
:         at os.package$.<init>(package.scala:19) ~[3rdparty.jvm.lihaoyi-os-lib-0.jar:?]
:         at os.package$.<clinit>(package.scala) ~[3rdparty.jvm.lihaoyi-os-lib-0.jar:?]

Context: I was trying to us os.proc.call(), wrapped in a Try { } block in case it failed. Much to my surprise, this process died in prod with an exception that is excluded from NonFatal(), due apparently to os.File's constructor not liking the return value from new java.io.File("").getCanonicalPath apparently.

I see you addressed a similar issue here:
com-lihaoyi/Ammonite#376

Ultimately, i expect that Path's constructor should not be throwing like this, so should probably be less sensitive to the underlying FS implementation perhaps?

This is with version 0.2.9 for scala 2.11

@lihaoyi-databricks
Copy link
Collaborator

Swapped over to using java.nio to do this in master, hopefully that should be a bit more robust

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants