How to quit scala 2.11.0 REPL?
ScalaScala 2.11Scala Problem Overview
In the last version of scala (2.10.3) REPL, I can type exit
to quit from REPL. However, in Scala 2.11.0 this doesn't work.
$ scala
Welcome to Scala version 2.11.0 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_51).
Type in expressions to have them evaluated.
Type :help for more information.
scala> exit
<console>:8: error: not found: value exit
exit
^
scala>
Scala Solutions
Solution 1 - Scala
I ran into the same issue on upgrade, just use colon q.
:q
Additionally, exit
was deprecated in 2.10.x with sys.exit
suggested instead, so this works as well:
sys.exit
As a side note, I think they did this so you can distinguish between exiting the scala console in sbt and exiting sbt itself, though I could be wrong.
Solution 2 - Scala
You options to leave the REPL as stated in the answers before are:
:quit
:q
Ctrl + d // Unix
Ctrl + z // Windows
sys.exit
Solution 3 - Scala
Use the end of file characters. Ctrl-D
on linux, Ctrl-Z
on Windows.
Using the :help
command on my 2.10.3 REPL gets me this hint:
:quit exit the interpreter
I don't know whether :quit
is still there in 2.11.0 or not though.
Solution 4 - Scala
When I use exit
in 2.10.4, I got a warning:
> warning: there were 1 deprecation warning(s); re-run with -deprecation for details
You can use:
:q
:quit
sys.exit
all of them work in 2.11.x.
Solution 5 - Scala
You can use sys.exit OR :q to exit the shell
Solution 6 - Scala
For sbt 1.4.1 commands use below command
exit:Terminates the remote client or the build when called from the console.
shutdown:Terminates the build.
Example
vudikeri@C02CP3LAMD6M scala % sbt version
[info] welcome to sbt 1.4.1 (N/A Java 14.0.1)
sbt:scala> shutdown
[info] shutting down sbt server
vudikeri@C02CP3LAMD6M scala %
sbt:scala> exit
[info] shutting down sbt server