clj-on-windows

For those interested in making clj on Windows https://dev.clojure.org/jira/browse/TDEPS-67. Also see https://github.com/littleli/scoop-clojure.
ajoberstar 2019-03-08T00:49:44.069400Z

As some additional context, here's the commit message from the patch.

ajoberstar 2019-03-08T00:52:41.072500Z

I think you could wrap it with a bat. That does bring back manipulating the PATH as part of the install. Which is common in installs, but I've liked the more structured approach PowerShell provides for making commands available. This could work either way though. As primarily a VS Code user, I usually have a PowerShell terminal open in the VS Code window. For other editors I don't know enough to say if that will be as straightforward to use.

seancorfield 2019-03-08T02:01:19.072900Z

https://twitter.com/seancorfield/status/1103837703194337280 -- pls RT so we can get lots of responses πŸ™‚

cfleming 2019-03-08T09:26:44.074Z

Cursive doesn’t do any of this right now, it just invokes tools.deps.alpha directly. Reading this a bit, perhaps it should keep doing that πŸ™‚

cfleming 2019-03-08T09:27:42.075100Z

But if invoking it requires prepending powershell.exe, there’s no problem doing that for Cursive, at least, but it does open the door to possibly needing to support both powershell and cmd.exe (if I understand correctly, been a while)

teodorlu 2019-03-08T15:39:47.077300Z

Hey @ajoberstar and everyone! Chiming in to say I really appreciate the effort you're putting in. Thanks!

alexmiller 2019-03-08T15:59:35.077800Z

@ajoberstar ok, I merged everything over and did a release - available at https://download.clojure.org/install/clojure-tools-1.10.0.428.zip and https://download.clojure.org/install/win-install-1.10.0.428.ps1

alexmiller 2019-03-08T15:59:52.078Z

let me know how it looks

seancorfield 2019-03-08T17:37:42.078500Z

@alexmiller I get

PS Y:\Downloads> .\win-install-1.10.0.428.ps1
Downloading Clojure tools
Invoke-WebRequest : The remote server returned an error: (403) Forbidden.
At Y:\Downloads\win-install-1.10.0.428.ps1:9 char:1
+ Invoke-WebRequest -Uri $ClojureToolsUrl -OutFile clojure-tools.zip
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebExc
   eption
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

PS Y:\Downloads>

alexmiller 2019-03-08T18:18:34.079Z

looks like didn't get version replacement in there, I can look at that

alexmiller 2019-03-08T18:21:14.079600Z

@seancorfield in that ps1 file, line 6, should that be " instead of ' to get variable interpolation?

alexmiller 2019-03-08T18:21:20.079800Z

can you try that?

timgilbert 2019-03-08T18:32:36.080600Z

I think that's correct, yeah. At least vscode hightlights the $Version bit in blue when you change to double-quotes...

alexmiller 2019-03-08T18:33:53.080800Z

cool, rebuilding now

seancorfield 2019-03-08T18:35:34.081200Z

I'll try from a new release, just to get closest to the "real" experience.

timgilbert 2019-03-08T18:37:58.082Z

I'm getting an SSL error from that one:

PS C:\Users\tim> C:\Users\tim\Downloads\win-install-1.10.0.431.ps1
Downloading Clojure tools
Invoke-WebRequest : The request was aborted: Could not create SSL/TLS secure channel.
At C:\Users\tim\Downloads\win-install-1.10.0.431.ps1:9 char:1
+ Invoke-WebRequest -Uri $ClojureToolsUrl -OutFile clojure-tools.zip
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

timgilbert 2019-03-08T18:39:05.082500Z

Firefox lets me download https://download.clojure.org/install/clojure-tools-1.10.0.431.zip with no apparent issues though

timgilbert 2019-03-08T18:40:21.082700Z

Possibly it's this: https://stackoverflow.com/a/36266735/87990

alexmiller 2019-03-08T18:42:01.083100Z

oh should be http, not https

alexmiller 2019-03-08T18:42:23.083600Z

nah, both should work

timgilbert 2019-03-08T18:42:36.083900Z

https works, just the posh client is using TLS 1 or something

alexmiller 2019-03-08T18:42:51.084400Z

yeesh

timgilbert 2019-03-08T18:42:52.084500Z

Adding this line fixed that for me:

[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]'Ssl3,Tls,Tls11,Tls12'

alexmiller 2019-03-08T18:43:07.085100Z

adding that in the script or outside?

timgilbert 2019-03-08T18:43:09.085200Z

Just above the Invoke-Request on line 10

timgilbert 2019-03-08T18:43:14.085400Z

In the script

timgilbert 2019-03-08T18:43:31.085600Z

Er, line 9

timgilbert 2019-03-08T18:45:10.086Z

Yep

alexmiller 2019-03-08T18:46:47.086500Z

so what's the install process here that we would tell people? download the script and then... ?

timgilbert 2019-03-08T18:48:00.087600Z

Uh, download that, run it, and select an install location, then use clj as normal

alexmiller 2019-03-08T18:48:18.088200Z

so the stuff at https://github.com/ajoberstar/ClojureTools is not necessary?

timgilbert 2019-03-08T18:48:33.088500Z

I'm still trying to verify that it's working correctly for me, seeing an odd error

alexmiller 2019-03-08T18:48:42.088700Z

whew, no even errors

timgilbert 2019-03-08T18:48:55.089Z

Yeah, we're 50% there πŸ˜‰

timgilbert 2019-03-08T18:50:08.089800Z

My local machine is in a weird state from working on https://github.com/ajoberstar/ClojureTools/pull/3 which is a workaround for a kind of gross Windows limitation

timgilbert 2019-03-08T18:51:03.090700Z

The stuff in https://github.com/ajoberstar/ClojureTools is the content of the zip file, isn't it? The installer just pops it in the proper directory

alexmiller 2019-03-08T18:51:49.090900Z

ah, right

alexmiller 2019-03-08T18:53:06.092Z

seems like when I ran into this issue in the deep past (long enough ago that I was using windows daily), there was some way to start java with a classpath in a file, so we would just make the file (which actually happens to be exactly the file that's already in the .cpcache maybe)

timgilbert 2019-03-08T18:53:39.092400Z

Sort of, yeah. Java 9 can read arguments out of a file

alexmiller 2019-03-08T18:53:59.093200Z

you can set the CLASSPATH env var - is that same problem?

timgilbert 2019-03-08T18:54:35.094Z

What my PR up there does as a proof of concept is to construct a jar which only has a manifest with a classpath in it, invoke java with -cp path/to/that/thing.jar, then remove the generated jar

alexmiller 2019-03-08T18:54:50.094500Z

yeah, that's awful

timgilbert 2019-03-08T18:55:01.094800Z

For my use case the classpath is also too long for an environment variable 😿

alexmiller 2019-03-08T18:55:08.095Z

what does Maven do?

timgilbert 2019-03-08T18:55:20.095200Z

Good question, I'm not sure

alexmiller 2019-03-08T18:56:36.095400Z

can you change the line limit length?

alexmiller 2019-03-08T18:57:06.096300Z

also, the meta question - how is this still a problem 15 years after the last time it hurt me?

timgilbert 2019-03-08T18:57:16.096500Z

Maybe if they put me in charge of Windows 11

alexmiller 2019-03-08T18:57:39.096800Z

man, what a punishment that would be

timgilbert 2019-03-08T18:58:52.098200Z

Seriously. Although I must say that I'm warming up to Powershell, the syntax is awful but it winds up being more powerful than bash for some stuff

alexmiller 2019-03-08T18:58:54.098300Z

common "solution" seems to involve various ways to shorten the path of your maven repo

timgilbert 2019-03-08T18:59:01.098600Z

Yeah

alexmiller 2019-03-08T18:59:17.099Z

I generally like powershell for being generally saner than bash (if also more verbose)

alexmiller 2019-03-08T19:00:31.099400Z

deeply unsatisfying

timgilbert 2019-03-08T19:01:23.100500Z

Yeah. My classpath is up to around 33K, which yes, I know that's not reasonable. Works fine in *nix though

alexmiller 2019-03-08T19:01:49.101200Z

you could symbolic link the files into a temp dir and include tmp/* :)

alexmiller 2019-03-08T19:02:00.101600Z

does windows have symbolic links?

seancorfield 2019-03-08T19:02:04.101800Z

I tried to install into C:\Program Files\WindowsPowerShell\Modules which was offered as an option but it failed due to permissions -- but the script still said it was installed correctly 😐

alexmiller 2019-03-08T19:02:15.102Z

well that's clear :)

alexmiller 2019-03-08T19:02:40.102500Z

is it the execution policy as described at https://github.com/ajoberstar/ClojureTools ?

alexmiller 2019-03-08T19:02:57.103Z

Set-ExecutionPolicy RemoteSigned -Scope CurrentUser ?

timgilbert 2019-03-08T19:02:57.103100Z

Yeah, I got that too, the script should probably check for root / elevate permissions before it does that

timgilbert 2019-03-08T19:03:12.103500Z

Hmm, dunno

alexmiller 2019-03-08T19:03:24.103800Z

it's always good to download scripts from the internet that elevate permissions

timgilbert 2019-03-08T19:04:53.104100Z

wget | sudo sh

seancorfield 2019-03-08T19:11:17.104600Z

Success if I install it into my local modules location

PS Y:\Downloads> .\win-install-1.10.0.434.ps1
Downloading Clojure tools
WARNING: Clojure will install as a module in your PowerShell module path.

Possible install locations:
  1) \\Mac\Home\Documents\WindowsPowerShell\Modules
  2) C:\Program Files\WindowsPowerShell\Modules
  3) C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\
Enter number of preferred install location: 1

Cleaning up existing install
Installing PowerShell module
Removing download
Clojure now installed. Use "clj -h" for help.
PS Y:\Downloads>

seancorfield 2019-03-08T19:11:31.104800Z

PS Y:\Downloads> clj -Sdescribe
{:version "1.10.0.434"

alexmiller 2019-03-08T19:17:56.105Z

woohoo

alexmiller 2019-03-08T19:18:19.105500Z

I want to be able to tell people to try this, but also I want to tell them something likely to work :)

seancorfield 2019-03-08T19:19:12.106200Z

PS X:\workspace\wsmain\clojure\lowlevel> $env:CLJ_CONFIG
PS X:\workspace\wsmain\clojure\lowlevel> $env:CLJ_CONFIG='..\versions'
PS X:\workspace\wsmain\clojure\lowlevel> $env:CLJ_CONFIG
..\versions
PS X:\workspace\wsmain\clojure\lowlevel> clj -A:defaults:test-deps:test:runner

Running tests in #{"test"}
...
From a clean install.

timgilbert 2019-03-08T19:19:15.106400Z

As long as they use option 1 (home directory) I reckon it should work

alexmiller 2019-03-08T19:19:26.106900Z

why are there options then? :)

timgilbert 2019-03-08T19:19:30.107100Z

(And they don't hit the classpath limit)

seancorfield 2019-03-08T19:19:39.107600Z

So, yeah, with a few caveats, it works smoothly πŸ™‚

alexmiller 2019-03-08T19:19:58.108200Z

did you have to do the security thing?

timgilbert 2019-03-08T19:20:30.109Z

One weird thing about option 1 is it puts a folder into Documents, which is slightly irritating

seancorfield 2019-03-08T19:20:54.109700Z

I did not (but it's possible it was in effect from last time?). I only had to do that on one machine -- the other machine defaulted to allowing it...

timgilbert 2019-03-08T19:21:19.110300Z

Possibly it would be better to instruct users to run as admin and choose 2 or 3

timgilbert 2019-03-08T19:22:21.111500Z

I don't think I had to mess with that setting but I might have already fiddled with it to get other OSS stuff working. I can check tonight on a different machine

alexmiller 2019-03-08T19:33:33.111700Z

dumped some stuff here, please update https://github.com/clojure/tools.deps.alpha/wiki/clj-on-Windows

alexmiller 2019-03-08T19:33:58.112Z

I'm particularly not sure if I got all that info right from the chat here

alexmiller 2019-03-08T19:34:29.112500Z

does this all assume being in a powershell terminal? (and is that the right words to call that?)

alexmiller 2019-03-08T19:37:03.112800Z

feel free to just edit and fix

timgilbert 2019-03-08T19:48:09.113Z

Everything looks good to me

βœ”οΈ 1
ivangalbans 2019-03-08T21:00:05.115500Z

I have installed clj on Windows without problems but when I do:

clojure -Sdeps '{:deps {friendly {:git/url "<https://gist.github.com/bhb/2686b023d074ac052dbc21f12f324f18>" :sha "418bf66fd96851cc55398b55d5a8aff65692f565"}}}' -m friendly
I get this error:
Error while parsing option "--config-data {:deps {friendly {:git/url <https://gist.github.com/bhb/2686b023d074ac052dbc21f12f324f18> :sha 418bf66fd96851cc55398b55d5a8aff65692f565}}}": java.lang.RuntimeException: Invalid token: <https://gist.github.com/bhb/2686b023d074ac052dbc21f12f324f18>

ivangalbans 2019-03-08T21:03:50.115900Z

somebody have some idea how can i fix this error?

seancorfield 2019-03-08T21:04:35.116600Z

Sounds like a quoting issue in the script. Want to file a bug on TDEPS JIRA?

πŸ‘ 1
alexmiller 2019-03-08T21:13:01.120800Z

looks like the script builds up the $ToolsArgs array and then drops it on the command line. probably want something to do the equivalent of unquote splice

πŸ‘ 1
alexmiller 2019-03-08T21:15:12.122400Z

yeah should be @ToolsArgs I think

πŸ‘ 1
timgilbert 2019-03-08T21:15:51.123200Z

Say @alexmiller, I've been playing around more with the classpath thing on Windows and figured out how to get it working with absolute paths to the local jars (in the maven repository). One thing that occured to me is that you could think of the "pathing jar" as just a differently-formatted version of what's currently in ~/.cpcache/&lt;hash&gt;.cp, so that maybe from the Clojure side we could construct a ~/.cpcache/&lt;hash&gt;.jar at the same time as the .cp file, and then the PS script could check for that and use it it it's present. What do you think about that approach? I can try to work up a patch if it seems reasonable

timgilbert 2019-03-08T21:17:32.123900Z

Also maybe I'll open a ticket for this stuff so it doesn't wash away in the Slack history

alexmiller 2019-03-08T21:18:34.124300Z

that sounds better - I'd make a ticket for it in TDEPS

πŸ‘ 1
alexmiller 2019-03-08T21:19:04.124600Z

@ivangalbans updated build at https://download.clojure.org/install/win-install-1.10.0.436.ps1

πŸ‘ 1
ivangalbans 2019-03-08T21:21:15.125300Z

thanks @alexmiller, I will try this

ivangalbans 2019-03-08T21:48:47.126400Z

@alexmiller i'm getting this error now with win-install-1.10.0.436.ps1.

Invoke-WebRequest : Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
At C:\Users\ivan\Downloads\win-install-1.10.0.436.ps1:10 char:1
+ Invoke-WebRequest -Uri $ClojureToolsUrl -OutFile clojure-tools.zip
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Invoke-WebRequest], IOException
    + FullyQualifiedErrorId : System.IO.IOException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

seancorfield 2019-03-08T21:51:35.127500Z

It installed cleanly for me -- but only the window in which I ran the installer saw the new version. How do I tell PS to refresh/reload/whatever a module that has already been imported?

alexmiller 2019-03-08T21:52:05.127800Z

well the line that is failing is before that - that's the download

alexmiller 2019-03-08T21:52:16.128100Z

do you still have a clojure-tools.zip sitting there?

alexmiller 2019-03-08T21:53:43.128400Z

like is it barfing on writing over an existing file?

alexmiller 2019-03-08T21:56:19.129200Z

well actually I guess the error is on reading from the network. maybe just try it again?

πŸ‘ 1
raydel95 2019-03-08T22:01:54.131100Z

hi, i tried to run https://download.clojure.org/install/win-install-1.10.0.436.ps1 and i got this error after i select the path

raydel95 2019-03-08T22:02:02.131300Z

New-Object : Exception calling ".ctor" with "3" argument(s): "End of Central Directory record could not be found."
At
C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\Microsoft.PowerShell.Archive\Microsoft.PowerShell.Archive.psm1:934
char:23
+ ... ipArchive = New-Object -TypeName System.IO.Compression.ZipArchive -Ar ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [New-Object], MethodInvocationException
    + FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand

raydel95 2019-03-08T22:02:12.131600Z

any ideas?

alexmiller 2019-03-08T22:03:11.132200Z

that doesn't seem to be in the clojure script ?

raydel95 2019-03-08T22:04:07.132800Z

i just did .\win-install-1.10.0.436.ps1 in my powershell

raydel95 2019-03-08T22:05:08.133Z

:thinking_face:

alexmiller 2019-03-08T22:09:04.133400Z

maybe a powershell version thing? what version do you have?

alexmiller 2019-03-08T22:11:01.133600Z

$PSVersionTable.PSVersion

alexmiller 2019-03-08T22:11:28.134Z

was tested with PowerShell Core 6

raydel95 2019-03-08T22:11:49.134400Z

build 17763 revision 316

raydel95 2019-03-08T22:12:20.134800Z

Major  Minor  Build  Revision
-----  -----  -----  --------
5      1      17763  316

alexmiller 2019-03-08T22:12:46.135400Z

so, 5.1. maybe the script is using something new in 6. just guessing

πŸ‘ 1
seancorfield 2019-03-08T22:15:51.136700Z

How old is build 17763? I'm on 18343 (but I am on fast ring insider builds).

alexmiller 2019-03-08T22:16:02.137Z

looks like it's coming from the zip expansion

alexmiller 2019-03-08T22:18:57.137300Z

possibly a corrupt downloaded zip file?

alexmiller 2019-03-08T22:19:28.137900Z

I will retract what I said above on versioning, doesn't seem like that's the issue

1
alexmiller 2019-03-08T22:20:47.138700Z

If it fails and you still have the clojure-tools.zip file there, try opening it and see if it works

raydel95 2019-03-08T22:22:28.139Z

i don't have the file

timgilbert 2019-03-08T22:30:36.139800Z

I'm running on

Major  Minor  Build  Revision
-----  -----  -----  --------
5      1      17134  590
...and things are hunky-dory for me.

1
alexmiller 2019-03-08T22:37:06.140100Z

@raydelalonsobaryolo did you try it more than once?

raydel95 2019-03-08T22:42:07.141400Z

I tried again, and it works, thanks

raydel95 2019-03-08T22:44:10.142100Z

when i run this clojure -Sdeps '{:deps {friendly {:git/url "<https://gist.github.com/bhb/2686b023d074ac052dbc21f12f324f18>" :sha "418bf66fd96851cc55398b55d5a8aff65692f565"}}}' -m friendly, i get this error

raydel95 2019-03-08T22:44:23.142300Z

Error while parsing option "--config-data {:deps {friendly {:git/url <https://gist.github.com/bhb/2686b023d074ac052dbc21f12f324f18> :sha 418bf66fd96851cc55398b55d5a8aff65692f565}}}": java.lang.RuntimeException: Invalid token: <https://gist.github.com/bhb/2686b023d074ac052dbc21f12f324f18>

alexmiller 2019-03-08T22:53:21.143Z

prob best to file a jira ticket so we can track it, not going to be able to solve it right now

seancorfield 2019-03-08T22:54:23.143400Z

I think @ivangalbans may have filed that one earlier today?

alexmiller 2019-03-08T22:55:27.144400Z

I think he's using the version after the fix

alexmiller 2019-03-08T22:55:33.144600Z

"fix" I should say

alexmiller 2019-03-08T22:56:10.145500Z

I made the change I thought would help that in 1.10.0.436

seancorfield 2019-03-08T22:56:11.145600Z

Oh. I'm with you. So it still needs a JIRA ticket then.

seancorfield 2019-03-08T22:56:28.145900Z

I'll go file one, to save anyone else...

alexmiller 2019-03-08T22:56:34.146100Z

thx

seancorfield 2019-03-08T22:59:24.146500Z

https://dev.clojure.org/jira/browse/TDEPS-121 @ivangalbans @raydelalonsobaryolo

πŸ‘ 2
ajoberstar 2019-03-08T23:30:44.153700Z

Looks like the wiki captures all of the main points but I can add some clarification about the install locations tomorrow. They're all generated from the users existing modulepath, and this can differ between Windows PS and PS Core (and different again on Linux PS Core). So figured we'd just display all options in your path instead of trying to hardcode one. Should probably get a better message in the prompt about the need for an elevated PowerShell for some locations. Thanks everyone for helping test!

πŸ‘ 2