RutaCubano

A cuban around the globe

[Clojure] Installing Leiningen in GNU/Linux or Windows systems

 

In the previous article about Clojure we were learning what Clojure is and its basic operations. On this occasion we are going to show the Leiningen installation process, which can be considered the the easiest way to use Clojure as is mentioned on their official site. Alternative popular build toolchains are Boot and deps and clj. This time we will be showing the procedure for its installation on GNU/Linux and Windows systems. At the end of this post you will be able to install and use lein to interact with Clojure more comfortably.

What is Leiningen?

Leiningen is a build automation and dependency management tool for the simple configuration of software projects written in the Clojure programming language. It was created by Phil Hagelberg who started the project with the aim of simplifying the complexities of Apache Maven, while offering a way of describing the most common build requirements of Clojure projects in idiomatic Clojure. Leiningen’s motto is Automate Clojure projects without setting your hair on fire

Attention!!! Leiningen and Clojure require Java. OpenJDK version 8 is recommended at this time.

Access here for more information: https://www.java.com/

Install leiningen on Debian base systems

Installing leiningen package Debian and derivatives is simple:

sudo apt-get update

sudo apt-get install leiningen

Install leiningen a script for GNU/Linux systems

  1. Download the lein script here
  2. Place it on your $PATH where your shell can find it (eg. ~/bin)
  3. Set it to be executable (chmod a+x ~/bin/lein)
  4. Run lein and it will download the self-install package

Install leiningen on Windows

  1. Download the lein.bat here and save it in C:\JavaLib\
  2. Open up File Explorer
  3. Right Click on This PC and select Properties
  4. On the left hand side of the new window select Advanced System Settings
  5. On the bottom of this screen select Environment Variables…
  6. Find the PATH variable
  7. Append ;C:\JavaLib; to the existing PATH variable
  8. Open up a command prompt and type in lein self-install. This will install lein.

3rd-party releases packages not supported by the Leiningen team

Also you can find some packages for others systems here

 

Let’s test the REPL

Now open your terminal or command prompt and type:

lein repl

Later type this 3 inputs and check the result in each case:

  1. “hello world”
  2. (+ 2 3)
  3. (- 10 (* 10 9))

Check if you get the same results 😉

lein repl
nREPL server started on port 46521 on host 127.0.0.1 - nrepl://127.0.0.1:46521
REPL-y 0.4.3, nREPL 
Clojure 1.10.0
OpenJDK 64-Bit Server VM 11.0.9.1+1-post-Debian-1deb10u2
    Docs: (doc function-name-here)
          (find-doc "part-of-name-here")
  Source: (source function-name-here)
 Javadoc: (javadoc java-object-or-class-here)
    Exit: Control+D or (exit) or (quit)
 Results: Stored in vars *1, *2, *3, an exception in *e

user=> "hello world"
"hello world"
user=> (+ 2 3)
5
user=> (- 10 (* 10 9))
-80
user=> exit 
Bye for now!

Closing our interpreter

To close our REPL interpreter it will only be necessary to enter

exit

or

quit

It is also possible to exit with the key combination control + d.

To end

I hope you found this first tutorial helpful. I plan to continue publishing tutorials about Clojure. If you have a question, recommendation or feedback please leave me a comment.

One thought on “[Clojure] Installing Leiningen in GNU/Linux or Windows systems

Leave a Reply

Your email address will not be published. Required fields are marked *.

*
*
You may use these <abbr title="HyperText Markup Language">HTML</abbr> tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>