ANN: Windows installer for Leiningen

493 views
Skip to first unread message

David Powell

unread,
Mar 30, 2013, 1:39:12 PM3/30/13
to clo...@googlegroups.com
Hi,

I've put together an installer for Leiningen on Windows:

Hopefully it should make it a bit easier for Windows people to get Leiningen and a Clojure repl up and running.

It requires a JDK to be installed first, but other than that there aren't any dependencies.
It should work on Windows XP and above, 32-bit or 64-bit.  With or without powershell available.

The installer should take the hassle out of setting up paths and environment variables, and changing them when new JDKs are installed.

The current version is beta1.  If you've got any feedback then give me an email.

-- 
Dave

Brent Millare

unread,
Mar 30, 2013, 8:06:16 PM3/30/13
to clo...@googlegroups.com
Nice work!

Roberto Mannai

unread,
Mar 31, 2013, 8:55:09 AM3/31/13
to clo...@googlegroups.com
Hello,

Should one have Powershell pre-installed? The wizard does not complete
successfully the "self-install" step, although it seems as it is not
aware of it.

When running "lein self-install" manually, I get a
DotNetMethodException (*). Now I'd guess this is an issue of lein.bat,
not of your installer, anyway it would be nice if your package could
embed all the hidden dependencies, as it already does for "curl.exe".

Kind regards,
Roberto

(*)
C:\Users\Roberto Mannai\.lein\bin>lein self-install
Downloading Leiningen now...
Eccezione durante la chiamata di "DownloadFile" con "2" argomento/i:
"Eccezione durante una richiesta WebClient."
In riga:1 car:63
+ & {param($a,$f) (new-object System.Net.WebClient).DownloadFile <<<< ($a, $f)}
https://leiningen.s3.amazonaws.com/downloads/leiningen-2.1.2-standalone.jar C:
\Users\Roberto Mannai\.lein\self-installs\leiningen-2.1.2-standalone.jar.pendin
g
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
> --
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clo...@googlegroups.com
> Note that posts from new members are moderated - please be patient with your
> first post.
> To unsubscribe from this group, send email to
> clojure+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+u...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

David Powell

unread,
Mar 31, 2013, 9:23:31 AM3/31/13
to clo...@googlegroups.com

Interesting.  Yes this is a problem with lein.bat rather than the installer.

Leiningen recently added support for powershell because it was assumed that powershell would always be installed, but in fact that isn't the case.  The installer bundles curl as a fallback for when powershell isn't installed.

The error suggests that you have powershell installed, but that it isn't working for some reason.

Could you tell me what version of windows you are using?  Do you have any unusual network setup - eg, are you behind a proxy?

Did the installer successfully download lein.bat to ~/.lein/bin/lein.bat?

Can you see if this command completes without errors:



If powershell is going to be a problem, then it might be easier for leiningen to lower powershell below curl in the priority list.

-- 
Dave

David Powell

unread,
Mar 31, 2013, 9:45:50 AM3/31/13
to clo...@googlegroups.com
Also, can you check what version of powershell you have?

  powershell -Command echo $host.version

-- 
Dave

Roberto Mannai

unread,
Mar 31, 2013, 9:48:34 AM3/31/13
to clo...@googlegroups.com
C:\Users\Roberto Mannai\.lein\bin>powershell -Command echo $host.version
Major Minor Build Revision
----- ----- ----- --------
2 0 -1 -1


I'm doing some test, the problem seems to be this line:

powershell -Command "& {param($a,$f) (new-object
System.Net.WebClient).DownloadFile($a, $f)}" %~2 %~1

Where %~1 points to a path with a space inside:
C:\Users\Roberto
Mannai\.lein\self-installs\leiningen-2.1.2-standalone.jar.pending

[I can't believe both that in 2013 MS Windows does not handle such
cases, and that Windows Administrators still create User profiles with
spaces inside]

It should be enough to do a smarter string concation; I'll try later.

Thanks again,
Roberto

David Powell

unread,
Mar 31, 2013, 10:08:46 AM3/31/13
to clo...@googlegroups.com
powershell -Command "& {param($a,$f) (new-object System.Net.WebClient).DownloadFile($a, $f)}" %~2 %~1

Ah, yeah.  %~1 and %~2 strip the quotes off the parameters, which isn't a good idea.
Something like this should work:
 
powershell -Command "& {param($a,$f) (new-object System.Net.WebClient).DownloadFile($a, $f)}" "%~2" "%~1"
 
[I can't believe both that in 2013 MS Windows does not handle such

cases, and that Windows Administrators still create User profiles with
spaces inside]

To be fair, whilst batch file syntax is horrible, it is more a lein.bat problem in this case.  If we pass two parameters without quotes, and one has spaces in, it isn't surprising that it gets interpreted wrongly.

I'll submit a patch to fix the handling of profiles with spaces in them in lein.bat


-- 
Dave

Kemar

unread,
Mar 31, 2013, 10:35:31 AM3/31/13
to clo...@googlegroups.com
Using lein.bat with powershell I found two issues:

First, there is the aforementioned

  {param($a,$f) (new-object System.Net.WebClient).DownloadFile <<<< ($a, $f)}
DotNetMethodException.

This could be solved by starting the Command Prompt as an Administrator
(shift + right-click on the cmd.exe, then "Run as administrator").

Then it's able to download the leiningen jar-file.

But there is a second problem. It (apparently) tries two save the jar file in
C:\Users\<Username>\.lein\self-installs\leiningen-x.y.z-standalone.jar

But it looks like it doesn't deal correctly with spaces in the path. If your Username
were to be "John Doe", only the part in front of the space is used as the install path.

So the leiningen jar-file would actually be a file named "John" in the directory C:\Users,
instead of C:\Users\John Doe\.lein\self-installs\leiningen-x.y.z-standalone.jar.

I hope this helps :-)

David Powell

unread,
Mar 31, 2013, 11:23:00 AM3/31/13
to clo...@googlegroups.com

Hi,

But there is a second problem. It (apparently) tries two save the jar file in
C:\Users\<Username>\.lein\self-installs\leiningen-x.y.z-standalone.jar

But it looks like it doesn't deal correctly with spaces in the path. If your Username
were to be "John Doe", only the part in front of the space is used as the install path.

So the leiningen jar-file would actually be a file named "John" in the directory C:\Users,
instead of C:\Users\John Doe\.lein\self-installs\leiningen-x.y.z-standalone.jar.

I think all of these problems, and Robertos issue are caused by the same lein.bat.  The permissions problem is probably because the spaces in the profile are causing lein to attempt to write outside of the user profile.

I think that this patch fixes the issue:

It seems that quotes around powershell parameters on the command-line need to be triple-double-quoted :)

-- 
Dave

Roberto Mannai

unread,
Mar 31, 2013, 11:42:15 AM3/31/13
to clo...@googlegroups.com
On Sun, Mar 31, 2013 at 5:23 PM, David Powell <djpo...@djpowell.net> wrote:

> I think that this patch fixes the issue:
> https://github.com/djpowell/leiningen/commit/bd9e2e25508cfc01889057349b133941ff4fc379
>
> It seems that quotes around powershell parameters on the command-line need
> to be triple-double-quoted :)

That's correct, now it works! :)

IMHO the patch should be just the line 83 of your file, the other
quoted variables are URLs (which cannot have spaces). Note that
:DownloadFile, when calls powershell, inverts the order of its
arguments.

Thanks again,
Roberto

David Powell

unread,
Mar 31, 2013, 11:56:21 AM3/31/13
to clo...@googlegroups.com
 
That's correct, now it works! :)

Great.  The patch has been accepted by leiningen, so it should be in the next release.
 
IMHO the patch should be just the line 83 of your file, the other
quoted variables are URLs (which cannot have spaces). Note that
:DownloadFile, when calls powershell, inverts the order of its
arguments.

The extra quotes seem to be an artifact of passing the arguments on the command-line.  The actual arguments to the DownloadFile method in .NET aren't expected to contain quotes.

From inside powershell itself, this works:

  (new-object System.Net.WebClient).DownloadFile("https://raw.github.com/technomancy/leiningen/stable/bin/lein.bat", "with space\file name.txt")

So the extra quotes probably won't harm on either parameter.

-- 
Dave



Reply all
Reply to author
Forward
0 new messages