Answer: Use the
consoleQuick commands inside the SBT shell:
consoleto start a REPL session from inside SBT. This (a) compiles your Scala project and then (b) starts a REPL session.
consoleQuickif you don’t want to compile your project before starting a REPL session inside of SBT.
console command process looks like this:
> sbt [info] Loading project definition from /Users/al/Projects/Cats101/project [info] Set current project to Cats101 (in build file:/Users/al/Projects/Cats101/) > console [info] Starting scala interpreter... [info] Welcome to Scala 2.12.2 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_131). Type in expressions for evaluation. Or try :help. scala> _
If you wanted to see how to start a Scala REPL session from inside SBT, I hope this helps.
libraryDependencies += "org.scalacheck" %% "scalacheck" % "1.13.4" % "test"
it’s only available in the SBT “test” scope. This means that when you start a Scala REPL session inside of SBT with its
console command, the ScalaCheck library won’t be available in that scope.
To use ScalaCheck with the SBT console (REPL), don’t use its
console command — use
test:console instead. A complete example looks like this:
$ sbt > test:console scala> import org.scalacheck.Gen.choose
Note that after you type
test:console your project may be compiled, so that step may take a few moments.
In summary, use SBT’s
console command to start a “normal” Scala REPL inside SBT, and use
test:console to start a REPL that you can run tests inside of. (Note that this same advice also applies to using ScalaTest or specs2.)
It took me a few minutes to figure out that when you want help on Play Framework console commands (i.e., the Play command line tool), you may get more useful help by typing
help play instead of just
help. Using the first command shows information on commands like
console, etc., which is what I'm more interested in.
To take a quick look at this, here's what you get when you type
I had the common Scala SBT commands in the notes for my project named SARAH, and thought I'd list them here to make them easier to find:
A great thing about Scala is that not only is it scalable, it was also created to help you work on small tasks, including being useful in shell scripts. This includes small shell script tasks like prompting a user interactively from a shell script, and reading their input.
You can prompt users with print commands like
Mac OS X debug FAQ: Help, I'm having a problem with [fill in the blank] on my Mac OS X system, how do I troubleshoot it?
I just ran into a problem when trying to create a Safari web clip dashboard widget, where the web clip isn't properly updating itself, and I stopped for a moment to think about how to troubleshoot/debug this Mac OS X problem. That's when I thought, "Okay, a Mac is a Unix system, check the log files." So I cracked open a Mac Terminal window, and checked the system log file: