Skip to content

Fix Scala Native test binary resolution when cached metadata is present#3

Merged
sake92 merged 6 commits intomainfrom
copilot/fix-deder-permission-error
Apr 12, 2026
Merged

Fix Scala Native test binary resolution when cached metadata is present#3
sake92 merged 6 commits intomainfrom
copilot/fix-deder-permission-error

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 12, 2026

Scala Native test runs could pick .deder/out/<module>/nativeLink/metadata.json as the process to execute instead of the linked binary. In downstream builds, that surfaced as Permission denied when cached nativeLink outputs were reused.

  • Root cause

    • ScalaNativeTasks selected the first matching file in the nativeLink output directory.
    • Cached tasks store metadata.json in the same directory, so file ordering could cause the JSON file to be treated as the executable.
  • Resolution

    • Tighten native binary discovery in ScalaNativeTasks.findNativeBinary.
    • Exclude cache metadata and other non-binary artifacts from consideration.
    • Require an actual executable output instead of falling back to an arbitrary remaining file.
  • Regression coverage

    • Add a focused unit test for the nativeLink output layout where both metadata.json and the native binary are present.
    • Assert that binary resolution selects the executable and ignores the cache file.
  • Behavioral change

    • Failure mode is now explicit if no executable binary is present in nativeLink, rather than attempting to run a non-executable file.
private val ignoredFileSuffixes = Seq(".ll", ".c", ".o", ".s", ".json")

private[scalanative] def findNativeBinary(nativeLinkDir: os.Path): os.Path = {
  val files = os.list(nativeLinkDir).filter(os.isFile).sortBy(_.last)
  val candidates = files.filterNot(path => ignoredFileSuffixes.exists(path.last.endsWith))
  val executableCandidates = candidates.filter(isExecutableBinaryCandidate)

  executableCandidates.headOption.getOrElse(
    throw DederException(
      s"No executable native binary found in $nativeLinkDir. Files: ${files.map(_.last).mkString(", ")}"
    )
  )
}

Copilot AI and others added 6 commits April 12, 2026 09:07
Agent-Logs-Url: https://github.com/sake92/deder/sessions/ef6faedd-107f-481e-ac56-6db1e7282bc8

Co-authored-by: sake92 <12010694+sake92@users.noreply.github.com>
Agent-Logs-Url: https://github.com/sake92/deder/sessions/ef6faedd-107f-481e-ac56-6db1e7282bc8

Co-authored-by: sake92 <12010694+sake92@users.noreply.github.com>
Agent-Logs-Url: https://github.com/sake92/deder/sessions/ef6faedd-107f-481e-ac56-6db1e7282bc8

Co-authored-by: sake92 <12010694+sake92@users.noreply.github.com>
Agent-Logs-Url: https://github.com/sake92/deder/sessions/ef6faedd-107f-481e-ac56-6db1e7282bc8

Co-authored-by: sake92 <12010694+sake92@users.noreply.github.com>
Agent-Logs-Url: https://github.com/sake92/deder/sessions/ef6faedd-107f-481e-ac56-6db1e7282bc8

Co-authored-by: sake92 <12010694+sake92@users.noreply.github.com>
Agent-Logs-Url: https://github.com/sake92/deder/sessions/ef6faedd-107f-481e-ac56-6db1e7282bc8

Co-authored-by: sake92 <12010694+sake92@users.noreply.github.com>
@sake92 sake92 marked this pull request as ready for review April 12, 2026 14:45
@sake92 sake92 merged commit 514deab into main Apr 12, 2026
1 of 2 checks passed
@sake92 sake92 deleted the copilot/fix-deder-permission-error branch April 12, 2026 15:28
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

Successfully merging this pull request may close these issues.

2 participants