How to quit scala 2.11.0 REPL?
Asked Answered
P

6

157

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>
Parapodium answered 22/4, 2014 at 23:42 Comment(0)
P
270

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.

Poetaster answered 22/4, 2014 at 23:51 Comment(0)
M
44

You options to leave the REPL as stated in the answers before are:

:quit
:q

Ctrl + d // Unix
Ctrl + z // Windows

sys.exit
Mensal answered 23/4, 2014 at 8:37 Comment(4)
Have no windows machine at my disposal right now. @GovindSinghNagarkoti . What works for you ?Mensal
@AndreasNeumann all others works for me except ctrl+d , i am using windows 7Passage
I'm using Windows 10 and have Cygwin installed: ctrl+d works but ctrl+z does not. Not sure if that's related to Cygwin or not.Boastful
ctrl-c also exits the repl, which is annoying because in literally every other repl it cancels the current lineGreaves
F
14

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.

Flotsam answered 22/4, 2014 at 23:50 Comment(3)
If you use sbt, ctl-D will get you out of either command prompt. That's what I started doing at some point. The :q vs exit thing just drove me nuts. Can you tell?Imperium
You can also use java.lang.System.exit(0);Formulate
@ElliottFrisch sure, i feel like typing that every timeKiddy
B
4

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.

Bojorquez answered 7/3, 2015 at 16:3 Comment(0)
C
3

You can use sys.exit OR :q to exit the shell

Covet answered 22/8, 2017 at 14:20 Comment(1)
This has already been pointed out, years ago, in the previous answers to this question.Prosecute
C
0

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
Choline answered 22/10, 2020 at 10:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.