Skip to content

Shapeless with SBT Assembly inside Docker

Miles Sabin edited this page May 6, 2015 · 6 revisions

If your application:

  • has a dependency on shapeless
  • directly or transitively via e.g. Slick or Spray/Akka-Http
  • it is built with SBT Assembly (or similar)
  • and is assembled inside Docker

then this is a work around a file name length limit issue you will encounter.

The problem

Most file systems have a file name length limit of 255.

Scala also hard codes its class name length to 255

However some file systems, for example encrypted disk or virtual machines have a much shorter limit. And inside Docker the limit is 242 characters.

This is not a problem for normal use of Scala dependencies which are binaries. However this is a problem if you assemble your application JAR inside Docker using SBT Assembly. SBT Assembly explodes all dependency jars, so the classes become local files and rolls them into one application super jar.

And as shapeless can include files with a file name up to the limit of 255 characters these files will conflict and fail the assembly build when done inside Docker.

Changing this by default for everyone to e.g. 242 in shapeless is not currently advisable. As that will still break for encrypted disks, is inconsistent with the other libraries, and more importantly can loose debugging information.

Work around

Internal Maven/Ivy repository

Bundle JAR inside application