How to set SCALACTIC_FILL_FILE_PATHNAMES=yes (or other environment variable) for scalac from sbt?

I would like to use full paths in ScalaTest reporter. The value LineInFile.filePathname tells me I should:

Please set the environment variable SCALACTIC_FILL_FILE_PATHNAMES to yes at compile time to enable this feature.

Can I do this from sbt, or do I have to launch SBT with a different environment? Scalac seems to be running in the same JVM as sbt, and there is a question Scala: Unable to set environment variable telling me I cannot modify my own environment.

I have tried following, none of them seems to set the variable for the compiler:

    scalacOptions ++= Seq(
      "-deprecation", "-unchecked",
      "-DSCALACTIC_FILL_FILE_PATHNAMES=yes"
    ),
    Compile / envVars := Map("SCALACTIC_FILL_FILE_PATHNAMES" -> "yes"),
    Test / envVars := Map("SCALACTIC_FILL_FILE_PATHNAMES" -> "yes"),

As far as I know, sbt doesn't run scalac in a separate process (which would allow it to set environment variables), so you'd have to run sbt in an environment with that set.

Note that -D sets Java properties. While it's fairly common for software to allow environment variables and properties to be treated similarly (e.g. Lightbend Config), that's not standard.

The mechanism for setting the environment will depend on how you are launching sbt. If using a Bourne-style shell like bash:

export SCALACTIC_FILL_FILE_PATHNAMES=yes
sbt

or

SCALACTIC_FILL_FILE_PATHNAMES=yes sbt

IDEs and CI/CD tooling may launch sbt directly, in which case check the documentation for those tools.