Skip to content

Conversation

@lihaoyi
Copy link

@lihaoyi lihaoyi commented Oct 22, 2025

The previous code was off by one:

  • If given a relative path vf://tmp/foo/bar/baz, it would crash with unsupported URI
  • If given an absolute path vf://tmp//foo/bar/baz, it would incorrectly produce a relative path foo/bar/baz using the absolute path's segments, which would typically duplicate the -sourceroot value and result in an invalid path

Looking at the code, it seems like it is simply splitting by 1 too many slashes: if we want everything after the vf://tmp/, we need to .split('/', 4) rather than .split('/', 5). This seems fixes both misbehaviors listed above:

  • If given a relative path vf://tmp/foo/bar/baz, it extracts the relative foo/bar/baz, which is then appended as a sub-path by options.sourceroot.resolve
  • If given an absolute path vf://tmp//foo/bar/baz, it extracts the absolute /foo/bar/baz, which then remains unchanged and is returned by options.sourceroot.resolve

Test plan

Tested manually, a local sbt publishLocal with these changes fixes downstream issues in tools that consume the semanticdb e.g. scalameta/metals#7913

@lihaoyi
Copy link
Author

lihaoyi commented Oct 22, 2025

CC @antonsviridov-src since you seem to be the most active maintainer

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.

1 participant