Skip to content
Sign upLog in
← Back to Community

Clojure koans on REPL.IT

Profile icon
devjamoranca

The standard clojure repl provided by repl.it has leininingen but it does not support files, directories or editors. Even with the shell, I was unable to use the standard clojure repl for anything other than small programs. But there is an alternative.

For instance to run clojure koans (https://github.com/functional-koans/clojure-koans) and lein on repl.it, there are two ways:

Option 1.

Clone clojure koans to your github account

In repl.it select Import a github repository. At time of creation, in the run button configuration, select bash (no run option) and install leiningen as below in the bash window. (IF you select a clojure project at time of creation, then the REPL will hang).

;;FIRST LEIN INSTALL mkdir bin cd bin wget https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein chmod +x lein ./lein cd ..

Lein will be installed in the bin directory and this will be kept in your repl for future use, so no need to reinstall afterwards.

Edit the koans and solve the exercises by replacing the underscores in the files in directory src/koans.

Run lein koans:

bin/lein koan run

The koans will be executed silently until one of the tests fails. Stop the execution by CTRL-C.

To run the lein repl

bin/lein repl

(The bin directory could be added to the path by doing:

cd bin echo "PATH=\$PATH:$PWD" >> $HOME/.bashrc source $HOME/.bashrc cd ..

and then there is no need to add bin path in front of lein, but this change is not persistent and will need to be redone next time you go into your repl).

Option 2

Create a blank bash or polygott, and then add files using git in the bash and then use snippet above to install leiningen.

Bash or polygott REPLs have already installed clojure cli tools (clj and clojure).

Invoke clj -h for further info.
https://clojure.org/guides/deps_and_cli
https://clojure.org/reference/repl_and_main

Voters
Profile icon
phil-mac
Profile icon
bradtaniguchi
Profile icon
LuckyOreos
Comments
hotnewtop
Profile icon
phil-mac

This is awesome. Thank you

@devjamoranca
! This might be a recent addition to Replit, but you can now add bin/lein koan run as the "run" command in the .replit file, then you only have to click the run button to start it up.