mdoc icon indicating copy to clipboard operation
mdoc copied to clipboard

Exception thrown by mdoc terminates unforked JVM on sbt 1.6.x

Open iRevive opened this issue 3 years ago • 1 comments

sbt: 1.6.1 sbt-mdoc: 2.2.4

The issue

sbt dropped TrapExit mechanism in 1.6.0 release (https://github.com/sbt/sbt/pull/6665), hence any exception thrown by mdoc terminates unforked JVM.

The output of docs/mdoc command:

[info] running mdoc.Main
info: Compiling 23 files to /Users/maksim/projects/oss/xxx/mdoc/target/mdoc
error: README.md:2:15: compile-only cannot be used in combination with silent
```scala mdoc:silent:compile-only
              ^^^^^^^^^^^^^^^^^^^
info: Compiled in 1.69s (1 error)
[info] shutting down sbt server

The local fix

lazy val docs = project
  .in(file("mdoc"))
  .enablePlugins(MdocPlugin)
  .settings(
+   run / fork := true
  )

The proper solution

Should MdocPlugin enable forking by default? If not, I guess it's worth mentioning a workaround in the docs.

iRevive avatar Jan 23 '22 08:01 iRevive

I'd also be interested if there's a way to solve this in mdoc without requiring forking. For some reason forking doesn't interact well with --watch in https://github.com/typelevel/sbt-typelevel/issues/197.

armanbilge avatar Apr 15 '22 00:04 armanbilge