Installing Clojure with Lein

Most of the Clojure tutorials and Clojure examples on this site require at the minimum Clojure to be installed. Usually, you want Leiningen installed too.

Easy peasy.

Seriously, do it once and ignore it for the rest of your learning experience. Here are the steps for getting Lein and Clojure up and running.

Step 1: Make sure you have a Java JDK on your computer. I recommend Adopt Open JDK. They have Java JDK installers for all major operating systems, including Linux.

Step 2: Download the lein script (AKA Leiningen.) Don’t try to pronounce it. Just download it. There is lein.bat download for windows users and lein shell script download for everyone else.

Step 2.1: For extra credit, put lein  in your command path. This will very based off your preferences and OS. On *nix this might be in ~/bin/ . On windows, you might might just add the full path to your lein  script to the environment variable $PATH .

Step 3: Make lein  executable. You need to change permissions so that you can use the command lein  from the command line. (Little Clojure humor there.) On Linux and MacOS use the command chmod a+x <full path>/lien  On Windows, the lein.bat  is probably already executable. If the lein.bat  file is not running when you  type lein , check to see if there is a hidden .txt  extension appended on to lein.bat .

Step 4: Run the lein  command to let lein  self-install Clojure and the newest version of Leiningen.

A quick note for Linux users and MacOS users, you may need to use sudo  at some point in the installation process, but running lein  when you are done should not require the use of sudo .

Once lein  is installed, type lein repl  to get a Clojure REPL up and running for quick use of Clojure.

Leave a Reply

Your email address will not be published.