Easier Scala installation

(The Scala Center team is dedicated to providing regular and transparent community updates about project plans & progress we develop or support. In this forum we created a new topic category to allow quicker orientation going forward: “Scala Center Updates”. Even though all feedback is welcome, we keep the right to make executive decisions about projects we lead. Overview of all our activities can always be found at https://scala.epfl.ch/records.html)

You can setup your machine for Scala development by getting the coursier CLI, and running

$ cs setup

On Windows, you can simply download cs.exe and double-click on it.

No JVM is required for that to work. This takes care of:

  • installing a JVM if none is found on your machine,
  • creating launchers for the most common Scala CLI tools, most notably:
    • ammonite,
    • scalac,
    • scalafmt,
    • cs,
    • sbt.

This relies on capabilities of the coursier CLI, most notably

Context

There’s no clear way to setup one’s machine for Scala development. Installing an Oracle JVM has become more and more blurry over the years, and each Scala CLI tool has its own installation process. Instructions to install JVMs and those Scala tools also vary depending on your operating system.

To address that, the Scala Center decided to invest in the install command of coursier and to pack it with JVM installation capabilities. The ability to:

  • install applications,
  • install JVMs,
  • do that from a native application, generated with GraalVM native-image,

give us the possibility to have a standalone CLI tool to setup one’s machine for Scala development, that doesn’t need a prior JVM to be installed.

Going forward

Your feedback about this new setup is very welcome. Our hope is to make this setup the default way of installing Scala on one’s machine.

26 Likes

This sounds like it would be awesome for the educational space. Getting students setup up and ready to work in Scala is always a challenge early in the semester and it can both slow down and turn off many students.

9 Likes

I’ve been using this new distribution on 3 different Windows machines for a couple months, now, and I can say that it is immensely better than anything we’ve ever had before. It’s such a breeze to install sbt and the Scala CLI so easily.

I’m particularly fan of the --jvm x option which allows to easily launch one of the projects using a different JVM, for example

$ cs launch --jvm 11 sbt

On Linux it’s relatively easy to work with separate JVMs, but on Windows this was annoyingly tricky before cs.

9 Likes

This is super cool! Getting students setup is always a pain (especially on Windows), here’s the instructions we’re using currently for EPFL courses: https://gitlab.epfl.ch/lamp/cs206-2020/-/blob/master/homeworks/instructions/tools-setup.md, if I understand this correctly, it looks like we’ll be able to replace step 2, 3 and 4 by just:

- Install coursier
- cs setup --jvm 8

that would be a great improvement!

Incidentally, do you think it would make sense to publish coursier on the new window package manager repository (https://github.com/microsoft/winget-pkgs) ? That way eventually a full setup could be reduced to two commands on windows without needing to download anything manually:

winget install coursier ssh git vscode
cs setup --jvm 8
5 Likes

Easy installation is very important indeed. But if we want to get users hooked on Scala before they are even required to do anything else, we can actively support free web-based platforms that use Ecplise Che or Eclipse Theia with the Metals plugin. Unfortunately the current support is clunky at best.

3 Likes

Actually on Windows you can just double-click on the installer executable (or confirm execution when you download it from your browser). That’s how Windows users install stuff. They don’t know to use a complicated incantation on the command line. Edit: It is not idiomatic to use a complicated incantation on the command line, and Windows users can find that suspicious.

To be clear: I include myself among “Windows users”/“they”. This post was not intended to mean that Windows users are less knowledgeable/can’t use a command line, but to point out was is considered idiomatic/well accepted to install software on that platform. I apologize to those who may have taken this the wrong way.

1 Like

Sure, but I’m optimizing for “smallest numbers of instructions I have to give to students”. Given that Windows is in the process of getting a standard cli package manager, it seems that we could get that done to two (actually three because they need to generate an SSH key too), the alternative is telling them to click and install a bunch of programs from a bunch of different sources which takes much longer and is easier to do wrong.

4 Likes

I don’t think regular users that installing stuff with installer are into development and especially into Scala, which require quite understating of cli tooling in first place.

In my opinion using coursier for management jvm and sbt is not really practical and redundant as there is already multiple native to platform solutions for managing packages like scoop/winget/choco/apt-get/brew/sdkman/asdf and many other well know projects. Also managing jvm by coursier wouldn’t friendly if you’re using other alternative manager, so I would avoid this part especially.

As professional developer I would rely on general purpose solutions instead of niche one unless it provides killer features. Also for practical purpose package manager require not only ability to install, but also manage updates, have updates database up-to date and manage global/local alternatives.

In summary I’m up-to native package management solution like

winget install java-11 vscode sbt ammonite

in one command, or at most two

winget install java-11 vscode coursier
cs setup sbt ammonite
1 Like

That’s ridiculous.

It’s a bit of a hyperbole, yes. But as a daily Windows user and a Linux user, I can tell you that I have two very different mindsets when it comes to installing software. On Linux, I expect to be able to install them via my distribution’s package manager, or perhaps with a shell incantation. On Windows, I expect an executable that I can execute right from my browser. I am very suspicious of software that I need to install via a command line on Windows.

Perhaps it’s just me.

2 Likes

I know of plenty of Windows users who are much more well-versed in CLI usage than many Mac users I know.

Still, I wouldn’t say Mac users they don’t know how to use a complicated incantation on the command line, because that obviously doesn’t go for all of them, and it doesn’t serve any useful purpose other than alienating part of our userbase.

We could publish coursier to winget. It’s already on brew, for macOS. We would need to somehow clarify the ~story around those package managers.

Right now, downloading cs like

$ curl -Lo cs …
$ chmod +x cs
$ ./cs setup

actually installs cs itself too. And cs update can later update it. So that the cs file that was downloaded by curl can be removed right after having run ./cs setup.

If cs is installed in the PATH by brew or winget, we should ensure that we don’t install cs during cs setup. We don’t do that yet. And maybe we can print a message during cs update if we detect that a new coursier version is available.

2 Likes

I agree we should ensure double-clicking on the installer executable just works. But if winget were to gain momentum, like brew has on macOS, we could support it too.

It’s not just you. +20 years Windows user/developer. It’s habitualized SOP.

It is getting slightly better because of PowerShell, but is still nowhere near Linux SOP.

Having spent ~15 years as a professional Windows dev, I’m with @sjrd here: while command-line installation isn’t unheard of, it’s weird. Frankly, it feels amateurish in the Windows environment: any serious tool has an installer. (Yes, I know that sounds weird from a *nix or Mac viewpoint – it’s a different world, and a different mindset.)

And while, yes, any programmer worth their salt is able to use a CLI, the installer version is friendlier to absolute beginners – which we have a lot of in the ScalaBridge world, and I think they are particularly likely to have Windows laptops.

So I think the Windows installer is likely a big win: it should smooth the path for a substantial number of people who aren’t Macbook-centric (the way that most of the Scala world seems to be, judging from looking around at conferences)…

5 Likes

Perfectly true.

On Linux, I expect a DEB or RPM file I can install via apt or dnf/yum respectively, and I am highly suspicious of software that doesn’t do that. I’m highly annoyed at IntelliJ IDEA for expecting me to download a ZIP file and unpack it myself. There are UI apps for package management on Linux, too, but usually I don’t bother.

On Windows, I expect an executable installer and would be highly suspicious of anything else.

3 Likes

https://www.jetbrains.com/idea/download/#section=linux says:

IntelliJ IDEA is also available as a snap package. If you’re on Ubuntu 16.04 or later, you can install IntelliJ IDEA from the command line.
sudo snap install intellij-idea-community --classic
or
sudo snap install intellij-idea-ultimate --classic
or
sudo snap install intellij-idea-educational --classic

Haven’t used that option, though.

I’m grateful for the ZIP option, as the laptop I’m using at work blocks (almost?) all installers.

3 Likes

Thanks, I will consider that option when I install IntelliJ next time (which doesn’t happen often, usually only when I get a new machine).

Use Jetbrain Toolbox instead to install. It’s waaay better than any other method, especially when updating and using EAP versions.

3 Likes

I have different experience with Windows

I have all my personal hardware are running Windows, while my work station is Mac, and all my/company servers are running Linux, so I immediately started experimenting with package managers once they appeared on the scene, first it was choco, then scoop and now winget. And I would say it’s nothing strange, all windows packages are actually the same installers, but with orchestration scripts on top, as bonus they have uniform installation process and more granular dependency and permission control, so they suppose to be even safer than regular installers. In addition they have killer feature as alternatives control (as they usually installing in user space instead of system wide) which I was really missing.

By this off-topic I was trying to say, that trend on package managers on windows will be increasing and I think in couple of years it will be completely normal and old habits will change. Otherwise why cli tools are not shipped with DMG on mac? Additionally if you’re professional programmer you probably have several terminals with various environment - PS/CMD/WLS1/2.

I hope my argumentation in favor to package manager shipped option is understandable

1 Like