Jack
Jack

Reputation: 16728

Make Scala 3 default in CLI

I've just installed Scala 3 on a brand Ubuntu machine. I used Coursier to install Scala 3 using the official instructions.

I can compile a file using scala3-compiler, but how do I run it? Using the scala command will still default to the 2.13 version of Scala.

Upvotes: 3

Views: 472

Answers (2)

shvahabi
shvahabi

Reputation: 1308

Using Coursier, it's as simple as running

:~$ cs update scala

on the Ubuntu shell. This single line will update Scala default REPL to the latest version:

:~$ scala

Welcome to Scala 3.5.1 (22.0.2, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.
                                                                                                                                                                                              
scala>  

Upvotes: 0

Mykola Driuchatyi
Mykola Driuchatyi

Reputation: 1

Editing ~/.profile file in a section 'coursier install directory' helps. Initially, the line looks as follows:

export PATH="$PATH:$HOME/.local/share/coursier/bin"

It should be changed to:

export PATH="$HOME/.local/share/coursier/bin:$PATH"

Coursiers bin directory should be defined earlier, since bash picks up the first occurrence of the command among directories defined in PATH environment variable.

Upvotes: 0

Related Questions