Error: os.PathError$LastOnEmptyPath: empty path has no last segment
Although this could be avoided in client code, it would require any os.Path object to be tested before referencing baseName.
One way to avoid the exception would be to redefine os.root.baseName as the empty String. However, the jvm defines the empty String as pwd, so if os.root.baseName is also the empty String, that would make it equal to pwd, which is a problem.
Shell environments (mostly) treat the root directory as its own parent, which is much easier to work with. For example, /usr/bin/basename takes this approach. The expression basename / resolves to /.
Defining os.root.baseName as s"$driveRoot/" resolves the scala-cli bug.
A new
scala-cli
bug is caused byos.root.baseName
~being an empty string~ throwing an exception.https://github.com/VirtusLab/scala-cli/issues/2954 If a
scala-cli
script resides in the root directory, it crashes with an error message:Although this could be avoided in client code, it would require any
os.Path
object to be tested before referencingbaseName
.One way to avoid the exception would be to redefine
os.root.baseName
as the empty String. However, thejvm
defines the empty String aspwd
, so ifos.root.baseName
is also the empty String, that would make it equal topwd
, which is a problem.Shell environments (mostly) treat the root directory as its own parent, which is much easier to work with. For example,
/usr/bin/basename
takes this approach. The expressionbasename /
resolves to/
.Defining
os.root.baseName
ass"$driveRoot/"
resolves thescala-cli
bug.This is the approach taken by PR #277