-
-
Notifications
You must be signed in to change notification settings - Fork 8
Getting started
This is another step by step guide about how to bring Clojure to Windows. This one is going to be slightly different as I want to take a detour around WSL (more specifically WSL2) and use the Windows platform natively without any kind of virtualization needed.
There at least two issues with WSL2 and why I think Clojure is a good fit to sit directly on the Windows platform.
- WSL2 is only available since Windows 10, version 1903 and 1909. If you don’t have access to it, it’s a dead end.
- WSL2 uses Hyper-V under the hood, and there can be only one hypervisor running on your Windows machine. This is relevant for you if you have to run other virtualization software like Oracle VirtualBox. Hyper-V holds exclusive control over your environment and it’s highly likely you won’t be able to proceed.
For further details, there is a FAQ section on the WSL2 site.
There is another non-technical reason, and it’s that you like your Windows environment. You know it well or you would like to use Clojure along with other familiar tools. This is fair and I hope I can help here with this guide.
In this tutorial, I’m going to use the Scoop installer. It’s a command-line installer for Windows which contains a huge collection of useful software and makes it easily accessible through the command-line. With just a few commands you can have popular software installed and actually Clojure is not an exception.
We’ll be using "Windows PowerShell", so make sure you always have one open where you can issue commands as you go through the tutorial.
Installing Scoop is our initial step. Visit https://scoop.sh with your web browser, where you can check the video tutorial to understand more. But there are truly just these steps that are needed in order to continue.
Execute these commands one by one:
iwr -useb get.scoop.sh | iex
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Force
Now scoop command-line tool is available and I highly recommend installing your first packages like git, 7zip and curl:
scoop install git 7zip curl
Scoop software repositories are called buckets and you have to add the following buckets to enable access to Clojure and other goodies. In PowerShell Command Prompt issue these commands:
scoop bucket add extras
scoop bucket add java
scoop bucket add scoop-clojure https://github.com/littleli/scoop-clojure
By adding the “extras” bucket, you get access to system libraries required in order to run some of the community tools.
By adding the “java” bucket, you get access to a bunch of packaged JDKs, including OpenJDK or GraalVM.
By adding the “scoop-clojure” bucket, you unlock access to Clojure. In addition, there are also community-driven tools in this bucket that can help you develop software using Clojure. This step is of course mandatory.
If you don’t have appropriate JDK installed on your machine, Scoop can serve one for you. Clojure requires at least JDK 8. I personally recommend installing JDK long term support release.
scoop install temurin-lts-jdk
Now you’re equipped with JDK and you reached the tipping point of this tutorial, Clojure itself.
To install Clojure, simply run:
scoop install clj-deps
Once installed you can check if you’re able to run it
clj -?
If there is no error in the terminal, just the output from the command, there is a reason to celebrate!
But it’s not over yet. There is still more ahead in order to be efficient with Clojure.
Leiningen is a popular building and dependency management tool. Most projects out there use it so let’s grab it too.
scoop install leiningen
Check the output of this command
lein version
It should give you back a version of the leiningen tool and Java version.
VSCode is popular these days and it’s available with scoop too. Just this command and you’re good.
scoop install vscode
Calva needs to be installed from the editor. Check a really great "Please, jack-in!" post from the author of the extension.
You can improve your user experience beyond with some goodies.
To get the most out of your REPL in Clojure I highly recommend installing Windows Terminal. It's a relatively new project from Microsoft which significantly improves user's command-line experience.
scoop install windows-terminal
This is entirely up to a taste of the user but it could be a great addition to command-line experience. Various GNU utilities ported to Windows.
scoop install coreutils
This utility improves a bit your Powershell prompt, for example, it shows you a git branch name you’re in, etc.
scoop install pshazz
This article is basically a step by step guide, but there is a very simple idea behind the "scoop-clojure" project. It’s the idea that user experience matters, and developers are users too. I hope it helps people of different backgrounds and experiences not just start easier and faster with Clojure but also take advantage of the ever-growing software repository that Scoop offers.