Skip to content

os.FilePath is not working correctly with relative path with scala native #392

@stephenamar-db

Description

@stephenamar-db

I'm currently working on debugging databricks/sjsonnet#374 and I think I stumbled upon an issue with scala native.

os.FilePath is not correctly resolving relative paths in scala native.

I tested with scala 2.12.X, 2.13.X and 3.3.X
Library version is com.lihaoyi::os-lib::0.11.4
Scala native version is 0.5.7

~/sjsonnet % uname -a                                                                                                                                           
Darwin QWYD2XFYYF 24.4.0 Darwin Kernel Version 24.4.0: Fri Apr 11 18:33:39 PDT 2025; root:xnu-11417.101.15~117/RELEASE_ARM64_T6020 arm64 arm Darwin

Test case:

import utest.{TestSuite, Tests, test}

object OsPathTest extends TestSuite {
  def tests: Tests = Tests {
    test("os.FilePath") - {
      assert(os.FilePath("../../bar.jsonnet").isInstanceOf[os.RelPath])
    }
  }
}

Scala Native:

~/sjsonnet % ./mill show "sjsonnet.native[3.3.6].test" "sjsonnet.OsPathTest"
[1/1] show
[1-143/150] sjsonnet.native[3.3.6].test.compile
[1-143] [info] compiling 27 Scala sources to /Users/stephen.amar/sjsonnet/out/sjsonnet/native/3.3.6/test/compile.dest/classes ...
[1-143] [info] done compiling
[1-150/150] sjsonnet.native[3.3.6].test.test
[1-150] [info] Starting process '/Users/stephen.amar/sjsonnet/out/sjsonnet/native/3.3.6/test/nativeLink.dest/out' on port '52359'.
---------------------- Running Tests sjsonnet.OsPathTest ----------------------
X sjsonnet.OsPathTest.os.FilePath 3ms
  java.lang.AssertionError: assertion failed
    scala.runtime.Scala3RunTime$.assertFailed(Unknown)
    sjsonnet.OsPathTest$.tests$$anonfun$1$$anonfun$1(Unknown)
[1-150] Test result: 1 completed, 1 failures.
[1-150] Tests: 1, Passed: 0, Failed: 1
[1/1, 1 failed] ============================== show sjsonnet.native[3.3.6].test sjsonnet.OsPathTest ============================== 8s
1 tasks failed
show 1 tasks failed
sjsonnet.native[3.3.6].test.test 1 tests failed:
  sjsonnet.OsPathTest sjsonnet.OsPathTest.os.FilePath

Scala JVM:

14s ~/sjsonnet % ./mill show "sjsonnet.jvm[3.3.6].test" "sjsonnet.OsPathTest"                                                                                   (master +!?)
[1/1] show
[1-108/115] sjsonnet.jvm[3.3.6].test.compile
[1-108] [info] compiling 1 Scala source to /Users/stephen.amar/sjsonnet/out/sjsonnet/jvm/3.3.6/test/compile.dest/classes ...
[1-108] [info] done compiling
[1-115/115] sjsonnet.jvm[3.3.6].test.test
[1-115] ---------------------- Running Tests sjsonnet.OsPathTest ----------------------
[1-115] + sjsonnet.OsPathTest.os.FilePath 11ms
[1-115] Tests: 1, Passed: 1, Failed: 0
[
  "Tests: 1, Passed: 1, Failed: 0",
  [
    {
      "fullyQualifiedName": "sjsonnet.OsPathTest",
      "selector": "sjsonnet.OsPathTest.os.FilePath",
      "duration": 11,
      "status": "Success"
    }
  ]
]
[1/1] ============================== show sjsonnet.jvm[3.3.6].test sjsonnet.OsPathTest ============================== 1s

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions