r/Clojure • u/toms-w • Jul 22 '25
Clojure on Windows without admin rights, can't run .exe file
My (Windows) work environment is quite locked down but I can use Java and Powershell. A few years ago I was happily using Clojure with Leiningen but these days it seems everything is deps based.
I can't run .exe files and I can't install anything. Is there still a way to use the new (to me) Clojure CLI on Windows? I assume that it is all Java / Clojure under the hood?
9
Upvotes
8
u/Borkdude Jul 22 '25
The Windows version of the clojure CLI is an
.exenow (https://github.com/casselc/clj-msi) and is based on deps.clj (https://github.com/borkdude/deps.clj). But there is still a workaround to run the clojure CLI using Java only. For this you can download the deps.clj uberjar: https://github.com/borkdude/deps.clj/releases/download/v1.12.1.1550/deps.clj-1.12.1.1550-standalone.jar and then run it withjava -jar deps.clj-1.12.1.1550-standalone.jar. I won't be as fast as when you run it with the binary, but it will work. You can then perhaps make a local .bat script or so on your system calledclj.batandclojure.batwhich invoke the uberjar for you.2
u/joinr Jul 23 '25 edited Jul 23 '25
Cognitect appears to have disowned it and is pushing folks to use the installer or WSL in the official guide, but the powershell variant might work for your environment.
You might need to set –ExecutionPolicy Bypass or RemoteSigned.
There is some jankiness on windows going the powershell route, primarily with string args. Quoting strings gets messed up, so examples that uses a lot of command line switch for deps can be screwy (you have to escape quote stuff). However, just dumping stuff into deps.edn and invoking clj works fine and covers a majority of the typical use cases.
You can also use lein since it has had powershell support for a long time too.
Some caveats on the Windows / powershell route:
If you don't have long pathnames enabled (or your admin doesn't), you can have either deps or lein blow up. Lein has lein-classpath-jar that caches the classpath and sidesteps this problem. The clojure CLI has a support ticket posted for caching the classpath jar as well (has had it in triage for a long time IIRC), but it's not posted. So you might break the bank if you add enough deps/transitive deps.
I had trouble resolving stuff (dependencies) due to goofy proxy rules. I was able to use an ssh tunnel with a socks 5 proxy and expose that to lein through some setup code in profiles.clj. No such luck with the cli, or at least I gave up trying to figure it out (simple java networking stuff, so it's probably possible, but the CLI didn't make it easy for me).
I think the CLI expects a system git command as well for pulling git deps. I used jgit with a powershell script on an environment similar to yours. I think you could adapt this setup so the CLI would pick it up (maybe). Haven't tried it myself though.