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.
mseddon 2019-04-04T00:05:27.038500Z

Is the issue that people are hitting initially installing on windows or general behaviour of the clj command?

mseddon 2019-04-04T00:08:29.043100Z

Keen to bring clj to everyone, but am curious why there is no release yet. I have been lucky and had no problems, what should be done to move clj to windows without snaring the unsuspecting.

ajoberstar 2019-04-04T00:10:23.046200Z

If it stays as a PowerShell module, Id still like to see it distributed on PS Gallery so that it's just an Install-Module command to get it installed. Would remove me some of the oddities of the script prompting for locations, etc.

👍 2
mseddon 2019-04-04T00:12:29.046900Z

So, zero configuration install, rather than the third degree?

ajoberstar 2019-04-04T00:14:30.047100Z

Yeah, with Install-Module the default is to install at the system level, which requires admin, but you can provide "-Scope CurrentUser" to install it in the user module directory. But that would be the user making the choice at the time they install. I think we'd run into fewer execution policy problems that way to.

ajoberstar 2019-04-04T00:14:46.047300Z

However, that doesn't address some of these concerns about using from other shells.

mseddon 2019-04-04T00:20:18.047500Z

Ah, are people trying to run it from WPL too? :)

ajoberstar 2019-04-04T00:20:45.047700Z

WSL?

ajoberstar 2019-04-04T00:20:52.047900Z

In that case you can use the linux install

ajoberstar 2019-04-04T00:21:28.048100Z

But @miridius mentioned cmd.exe, Git bash, Cmder

mseddon 2019-04-04T00:22:03.048300Z

Point. That should just work.

mseddon 2019-04-04T00:22:59.048500Z

So cmd.exe and git bash I know, will have to look at cmder since I haven't used that.

ajoberstar 2019-04-04T00:23:33.048700Z

I think cmder is just wrapping other shells, so I don't think it adds any new wrinkles to this.

mseddon 2019-04-04T00:24:50.048900Z

So the issue is it isn't working in these envs and an 'uberinstall' is needed to cover them all?

ajoberstar 2019-04-04T00:25:18.049200Z

The issue is that a PowerShell module doesn't add commands to the PATH, where other shells would look for them

ajoberstar 2019-04-04T00:25:33.049400Z

The nice part (from my perspective) is that you don't have to mess with people's PATH variable

ajoberstar 2019-04-04T00:25:50.049600Z

Since it's not like Linux where you drop the binary in /usr/bin or something like that

ajoberstar 2019-04-04T00:26:06.049800Z

Then again, adding to the PATH variable is a common Windows thing.

mseddon 2019-04-04T00:28:15.050Z

Yeah, that part confuses me. Windows by convention doesn't have a common binary path, why can't it just install to \Programs\Clojure and add that to the PATH? Everything else does, and powershell can do this...

ajoberstar 2019-04-04T00:29:02.050200Z

Certainly can. That's closer to how it worked when I started working on my contributions.

ajoberstar 2019-04-04T00:29:30.050400Z

The PowerShell module approach cleans some aspects of the code up. But can still be combined with adding things to the PATH

seancorfield 2019-04-04T00:30:13.050600Z

If we could just "force" everyone to use PowerShell on Windows, we could solve this easily 🙂

mseddon 2019-04-04T00:30:21.050800Z

I guess I am just confused. clj is working fine for me. I don't understand the politics that is pushing against a release ;)

ajoberstar 2019-04-04T00:30:39.051Z

Sounds good to me @seancorfield

mseddon 2019-04-04T00:31:13.051200Z

Naturally a .bat could be shipped with a standard installer and a zip for those who want more control

seancorfield 2019-04-04T00:31:59.051400Z

I think getting it into the PS Gallery would address a lot of the current glitches folks are running into -- and I don't see that as being much different to having the Mac installers go into brew.

seancorfield 2019-04-04T00:32:53.051600Z

The only other integration point is editors: and I think that would require them all getting on board with having to invoke it via the powershell command, right?

ajoberstar 2019-04-04T00:33:04.051800Z

I think so

seancorfield 2019-04-04T00:36:23.052Z

To be honest, I think the alternate shell issue is a red herring. Do the PS install as a one-off and then just use powershell clj -A:rebl-8 or whatever from cmd and you're up and running.

seancorfield 2019-04-04T00:36:45.052200Z

(I'm still very excited that I can run REBL on Windows that easily!)

ajoberstar 2019-04-04T00:37:21.052400Z

That's a good point on the other shells. Hadn't thought about that.

mseddon 2019-04-04T00:43:20.052600Z

The funny thing is, until recently I didn't understand enough powershell escaping to launch lein from powershell effectively. Mostly because I needed to escape --. It was never clear to me reading the official manual, so I can understand why tools may have issues with that, especially if the devs aren't familiar with the platform

ajoberstar 2019-04-04T00:44:20.052800Z

As part of the updates for clj, I learned that --% is a shortcut for terminating powershells normal parsing

ajoberstar 2019-04-04T00:44:35.053Z

So you could do lein --% --my-normal-args

ajoberstar 2019-04-04T00:44:47.053200Z

However, that might not be any better than remembering to quote things

mseddon 2019-04-04T00:44:55.053400Z

What was nice with clj is its client's syntax is remarkably compatible across ps, sh and cmd

seancorfield 2019-04-04T00:45:43.053700Z

Is there a nice, simple way to update the PowerShell clj version to the latest release? Or is that something that will really only come once it's up on somewhere standard like PS Gallery?

ajoberstar 2019-04-04T00:46:13.053900Z

I don't think there is in the current one

ajoberstar 2019-04-04T00:46:37.054100Z

With PSGallery, it would be Update-Module

mseddon 2019-04-04T00:46:47.054300Z

Good point. Personally I use chocolatey for reasonable package management under Windows

ajoberstar 2019-04-04T00:47:46.054500Z

Yeah, chocolatey's alright. PSGallery wouldn't require an additional install (chocolatey itself) to work though. PowerShell comes with the PSGallery repo registered by default

mseddon 2019-04-04T00:49:29.054700Z

I mean.. clojure-tools.jar could do the check and even replace it's jar under Windows. One of the nice things about not being an exe is windows doesn't lock you out when it is executing because sun thought of that ;)

ajoberstar 2019-04-04T00:50:32.054900Z

On Windows you can't replace a JAR file that's on the classpath of a running JVM

mseddon 2019-04-04T00:51:13.055100Z

Ahh. You definitely used to be able to. :(

mseddon 2019-04-04T00:51:35.055300Z

Something about Oracle.

ajoberstar 2019-04-04T00:51:47.055500Z

You might be able to move the JAR and then put the new one in it's place, but pretty sure you can't delete/overwrite the file.

mseddon 2019-04-04T00:53:04.055700Z

Yeah you could probably do that. Though you would probably need to delete yourself if you aren't System

mseddon 2019-04-04T00:56:10.055900Z

That said, it was possible to write out a new Exe, execute it, and have it delete the parent years ago. Though following in malware's footsteps is probably not a great idea.

ajoberstar 2019-04-04T00:57:32.056100Z

I'd still vote for PSGallery and "embracing the host" and it's install/update process. 😉

mseddon 2019-04-04T00:58:08.056300Z

Don't think that particular 'feature' is an intentional security boundary though... UAC isn't officially I recently learned 😭

ajoberstar 2019-04-04T00:58:55.056500Z

Not following. Isn't officially what?

mseddon 2019-04-04T00:59:36.056700Z

A boundary in the operating system designed to protect security bypass

mseddon 2019-04-04T01:00:20.056900Z

There are many unpatched UAC bypasses in windows. The official position is "we don't care" :/

ajoberstar 2019-04-04T01:00:26.057100Z

Interesting

mseddon 2019-04-04T01:01:31.057300Z

https://github.com/hfiref0x/UACME/blob/master/README.md "yaay"

mseddon 2019-04-04T01:03:18.057600Z

Anyway, that is massively OT, sorry.

mseddon 2019-04-04T01:06:34.057800Z

But yeah, it would be possible for the .jar itself to implement an update command which downloaded the new jar to temp, then launched it and killed itself, such that the new jar could overwrite it

ajoberstar 2019-04-04T01:07:36.058Z

Well it may not just be JAR updates. I'm not going to pretend there aren't bugs in the .psm1 file after I touched it. 😁

ajoberstar 2019-04-04T01:08:17.058200Z

All the more reason to leverage an update process that's outside of the clj tooling. (Whether PSGallery or Chocolatey)

1
mseddon 2019-04-04T01:08:48.058500Z

:D me either. I also guess that also cmd users could be catered for?

seancorfield 2019-04-04T01:09:05.058700Z

Tell them to run powershell clj. Seriously.

💯 2
mseddon 2019-04-04T01:10:20.059100Z

Other than my own ignorance, powershell hasn't failed me so far

seancorfield 2019-04-04T01:10:23.059300Z

Even for the install process, in cmd you can just type powershell and you're in PS. Type the single install-from-PS-Gallery command, then exit and you're back in cmd and you're done.

seancorfield 2019-04-04T01:10:53.059600Z

(in fact, you could probably just do powershell Install-Module ... directly from cmd right?)

ajoberstar 2019-04-04T01:11:02.059800Z

Never tried it

ajoberstar 2019-04-04T01:11:25.060Z

But yeah for install, definitely not a big deal to ask people to open a PS window

ajoberstar 2019-04-04T01:11:37.060200Z

And prefixing with powershell isn't that bad either for the other commands.

mseddon 2019-04-04T01:11:51.060400Z

I think you can pass a flag to put you there if it doesn't do it intitially

mseddon 2019-04-04T01:12:53.060600Z

And I refuse to believe a bat would be hard to produce, although I was surprised how much work clj.ps1 does

seancorfield 2019-04-04T01:13:23.060800Z

Try to write a .bat for it. I wouldn't want to tackle that! 🙂

mseddon 2019-04-04T01:13:29.061Z

Reasonable work, but no intuitive nontheless

ajoberstar 2019-04-04T01:13:30.061200Z

Agreed (with sean)

mseddon 2019-04-04T01:13:45.061500Z

Haha. You could always drop to vbs :)

seancorfield 2019-04-04T01:13:56.061700Z

@ajoberstar how do you pass an argument to Install-Module to scope it to the current user? (I'm just poking around at it here)

ajoberstar 2019-04-04T01:14:14.061900Z

Install-Module -Name Whatever -Scope CurrentUser

seancorfield 2019-04-04T01:15:07.062100Z

Ah, that was my problem -- I was trying to mix argument styles.

mseddon 2019-04-04T01:15:27.062300Z

Main issue is potentially nasty escaping passed from .bat to .ps in pathological cases, but again, clj avoids a lot of this silliness

seancorfield 2019-04-04T01:16:14.062500Z

So the answer is "Yes, you can invoke the PS installer via a single command from cmd"

seancorfield 2019-04-04T01:16:39.062700Z

(assuming you're trying to install something it knows about rather than a local custom module)

ajoberstar 2019-04-04T01:17:07.062900Z

So remaining hurdle would just be how does publishign to PS Gallery work from Cognitect's perspective and CI infrastructure

👍 1
mseddon 2019-04-04T01:17:12.063100Z

"we believe..." let's have a working example, but it seems totally feasible

ajoberstar 2019-04-04T01:17:27.063300Z

The publishing I've done to it has been from my desktop/laptop

alexmiller 2019-04-04T02:29:07.064600Z

pulling out of the thread and back to here...

alexmiller 2019-04-04T02:29:14.064800Z

there are clearly different technical options

alexmiller 2019-04-04T02:29:48.065500Z

someone needs to make a table that lists the options. and define some dimensions on which there are tradeoffs, and describe those tradeoffs

alexmiller 2019-04-04T02:30:04.065900Z

without that, we are all just talking, not making a technical decision

alexmiller 2019-04-04T02:31:02.067Z

there is at least one technical question buried in there too about update - can you update the jar and/or script while clj is running (I think that's unlikely, but someone should actually test it)

alexmiller 2019-04-04T02:32:22.067800Z

as far as how to get "built thing" to "deployed somewhere", that's the easy part. the hard part is determining what the thing is in the first place.