Effective Scala, part 3 - compatibility roulette

Scala sbt Tooling

I am going through the course Effective Programming in Scala on Coursera, and ran into build import errors in the very first assignment (fireworks).


While importing the fireworks project in VSCode-with-Metals, I encountered an error that started with:

[..]bad constant pool index: [..]

Looks like an error right out of a database connection pool library!

Attempt 1§

One of the suggested solutions on Discord was to ensure that the versions of java, scala, and sbt exposed in the PATH are compatible with each other.

Check the compatibility tables.

But these were already compatible in my case.

Attempt 2§

I roughly knew that *.sbt files describe the build of a project. Because the name bore relevance to build process, I also counted in a file I noticed in early debugging: build.properties.

So my first small scala project, and I am staring at the following list of *.sbt:

zsh | ~/Downloads
$ tree -a -P "*.sbt" -P "*.properties" fireworks
├── assignment.sbt
├── build.sbt
├── project
│   ├── build.properties
│   ├── buildSettings.sbt
│   └── plugins.sbt
└── src

And all of them were staring back at me, daring me to find which one of them is hiding the cause of the error.

Anyway, enough drama.

On a hunch, I decided to match the versions of sbt and scala mentioned in these .sbt files with the ones exposed in the PATH.

The mismatch turned out to be in build.properties.

zsh | ~/projects/effective-scala/week-1/fireworks
$ sbt -V
sbt version in this project: 1.9.9
sbt script version: 1.9.9

$ cat project/build.properties

I matched the versions to be 1.9.9, and re-ran the import. It worked.


  • Ensure that the versions of java, scala, and sbt exposed in the PATH are compatible with each other. Use the official compatibility tables.
  • Ensure that the versions of sbt and scala exposed in the PATH match with the versions mentioned in the build files (like built.sbt, build.properties). Best make them identical.


I hope this was the correct solution.

As people who make tools to make people's lives easier, we sure love to torture ourselves with our own tools.