Installing leinigen on windows

Figured I’d spend part of the afternoon and play with clojure but was immediately thwarted trying to install leiningen on windows via powershell. I tried the msi installer but it didn’t seem to do anything, so I went to my ~/.lein/bin folder and ran

.lein\bin> .\lein.bat self-install
Downloading Leiningen now...
SYSTEM_WGETRC = c:/progra~1/wget/etc/wgetrc
syswgetrc = C:\Program Files (x86)\Gow/etc/wgetrc
--2015-03-14 15:08:48--
Connecting to||:443... connected.
ERROR: cannot verify's certificate, issued by `/C=US/O=DigiCert Inc/ SHA2 Extended Validation Server CA':
  Unable to locally verify the issuer's authority.
To connect to insecurely, use `--no-check-certificate'.
Unable to establish SSL connection.

Failed to download

Hmm, thats weird. For some reason the cert isn’t validating with wget (that I have installed via Gow).

A quick google showed that this is a common problem using the gow wget, and I wasn’t about to use the unsecured certificate check. I opened up the leinigen installer bat file and saw that it does a check trying to see what kind of download function your shell has. It checks if you have wget, curl, or if you are in powershell (in which case it creates a .net webclient and downloads the target file).

Since I have gow in my path wget comes up first, so I just switched around the order and things now work happy!

The relevant section in the lein.bat file is

rem parameters: TargetFileName Address
if NOT "x%HTTP_CLIENT%" == "x" (
    %HTTP_CLIENT% %1 %2 
    goto EOF
call powershell -? >nul 2>&1
    powershell -Command "& {param($a,$f) (new-object System.Net.WebClient).DownloadFile($a, $f)}" ""%2"" ""%1""
    goto EOF
call curl --help >nul 2>&1
    rem We set CURL_PROXY to a space character below to pose as a no-op argument
    set CURL_PROXY= 
    if NOT "x%HTTPS_PROXY%" == "x" set CURL_PROXY="-x %HTTPS_PROXY%"
    call curl %CURL_PROXY% -f -L -o  %1 %2
    goto EOF
call Wget --help >nul 2>&1
    call wget -O %1 %2
    goto EOF

Once the self install completes now lein is available.

On a side note, I think you probably could have just downloaded the release file and plopped it into the ~/.lein/self-installs folder and it would work too

2 thoughts on “Installing leinigen on windows

  1. Lein has been installed, since more than a year ago, no problem. But I just received the same problem as yours, when trying to upgrade, thus:

    lein upgrade

    The solution you mentioned seems to start to work. But the problem is, that the upgrade process replaces the lein.bat. So the re-ordering of the calls to wget/curl/powershell are backed out.

    So at this point, I’m not even sure how to upgrade lein. Might just have to leave it, as is.

Leave a Reply

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