Skip to content

Instantly share code, notes, and snippets.

@VernonGrant
Last active November 29, 2022 05:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save VernonGrant/566346234c1ccc76a5ab1d7398f789cd to your computer and use it in GitHub Desktop.
Save VernonGrant/566346234c1ccc76a5ab1d7398f789cd to your computer and use it in GitHub Desktop.
Clojure via Cider and Emacs on Windows

Clojure/Cider on Windows

I spent the past 2 days trying to get this working and have tried almost everything I can think of, but I just can't get Cider functioning on Windows. I guess I'll need to use VSCode for now and this is truly painful :-(. Here's some of the guides I followed that didn't work. BTW I'm new to Clojure so I might have been doing something stupid.

Attempt One

Went to the official website's install Clojure section. Followed the Windows guide clj on Windows.

Installed Leiningen creating a bat file and adding it to the system path as instructed (Including Emacs's exec-path).

After installation:

java --version && clojure --version && clj --version && lein --version

# Output:
# openjdk 17.0.5 2022-10-18
# OpenJDK Runtime Environment Temurin-17.0.5+8 (build 17.0.5+8)
# OpenJDK 64-Bit Server VM Temurin-17.0.5+8 (build 17.0.5+8, mixed mode, sharing)
# Clojure CLI version 1.11.1.1165
# Clojure CLI version 1.11.1.1165
# 'Copied' is not recognized as an internal or external command,
# operable program or batch file.
# 'Copied' is not recognized as an internal or external command,
# operable program or batch file.
# 'Copied' is not recognized as an internal or external command,
# operable program or batch file.
# 'Copied' is not recognized as an internal or external command,
# operable program or batch file.
# Leiningen 2.9.10 on Java 17.0.5 OpenJDK 64-Bit Server VM
# 'Copied' is not recognized as an internal or external command,
# operable program or batch file.

# Bulding and running project from PowerShell works:
clj -T:build uber && java -jar .\target\project-0.0.1-standalone.jar

I can build and run my project without issues from the PowerShell terminal. But Cider within Emacs fails to start an nRepl and gives the following messages.

Emacs cider messages for deps.edn based project.

[nREPL] Starting server via "c:/Windows/System32/WindowsPowerShell/v1.0/powershell.exe" -encodedCommand YwBsAG8AagB1AHIAZQAgAC0AUwBkAGUAcABzACAAJwB7ADoAZABlAHAAcwAgAHsAbgByAGUAcABsAC8AbgByAGUAcABsACAAewA6AG0AdgBuAC8AdgBlAHIAcwBpAG8AbgAgACIAIgAxAC4AMAAuADAAIgAiAH0AIABjAGkAZABlAHIALwBjAGkAZABlAHIALQBuAHIAZQBwAGwAIAB7ADoAbQB2AG4ALwB2AGUAcgBzAGkAbwBuACAAIgAiADAALgAyADgALgA3ACIAIgB9AH0AIAA6AGEAbABpAGEAcwBlAHMAIAB7ADoAYwBpAGQAZQByAC8AbgByAGUAcABsACAAewA6AG0AYQBpAG4ALQBvAHAAdABzACAAWwAiACIALQBtACIAIgAgACIAIgBuAHIAZQBwAGwALgBjAG0AZABsAGkAbgBlACIAIgAgACIAIgAtAC0AbQBpAGQAZABsAGUAdwBhAHIAZQAiACIAIAAiACIAWwBjAGkAZABlAHIALgBuAHIAZQBwAGwALwBjAGkAZABlAHIALQBtAGkAZABkAGwAZQB3AGEAcgBlAF0AIgAiAF0AfQB9AH0AJwAgAC0ATQA6AGMAaQBkAGUAcgAvAG4AcgBlAHAAbAA=
nrepl-server-sentinel: Could not start nREPL server: #< CLIXML
<Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04"><Obj S="progress" RefId="0"><TN RefId="0"><T>System.Management.Automation.PSCustomObject</T><T>System.Object</T></TN><MS><I64 N="SourceId">1</I64><PR N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj><Obj S="progress" RefId="1"><TNRef RefId="0" /><MS><I64 N="SourceId">1</I64><PR N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj><S S="Error">clojure : The term 'clojure' is not recognized as the name of a cmdlet, function, script file, or operable program. _x000D__x000A_</S><S S="Error">Check the spelling of the name, or if a path was included, verify that the path is correct and try again._x000D__x000A_</S><S S="Error">At line:1 char:1_x000D__x000A_</S><S S="Error">+ clojure -Sdeps '{:deps {nrepl/nrepl {:mvn/version ""1.0.0""} cider/ci ..._x000D__x000A_</S><S S="Error">+ ~~~~~~~_x000D__x000A_</S><S S="Error">    + CategoryInfo          : ObjectNotFound: (clojure:String) [], CommandNotFoundException_x000D__x000A_</S><S S="Error">    + FullyQualifiedErrorId : CommandNotFoundException_x000D__x000A_</S><S S="Error"> _x000D__x000A_</S></Objs>

Emacs cider messeges for leiningen based project.

[nREPL] Starting server via "c:/Users/verno/.scripts/bin/lein.bat" update-in :dependencies conj ^"[nrepl/nrepl \^"\^"1.0.0\^"\^"]^" -- update-in :plugins conj ^"[cider/cider-nrepl \^"\^"0.28.7\^"\^"]^" -- repl :headless :host localhost
error in process sentinel: nrepl-server-sentinel: Could not start nREPL server: 'Copied' is not recognized as an internal or external command,
operable program or batch file.
java.lang.NumberFormatException: Invalid number: 1.0.0
 at clojure.lang.LispReader.readNumber (LispReader.java:352)
    clojure.lang.LispReader.read (LispReader.java:278)
    clojure.lang.LispReader.readDelimitedList (LispReader.java:1398)
    clojure.lang.LispReader$VectorReader.invoke (LispReader.java:1347)
    clojure.lang.LispReader.read (LispReader.java:285)
    clojure.lang.LispReader.read (LispReader.java:216)
    clojure.lang.LispReader.read (LispReader.java:205)
    clojure.lang.RT.readString (RT.java:1876)
    clojure.lang.RT.readString (RT.java:1871)
    clojure.core$read_string.invokeStatic (core.clj:3816)
    clojure.core$read_string.invoke (core.clj:3806)
    clojure.core$mapv$fn__8535.invoke (core.clj:6979)
    clojure.core.protocols$fn__8249.invokeStatic (protocols.clj:168)
    clojure.core.protocols/fn (protocols.clj:124)
    clojure.core.protocols$fn__8204$G__8199__8213.invoke (protocols.clj:19)
    clojure.core.protocols$seq_reduce.invokeStatic (protocols.clj:31)
    clojure.core.protocols$fn__8236.invokeStatic (protocols.clj:75)
    clojure.core.protocols/fn (protocols.clj:75)
    clojure.core.protocols$fn__8178$G__8173__8191.invoke (protocols.clj:13)
    clojure.core$reduce.invokeStatic (core.clj:6886)
    clojure.core$mapv.invokeStatic (core.clj:6970)
    clojure.core$mapv.invoke (core.clj:6970)
    leiningen.update_in$parse_args.invokeStatic (update_in.clj:13)
    leiningen.update_in$parse_args.invoke (update_in.clj:9)
    leiningen.update_in$update_in.invokeStatic (update_in.clj:36)
    leiningen.update_in$update_in.doInvoke (update_in.clj:24)
    clojure.lang.RestFn.applyTo (RestFn.java:146)
    clojure.lang.Var.applyTo (Var.java:705)
    clojure.core$apply.invokeStatic (core.clj:669)
    clojure.core$apply.invoke (core.clj:662)
    leiningen.core.main$partial_task$fn__7376.doInvoke (main.clj:284)
    clojure.lang.RestFn.applyTo (RestFn.java:139)
    clojure.lang.AFunction$1.doInvoke (AFunction.java:31)
    clojure.lang.RestFn.applyTo (RestFn.java:137)
    clojure.core$apply.invokeStatic (core.clj:669)
    clojure.core$apply.invoke (core.clj:662)
    leiningen.core.main$apply_task.invokeStatic (main.clj:334)
    leiningen.core.main$apply_task.invoke (main.clj:320)
    leiningen.core.main$resolve_and_apply.invokeStatic (main.clj:343)
    leiningen.core.main$resolve_and_apply.invoke (main.clj:336)
    leiningen.core.main$_main$fn__7465.invoke (main.clj:453)
    leiningen.core.main$_main.invokeStatic (main.clj:442)
    leiningen.core.main$_main.doInvoke (main.clj:439)
    clojure.lang.RestFn.applyTo (RestFn.java:137)
    clojure.lang.Var.applyTo (Var.java:705)
    clojure.core$apply.invokeStatic (core.clj:667)
    clojure.main$main_opt.invokeStatic (main.clj:514)
    clojure.main$main_opt.invoke (main.clj:510)
    clojure.main$main.invokeStatic (main.clj:664)
    clojure.main$main.doInvoke (main.clj:616)
    clojure.lang.RestFn.applyTo (RestFn.java:137)
    clojure.lang.Var.applyTo (Var.java:705)
    clojure.main.main (main.java:40)

Attempt Two

I found and followed this guide, also recommended somewhere on the official website.

I did the following

# install TCK certified Java runtime and compiler if you need to (optional)
scoop install temurin-lts-jdk

# add scoop clojure
scoop bucket add scoop-clojure https://github.com/littleli/scoop-clojure

# install official clojure tools
scoop install clojure

# update to the newest version
scoop update clojure

# install leiningen
scoop install leiningen

After installation:

java --version && clojure --version && clj --version && lein --version

# Output
# openjdk 17.0.5 2022-10-18
# OpenJDK Runtime Environment Temurin-17.0.5+8 (build 17.0.5+8)
# OpenJDK 64-Bit Server VM Temurin-17.0.5+8 (build 17.0.5+8, mixed mode, sharing)
# Clojure CLI version 1.11.1.1200
# Clojure CLI version 1.11.1.1200
# Leiningen 2.9.10 on Java 17.0.5 OpenJDK 64-Bit Server VM

# Bulding and running project from PowerShell works:
clj -T:build uber && java -jar .\target\project-0.0.1-standalone.jar

My deps.edn project repl now works in Cider. But Leiningen based projects are still broken.

Emacs cider messeges for leiningen based project.

[nREPL] Starting server via "c:/Users/verno/scoop/shims/lein.cmd" update-in :dependencies conj ^"[nrepl/nrepl \^"\^"1.0.0\^"\^"]^" -- update-in :plugins conj ^"[cider/cider-nrepl \^"\^"0.28.7\^"\^"]^" -- repl :headless :host localhost
error in process sentinel: nrepl-server-sentinel: Could not start nREPL server: java.lang.NumberFormatException: Invalid number: 1.0.0
 at clojure.lang.LispReader.readNumber (LispReader.java:352)
    clojure.lang.LispReader.read (LispReader.java:278)
    clojure.lang.LispReader.readDelimitedList (LispReader.java:1398)
    clojure.lang.LispReader$VectorReader.invoke (LispReader.java:1347)
    clojure.lang.LispReader.read (LispReader.java:285)
    clojure.lang.LispReader.read (LispReader.java:216)
    clojure.lang.LispReader.read (LispReader.java:205)
    clojure.lang.RT.readString (RT.java:1876)
    clojure.lang.RT.readString (RT.java:1871)
    clojure.core$read_string.invokeStatic (core.clj:3816)
    clojure.core$read_string.invoke (core.clj:3806)
    clojure.core$mapv$fn__8535.invoke (core.clj:6979)
    clojure.core.protocols$fn__8249.invokeStatic (protocols.clj:168)
    clojure.core.protocols/fn (protocols.clj:124)
    clojure.core.protocols$fn__8204$G__8199__8213.invoke (protocols.clj:19)
    clojure.core.protocols$seq_reduce.invokeStatic (protocols.clj:31)
    clojure.core.protocols$fn__8236.invokeStatic (protocols.clj:75)
    clojure.core.protocols/fn (protocols.clj:75)
    clojure.core.protocols$fn__8178$G__8173__8191.invoke (protocols.clj:13)
    clojure.core$reduce.invokeStatic (core.clj:6886)
    clojure.core$mapv.invokeStatic (core.clj:6970)
    clojure.core$mapv.invoke (core.clj:6970)
    leiningen.update_in$parse_args.invokeStatic (update_in.clj:13)
    leiningen.update_in$parse_args.invoke (update_in.clj:9)
    leiningen.update_in$update_in.invokeStatic (update_in.clj:36)
    leiningen.update_in$update_in.doInvoke (update_in.clj:24)
    clojure.lang.RestFn.applyTo (RestFn.java:146)
    clojure.lang.Var.applyTo (Var.java:705)
    clojure.core$apply.invokeStatic (core.clj:669)
    clojure.core$apply.invoke (core.clj:662)
    leiningen.core.main$partial_task$fn__7376.doInvoke (main.clj:284)
    clojure.lang.RestFn.applyTo (RestFn.java:139)
    clojure.lang.AFunction$1.doInvoke (AFunction.java:31)
    clojure.lang.RestFn.applyTo (RestFn.java:137)
    clojure.core$apply.invokeStatic (core.clj:669)
    clojure.core$apply.invoke (core.clj:662)
    leiningen.core.main$apply_task.invokeStatic (main.clj:334)
    leiningen.core.main$apply_task.invoke (main.clj:320)
    leiningen.core.main$resolve_and_apply.invokeStatic (main.clj:343)
    leiningen.core.main$resolve_and_apply.invoke (main.clj:336)
    leiningen.core.main$_main$fn__7465.invoke (main.clj:453)
    leiningen.core.main$_main.invokeStatic (main.clj:442)
    leiningen.core.main$_main.doInvoke (main.clj:439)
    clojure.lang.RestFn.applyTo (RestFn.java:137)
    clojure.lang.Var.applyTo (Var.java:705)
    clojure.core$apply.invokeStatic (core.clj:667)
    clojure.main$main_opt.invokeStatic (main.clj:514)
    clojure.main$main_opt.invoke (main.clj:510)
    clojure.main$main.invokeStatic (main.clj:664)
    clojure.main$main.doInvoke (main.clj:616)
    clojure.lang.RestFn.applyTo (RestFn.java:137)
    clojure.lang.Var.applyTo (Var.java:705)
    clojure.main.main (main.java:40)

Attempt Three

I followed your guide, CLJ-MSI. Could not complete the build process.

git clone git@github.com:casselc/clj-msi.git

cd .\clj-msi\

.\build-clojure-msi.ps1

# Output
# Downloading deps.exe version 1.11.1.1200
# Downloading runtime version 1.11.1.1200
# Downloading WiX binaries
# Creating new MSI at C:\Users\verno\Downloads\clj-msi\clojure-11.1.1200.msi
# candle.exe : error CNDL0103 : The system cannot find the file '.\installers\combined-permachine.wxs' with type 'Source'.
# light.exe : error LGHT0103 : The system cannot find the file 'work\clojure.wixobj' with type 'Source'.
# Done

Additional things I tried

  • Installing leiningen using the win installer, couldn't complete the installation, selecting the JDK path causes an errors.
  • Tried installing different version's of Java but it made no difference.
  • Tried modifying the Cider's command options but it didn't help.
  • Tried using a basic Emacs config with just Cider and Colojure, but the same issue persists.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment