# Question about building scala and sbt proper

**URL:** <https://contributors.scala-lang.org/t/question-about-building-scala-and-sbt-proper/2811>\
**Category:** Scala Platform\
**Created:** [February 6, 2019, 2:32am UTC](https://contributors.scala-lang.org/t/question-about-building-scala-and-sbt-proper/2811 "2019-02-06T02:32:47Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![tfinneid](https://contributors.scala-lang.org/letter_avatar_proxy/v4/letter/t/b782af/32.png) [@tfinneid](https://contributors.scala-lang.org/u/tfinneid)\
**Post date:** [February 6, 2019, 2:32am UTC](https://contributors.scala-lang.org/t/question-about-building-scala-and-sbt-proper/2811/1 "2019-02-06T02:32:48Z")

</div>

Hi

I am trying to build scala and sbt from scratch and I have a couple of questions.

For scala:  
On git for scala it says that 2.11 is built using java 6 and 2.12 is built using jdk-8, but on the download pages at [scala-lang.org](http://scala-lang.org) it states both version require java 8. Is it correct that one should use java 6 to build scala 2.11 or run scala 2.11 project code on? And likewise is it correct that 2.12 does require jdk 8 (update #?) and is not completely compatible if run on jdk 9/10/11?

Also is it correct that scala 2.12 should be built with sbt 0.13? I tried compiling it with sbt 1.x but that failed.  
Typically it stated:  
java.io.IOException: Scala signature package has wrong version  
expected: 5.0  
found: 5.2 in package.class

The last question I have is that it seems to me that scala requires sbt to build and sbt requires scala to build, so how does one bootstrap that tool chain? I understand that one can install a precompiled version of the one or the other, but the dependency is still circular so it is counter intuitive.

Regards

Thomas

---

<div class="post-metadata">

**Author:** ![Jasper-M](https://contributors.scala-lang.org/user_avatar/contributors.scala-lang.org/jasper-m/32/1192_2.png) [@Jasper-M](https://contributors.scala-lang.org/u/Jasper-M)\
**Post date:** [February 6, 2019, 1:35pm UTC](https://contributors.scala-lang.org/t/question-about-building-scala-and-sbt-proper/2811/2 "2019-02-06T13:35:11Z")

</div>

I think you misinterpreted the downloads page. For more complete information on JDK compatibility you should look at [JDK Compatibility | Scala Documentation](https://docs.scala-lang.org/overviews/jdk-compatibility/overview.html)

As for the sbt version you should use, sbt should just select the correct version based on the `project/build.properties` file. If you don’t edit that file yourself everything should be fine. It’s really not worth trying to upgrade that version yourself for this codebase… Any serious development should probably happen in the 2.13.x (and soon 2.14.x I guess) branch anyway.

> [@tfinneid](#):
>
> The last question I have is that it seems to me that scala requires sbt to build and sbt requires scala to build, so how does one bootstrap that tool chain? I understand that one can install a precompiled version of the one or the other, but the dependency is still circular so it is counter intuitive.

Building Scala requires Scala, so you don’t even need sbt in the equation to have a circular dependency.

---

<div class="post-metadata">

**Author:** ![SethTisue](https://contributors.scala-lang.org/user_avatar/contributors.scala-lang.org/sethtisue/32/3185_2.png) [@SethTisue](https://contributors.scala-lang.org/u/SethTisue)\
**Post date:** [February 6, 2019, 4:51pm UTC](https://contributors.scala-lang.org/t/question-about-building-scala-and-sbt-proper/2811/3 "2019-02-06T16:51:07Z")

</div>

(If it gives you the heebie-jeebies that you can’t build Scala without using the binaries from a previous Scala, it may help to know that the Scala CI scripts include something called the “stability test” — it verifies that compiling the compiler with the previous binary and compiling it with a freshly built binary produce identical results.)

---

<div class="post-metadata">

**Author:** ![tfinneid](https://contributors.scala-lang.org/letter_avatar_proxy/v4/letter/t/b782af/32.png) [@tfinneid](https://contributors.scala-lang.org/u/tfinneid)\
**Post date:** [February 8, 2019, 1:19pm UTC](https://contributors.scala-lang.org/t/question-about-building-scala-and-sbt-proper/2811/4 "2019-02-08T13:19:59Z")

</div>

Hi again, after having done som digging, let me rephrase my question, after a bit of context:

I am trying to upgrade Debians Scala and sbt packages from 2.11.12. The debian process is new to me and strict and complex. I respect Debians political point of view, but it makes things a bit difficult to start with. A Deian package must be built from scatch on debian servers. And I only have scala-2.11 and sbt-ivy available.

Hence the question about correct version of jdk, sbt and scala to use when building different versions moving up to 2.12.8.

I know of the compatability matrix. But there are a couple of issues with it.  
1- I tried using default scala on ubuntu/debian, which used 2.11.12 and jdk 10/11, to run a scala script and it crashed. when I downgraded to jdk 8 it ran without problems.  
2- Github page for scala, states that 2.11 was targeted at 1.6 and 2.12 at java 8.

Since a jdk has library changes, I found it safest and more stable to run using jdk8. jdk 8 will still be around in the wild for a good many years. and its still a bit more work for scala 2.13 to be complete and scala to be completely jdk-11 compatible.

So my first question is: is this a reasonable basis?

My second question is about building scala. I am using scala-sources-2.12.8.tar.gz (first try was with git clone)

- is it enough to just use “dist/mkPack” to build a complete scala release for a debian package or must I go through the bootstrapping procedure and run the stability tests and all, as well
  - also does it contain all that a release must contain, or are there other repos that needs to be compiled as well?

- since I dont have sbt available, is there a way to compile sbt without sbt, using only scala 2.11?
- is it correct that I actually only need sbt installed on the build system to compile scala, or must it contain a scala installation as well ro be able to run sbt (before sbt downloads and compiles scala 2.12.7)
- can I install sbt 1.2.8 on the build system to compile sbt and scala or should I use 0.13 (again I have read documents that state that certain versions must be used to build sbt at different version)

Regards

Thomas

---

<div class="post-metadata">

**Author:** ![SethTisue](https://contributors.scala-lang.org/user_avatar/contributors.scala-lang.org/sethtisue/32/3185_2.png) [@SethTisue](https://contributors.scala-lang.org/u/SethTisue)\
**Post date:** [February 11, 2019, 9:33pm UTC](https://contributors.scala-lang.org/t/question-about-building-scala-and-sbt-proper/2811/5 "2019-02-11T21:33:53Z")

</div>

Yes, JDK 8 is the safe and stable choice here.

I think targeting 2.12 is reasonable. Whatever you do for 2.12 should work for 2.13 as well, once 2.13 is finalized. (You, or someone, could think later about whether your efforts could be backported to 2.11.)

I don’t see any need for you to bootstrap or run the stability test. Any merged scala/scala PR has already been through that, it’s part of testing/QA rather than part of the build proper.

> does it contain all that a release must contain

no, you also need [GitHub - scala/scala-dist: sbt project that packages the Scala distribution](https://github.com/scala/scala-dist)

> since I dont have sbt available, is there a way to compile sbt without sbt, using only scala 2.11?

I don’t know, perhaps @eed3si9n could address this

> can I install sbt 1.2.8 on the build system to compile sbt and scala or should I use 0.13

I don’t see any way sbt 0.13 would enter into this. Both Scala 2.12 and sbt 1 are built using sbt 1.

Hope this helps.

Some history of past efforts to add Scala to Debian are at [Scala 2.12 needs packaging for Debian/Ubuntu in Ubuntu APT repos · Issue #9299 · scala/bug · GitHub](https://github.com/scala/bug/issues/9299) and [Enter current Scala version (2.12.1) into next Debian stable (Stretch) · Issue #10172 · scala/bug · GitHub](https://github.com/scala/bug/issues/10172) and [Build process acceptable to Ubuntu, Debian & Co · Issue #295 · scala/scala-lang · GitHub](https://github.com/scala/scala-lang/issues/295); of these, 9299 is the still-active ticket.

---

<div class="post-metadata">

**Author:** ![eed3si9n](https://contributors.scala-lang.org/user_avatar/contributors.scala-lang.org/eed3si9n/32/95_2.png) [@eed3si9n](https://contributors.scala-lang.org/u/eed3si9n)\
**Post date:** [February 12, 2019, 10:13pm UTC](https://contributors.scala-lang.org/t/question-about-building-scala-and-sbt-proper/2811/6 "2019-02-12T22:13:08Z")

</div>

> [@tfinneid](#):
>
> - since I dont have sbt available, is there a way to compile sbt without sbt, using only scala 2.11?

Not at the moment.  
It would actually be an interesting contribution if someone wants to generate a shell script that requires only `scalac` to build sbt.

---

<div class="post-metadata">

**Author:** ![ashawley](https://contributors.scala-lang.org/letter_avatar_proxy/v4/letter/a/53a042/32.png) [@ashawley](https://contributors.scala-lang.org/u/ashawley)\
**Post date:** [February 15, 2019, 1:30am UTC](https://contributors.scala-lang.org/t/question-about-building-scala-and-sbt-proper/2811/7 "2019-02-15T01:30:53Z")

</div>

Scala used to be built with ant, so it was probably still possible for these distros to build Scala from source by only depending on the Ant dependency.

Wasn’t 2.12 the first version of Scala that was built with sbt and not ant? Seems like a distro would need to go back to 2.12.0 and try to build with Ant? But even 2.12.0 probably depends on a 2.12 milestone, and not 2.11.

Seems like it would be easier to just start from a jar for sbt-launcher or sbt-extras to build Scala 2.12 from scratch.

---

<div class="post-metadata">

**Author:** ![tfinneid](https://contributors.scala-lang.org/letter_avatar_proxy/v4/letter/t/b782af/32.png) [@tfinneid](https://contributors.scala-lang.org/u/tfinneid)\
**Post date:** [February 16, 2019, 9:06am UTC](https://contributors.scala-lang.org/t/question-about-building-scala-and-sbt-proper/2811/8 "2019-02-16T09:06:18Z")

</div>

In all 2.12.0-Mx builds, both sbt and Ant buildfiles exists. The Ant buildfile was carried over from 2.11. I dont know how usable the later milestone Ant build files are, cause the 2.12.0 build does not seem to have an Ant buildfile. Anyone?

(One is not allowed to use externally downloaded tools/apps/libs/jars, to compile a package in Debian. All debian packages must be built with only what is already available in the current debian repo (main) and the source package alone. I.e it must be able to bootsrtap it self. 30 years ago a few people handwrote the first version of the tools and infrastructure, which has evolved into what is today. Those were the simpler days… 🙂

---

<div class="post-metadata">

**Author:** ![smarter](https://contributors.scala-lang.org/user_avatar/contributors.scala-lang.org/smarter/32/92_2.png) [@smarter](https://contributors.scala-lang.org/u/smarter)\
**Post date:** [February 16, 2019, 11:00am UTC](https://contributors.scala-lang.org/t/question-about-building-scala-and-sbt-proper/2811/10 "2019-02-16T11:00:20Z")

</div>

> [@tfinneid](#):
>
> One is not allowed to use externally downloaded tools/apps/libs/jars, to compile a package in Debian. All debian packages must be built with only what is already available in the current debian repo (main) and the source package alone. . I.e it must be able to bootsrtap it self.

Bootstrapping Scala is basically impossible. You will not be able to get around the fact that to compile Scala 2.12.0, [you will need Scala 2.12.0-RC2](https://github.com/scala/scala/blob/v2.12.0/versions.properties#L8-L11), to compile Scala 2.12.0-RC2 [you will need Scala 2.12.0-RC1-1e81a09](https://github.com/scala/scala/blob/v2.12.0-RC2/versions.properties#L8-L11), to compile Scala 2.12.0-RC1-1e81a09 [you will need Scala 2.12.0-RC1-ceaf419](https://github.com/scala/scala/blob/1e81a09/versions.properties#L8-L11), you can keep going back this way in theory until you get to Scala 1 from 15 years ago, which is written in [PiCo](http://zenger.org/jaco/#pico), a language which is basically Java-with-pattern-matching and whose source code was never released, so at that point you’ll need to write your own compiler.

I don’t know how Scala 2.11.8 got in Debian, but it’s impossible that it got it in through a full bootstrapping process, they must have cheated, so you’ll have to cheat again to upgrade it.

---

<div class="post-metadata">

**Author:** ![smarter](https://contributors.scala-lang.org/user_avatar/contributors.scala-lang.org/smarter/32/92_2.png) [@smarter](https://contributors.scala-lang.org/u/smarter)\
**Post date:** [February 16, 2019, 11:05am UTC](https://contributors.scala-lang.org/t/question-about-building-scala-and-sbt-proper/2811/11 "2019-02-16T11:05:37Z")

</div>

Note that this isn’t unique to Scala at all, to compile the current version of Rust, you’ll need the previous version of Rust, until you get to the first versions of Rust which were written in OCaml, but to compile OCaml, you’ll need the previous version of Ocaml … Someone did break the cycle through heroic effort by writing an alternative Rust compiler in C++: [https://github.com/thepowersgang/mrustc](https://github.com/thepowersgang/mrustc), but I’m not aware of any Scala compiler not written in Scala.

---

<div class="post-metadata">

**Author:** ![tfinneid](https://contributors.scala-lang.org/letter_avatar_proxy/v4/letter/t/b782af/32.png) [@tfinneid](https://contributors.scala-lang.org/u/tfinneid)\
**Post date:** [February 16, 2019, 12:00pm UTC](https://contributors.scala-lang.org/t/question-about-building-scala-and-sbt-proper/2811/12 "2019-02-16T12:00:17Z")

</div>

> [@smarter](#):
>
> I don’t know how Scala 2.11.8 got in Debian, but it’s impossible that it got it in through a full bootstrapping process, they must have cheated, so you’ll have to cheat again to upgrade it.

I thought the bootstrap process of scala was compiled with javac…

Well… since its already there, I can use it to build later version 🙂

---

<div class="post-metadata">

**Author:** ![tfinneid](https://contributors.scala-lang.org/letter_avatar_proxy/v4/letter/t/b782af/32.png) [@tfinneid](https://contributors.scala-lang.org/u/tfinneid)\
**Post date:** [February 16, 2019, 12:02pm UTC](https://contributors.scala-lang.org/t/question-about-building-scala-and-sbt-proper/2811/13 "2019-02-16T12:02:13Z")

</div>

> [@eed3si9n](#):
>
> It would actually be an interesting contribution if someone wants to generate a shell script that requires only `scalac` to build sbt.

I was thinking of trying that, I found some sh compile command in version 0.4.9 of sbt, so I thought I could look at that and the current build file to see if its possible. The sh command used javac…

I see now that you used the word “generate”, did you mean have some sbt code “record” the build process and the actual commands performed and create a script from it?

---

<div class="post-metadata">

**Author:** ![smarter](https://contributors.scala-lang.org/user_avatar/contributors.scala-lang.org/smarter/32/92_2.png) [@smarter](https://contributors.scala-lang.org/u/smarter)\
**Post date:** [February 16, 2019, 12:17pm UTC](https://contributors.scala-lang.org/t/question-about-building-scala-and-sbt-proper/2811/14 "2019-02-16T12:17:00Z")

</div>

> [@tfinneid](#):
>
> Well… since its already there, I can use it to build later version 🙂

You can maybe use it to build Scala 2.12.0-M1, which you can then use to build -M2, then -M3 then -M3-dc9effe, then -M4, … It’s going to take a while to get to 2.12.8.

---

<div class="post-metadata">

**Author:** ![ashawley](https://contributors.scala-lang.org/letter_avatar_proxy/v4/letter/a/53a042/32.png) [@ashawley](https://contributors.scala-lang.org/u/ashawley)\
**Post date:** [February 16, 2019, 3:37pm UTC](https://contributors.scala-lang.org/t/question-about-building-scala-and-sbt-proper/2811/15 "2019-02-16T15:37:20Z")

</div>

Yes, that seems right, but once you have 2.12.0 you can skip to 2.12.8.

Since I use sbt, I wasn’t aware before this that Scala 2.11 was available in Debian. Having Scala 2.11 available seems like a toe in here. There won’t be a reason to go back to 2004.

Getting Scala on Debian is a gateway to a lot of distributions, so this has a lot of value for furthering Scala. Granted, the bootstrap-from-source requirement is onerous. Scala language enthusiasts won’t be interested in. That’s what the project is good at, though.

It’s too bad sbt was never packaged in Debian. That’s the bigger hurdle.

Should this discussion be moved to a GitHub issue(s) or the sbt Discourse?

---

<div class="post-metadata">

**Author:** ![tfinneid](https://contributors.scala-lang.org/letter_avatar_proxy/v4/letter/t/b782af/32.png) [@tfinneid](https://contributors.scala-lang.org/u/tfinneid)\
**Post date:** [February 16, 2019, 5:14pm UTC](https://contributors.scala-lang.org/t/question-about-building-scala-and-sbt-proper/2811/16 "2019-02-16T17:14:16Z")

</div>

> [@ashawley](#):
>
> Granted, the bootstrap-from-source requirement is onerous. Scala language enthusiasts won’t be interested in. That’s what the project is good at, though.

Just an hypothetical question, would it be possible to write a simpler scala compiler / lib in e.g. java, that can be used to bootstrap the scala compiler process? that would be interesting to many people, also for learning about compilers and the as a scala language tutorial. (I would definately do that if it meant learning more about compilers and the inner workings of scala)

Another thought, would it be possible to use the disasembler on the class files, to get pure java source to be able to compile at least a basic scala compiler environment? or was that too naive? 🙂

---

<div class="post-metadata">

**Author:** ![smarter](https://contributors.scala-lang.org/user_avatar/contributors.scala-lang.org/smarter/32/92_2.png) [@smarter](https://contributors.scala-lang.org/u/smarter)\
**Post date:** [February 16, 2019, 5:36pm UTC](https://contributors.scala-lang.org/t/question-about-building-scala-and-sbt-proper/2811/17 "2019-02-16T17:36:19Z")

</div>

> [@tfinneid](#):
>
> Would it be possible to write a simpler scala compiler / lib in e.g. java, that can be used to bootstrap the scala compiler process?

Yes, but it would take a huge amount of work (if the goal is to make a compiler that is only usable for bootstrapping you could cut some corners, but this is probably still one year of work).

> [@tfinneid](#):
>
> would it be possible to use the disasembler on the class files, to get pure java source to be able to compile at least a basic scala compiler environment?

You’d probably have to do some substantial changes to the decompiled code to get it to work, so again a lot of work.

---

<div class="post-metadata">

**Author:** ![smarter](https://contributors.scala-lang.org/user_avatar/contributors.scala-lang.org/smarter/32/92_2.png) [@smarter](https://contributors.scala-lang.org/u/smarter)\
**Post date:** [February 16, 2019, 5:41pm UTC](https://contributors.scala-lang.org/t/question-about-building-scala-and-sbt-proper/2811/18 "2019-02-16T17:41:04Z")

</div>

Note that when rust is bootstrapped on a new architecture in Debian, they downloaded a binary of the reference compiler and use that to build it, so it’s clearly possible to bend the rules: [https://salsa.debian.org/rust-team/rust/blob/debian/sid/debian/README.source#L69](https://salsa.debian.org/rust-team/rust/blob/debian/sid/debian/README.source#L69)

---

<div class="post-metadata">

**Author:** ![tfinneid](https://contributors.scala-lang.org/letter_avatar_proxy/v4/letter/t/b782af/32.png) [@tfinneid](https://contributors.scala-lang.org/u/tfinneid)\
**Post date:** [February 17, 2019, 2:02pm UTC](https://contributors.scala-lang.org/t/question-about-building-scala-and-sbt-proper/2811/19 "2019-02-17T14:02:00Z")

</div>

> [@smarter](#):
>
> Note that when rust is bootstrapped on a new architecture in Debian, they downloaded a binary of the reference compiler and use that to build it, so it’s clearly possible to bend the rules:

Interresting, I suspect thats for one or two reasons. Either the maintainer team did not notice the infraction (which is what happened with the sbt package thats in Debian unstable) or the maintainer team consisted of other people which might have judged it slightly different than the java team. Another possibility is that for ports such as that, they decided to allow it, for some reason. Perhaps otherwise it would never happen or something… Pure speculation though…

---

<div class="post-metadata">

**Author:** ![tfinneid](https://contributors.scala-lang.org/letter_avatar_proxy/v4/letter/t/b782af/32.png) [@tfinneid](https://contributors.scala-lang.org/u/tfinneid)\
**Post date:** [February 17, 2019, 2:04pm UTC](https://contributors.scala-lang.org/t/question-about-building-scala-and-sbt-proper/2811/20 "2019-02-17T14:04:39Z")

</div>

> [@smarter](#):
>
> Yes, but it would take a huge amount of work…

Good to know which options are realistic and which are not 🙂

I know getting Sbt into Debian is the better choice, but I am exploring alternatives so…

One thought that came to mind was to perhaps use the ant build files from v2.12.0-M5 to build the scala source up to 2.12.8? Would that require much change of the build.xml files and support files? Or put another way, did much change in the way scala is built from M5 and up to 2.12.8?

(I have been looking into alternatives for a couple of weeks, and I keep running into the chicken and egg problem of scala and sbt all the time. So just trying to figure out if there is some solution I can work with in the mean time…)

---

<div class="post-metadata">

**Author:** ![smarter](https://contributors.scala-lang.org/user_avatar/contributors.scala-lang.org/smarter/32/92_2.png) [@smarter](https://contributors.scala-lang.org/u/smarter)\
**Post date:** [February 17, 2019, 2:50pm UTC](https://contributors.scala-lang.org/t/question-about-building-scala-and-sbt-proper/2811/21 "2019-02-17T14:50:40Z")

</div>

> [@tfinneid](#):
>
> Would that require much change of the build.xml files and support files?

No clue, I don’t think anyone remembers how the ant-based build works at this point.

[Next page](https://contributors.scala-lang.org/t/question-about-building-scala-and-sbt-proper/2811.md?page=2)
