Skip to content

Commit 7c3bb61

Browse files
committed
readme: tab completion error on module-info$
1 parent 83d906d commit 7c3bb61

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

README.md

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ markdown-toc --maxdepth 3 README.md|tail -n +4
5959
* [Is this an extension of the stock REPL or a fork?](#is-this-an-extension-of-the-stock-repl-or-a-fork)
6060
* [Why do we ship a shaded copy of other libraries and not use dependencies?](#why-do-we-ship-a-shaded-copy-of-other-libraries-and-not-use-dependencies)
6161
* [Where's the cache located on disk?](#wheres-the-cache-located-on-disk)
62+
* [Why am I getting an AssertionError re `class module-info$` on first tab completion?](#why-am-i-getting-an-assertionerror-re-class-module-info-on-first-tab-completion)
6263
- [Contribution guidelines](#contribution-guidelines)
6364
* [How can I build/stage a local version?](#how-can-i-buildstage-a-local-version)
6465
* [How can I get a new binary (bootstrapped) release?](#how-can-i-get-a-new-binary-bootstrapped-release)
@@ -67,7 +68,6 @@ markdown-toc --maxdepth 3 README.md|tail -n +4
6768
- [Fineprint](#fineprint)
6869

6970

70-
7171
## Benefits over / comparison with
7272

7373
### Regular Scala REPL
@@ -573,6 +573,39 @@ srp includes some small libraries (e.g. most of the com-haoyili universe) that h
573573
The cache? The caches you mean! :)
574574
There's `~/.cache/scala-repl-pp` for the repl itself. Since we use coursier (via a subprocess) there's also `~/.cache/coursier`.
575575

576+
### Why am I getting an AssertionError re `class module-info$` on first tab completion?
577+
```
578+
exception caught when loading module class module-info$: java.lang.AssertionError: assertion failed: attempt to parse java.lang.Object from classfile
579+
```
580+
There's a [Scala 3 compiler bug](https://github.com/scala/scala3/issues/20421) that triggers and prints this exception if one of your dependencies ships a `module-info.class`. Until that's fixed you can use this hacky workaround in your sbt build:
581+
```
582+
lazy val removeModuleInfoFromJars = taskKey[Unit]("remove module-info.class from dependency jars - a hacky workaround for a scala3 compiler bug https://github.com/scala/scala3/issues/20421")
583+
removeModuleInfoFromJars := {
584+
import java.nio.file.{Files, FileSystems}
585+
val logger = streams.value.log
586+
val libDir = (Universal/stagingDirectory).value / "lib"
587+
588+
// remove all `/module-info.class` from all jars
589+
Files.walk(libDir.toPath)
590+
.filter(_.toString.endsWith(".jar"))
591+
.forEach { jar =>
592+
val zipFs = FileSystems.newFileSystem(jar)
593+
zipFs.getRootDirectories.forEach { zipRootDir =>
594+
Files.list(zipRootDir).filter(_.toString == "/module-info.class").forEach { moduleInfoClass =>
595+
logger.info(s"workaround for scala completion bug: deleting $moduleInfoClass from $jar")
596+
Files.delete(moduleInfoClass)
597+
}
598+
}
599+
zipFs.close()
600+
}
601+
}
602+
```
603+
604+
If you use [sbt-native-packager](https://sbt-native-packager.readthedocs.io/en/latest/) to package your application, you can automatically invoke the task, e.g. like so:
605+
```
606+
removeModuleInfoFromJars := removeModuleInfoFromJars.triggeredBy(Universal/stage).value
607+
```
608+
576609

577610
## Contribution guidelines
578611

0 commit comments

Comments
 (0)