Secrets of Gorilla REPL

Sourced from Lee Spector (, revised October 19, 2016

This document was written for university students at the Hampshire College taking a course where they likely use Clojure for the first time. Gorilla REPL provides a complete Clojure programming environment. You might find it useful if you’re just getting started with Clojure, as it provides an easy workflow for development. The key features for using Gorilla as a complete environment are:

To make a project: If you have leiningen installed and you want to create a project called foo, for which you can use Gorilla REPL as your development environment, then cd into the directory where you want it to live and type:

lein new gorilla-app foo

This will create a project that uses both the app template (which will set things up so that lein run will run the -main function in src/foo/core.clj) and also the recommended version of the Gorilla REPL plugin.

After creating the project you can do:

cd foo
lein gorilla

and open the URL that this prints in your browser to begin working on your project. It will give you a fresh, unsaved worksheet initially, but you can use the “Load a worksheet” command (choose from the menu or type ctrl+g ctrl+l) to open and edit the core.clj file or any other Clojure file in your project.

To add a new file (and namespace) to your project: If your project is called foo then your code should all live in the src/foo folder within your foo folder. So if you want to have a file of code called bar.clj then it should be saved as src/foo/bar.clj. The namespace defined by this file should be, and that is what should appear in the ns expression at the top of the file. This correspondence of names is what will allow Clojure to find the file when you use or require the namespace in other code.

You can create this file in a variety of ways, including these:

Once you have done this you can write code in the new file, and use that code elsewhere. For example, if you create namespace, as described above, and define a function in that file, and save it, then in your core.clj file you can say (use ' and then the function that you defined will be available.

To enable Gorilla REPL for an existing leiningen project: Add this line to the defproject call in your project.clj:

  :plugins [[lein-gorilla "0.4.0"]]

When saving a worksheet: Always give it a name ending in .clj, .cljs, .cljc, or .hl. Otherwise Gorilla REPL won’t see it when you later try to load it.

To save the worksheet without the Gorilla REPL worksheet markup, select “Save the worksheet without markup.” from the Gorilla REPL menu or type ctrl+g ctrl+w. Note that this will overwrite the file, so if you want to preserve a version with the markup then you should make a copy of the file before you do this.

To auto-reindent a selection: Shift-Tab

To kill a long-running process: No good way. Kill the server at the command line and start over.