Fork me on GitHub
#clr
<
2023-06-04
>
dmiller03:06:34

Feedback request: I'm working on supporting deps.edn and the CLI tooling in ClojureCLR. Aiming toward getting most of https://clojure.org/guides/deps_and_cli working. A port of https://github.com/clojure/tools.deps which supplies dependency-chasing, library downloading and classpath (or its equivalent for ClojureCLR) is in progress. The code has been ported, but more testing is needed. The next step will be to work on the command-line interface. This is the clj and 'clojure commands discussed in the guide material linked to above. Where I'd like feedback is the mode of delivery. The two most obvious choices are; (1) PowerShell cmdlet; and (2) dotnet tool install. If you've used cli/`clojure` for ClojureJVM on Windows, you will have gone through steps outlined in https://github.com/clojure/tools.deps.alpha/wiki/clj-on-Windows. That downloads a PowerShell script that downloads a zip file containing the neccessary pieces to run Clojure. The cli and clojure commands aliases for a PowerShell cmdlet that is installed by installation script. (For those who like details, the cmdlet is defined by https://github.com/clojure/brew-install/blob/1.11.1/src/main/resources/clojure/install/ClojureTools.psd1 and https://github.com/clojure/brew-install/blob/1.11.1/src/main/resources/clojure/install/ClojureTools.psm1 .) If you followed the installation instructions for ClojureCLR, you know that we install clojure.main as dotnet tool. One simple command downloads the tool from http://Nuget.org. What would you like to see? FYI, from my side the considerations are: cmdlet: (+) we already have a script that does the heavy lifting of command-line argument parsing -- maybe modifying it for needs won't be too bad; (-) PowerShell programming is no my forte. dotnet tool: (+) installation would be simpler and would match what we already are doing for clojure.main. (+) I'm definitely more comfortable with C#. (-) I'd have to rewrite the command-line parsing. But the user experience should be driving this.

🚀 4
clojure-spin 4
djblue03:06:39

For me, getting started via dotnet tool was easy enough 💯

djblue03:06:35

In terms of dependency resolution, will there be a way to say these are my jvm deps vs clr deps? Currently my deps.edn contains https://github.com/clojure/data.jsonhttps://github.com/clojure/data.jsonhttps://github.com/clojure/data.json for the jvm but will need https://github.com/clojure/clr.data.json to run on the clr.

djblue03:06:25

I think another downside with cmdlet might be getting things working on linux and OSX involves more work

djblue03:06:32

Ohh, also in terms of additional work for command-line parsing, I think https://github.com/borkdude/deps.clj/blob/master/src/borkdude/deps.clj might already have some of it done since it's a "A faithful port of the clojure CLI bash script to Clojure"

lread04:06:55

Yes, the PowerShell module that the Clojure team currently uses for clojure on Windows makes shelling out to clojure and cmd line parsing tricky. The Clojure core team was (and maybe still is) considering moving to https://github.com/casselc/clj-msi/releases or similar (which is an installer for a natively compiled deps.clj).

seancorfield04:06:18

Given that the CLR tooling can be installed on macOS/Linux as well as Windows, perhaps not conflicting with the existing clj / clojure commands would be a good idea -- and based on my (limited) experience so far with the .NET stuff, I like the idea of a dotnet install command for the CLI (which would work for both Windows and for macOS/Linux, yes?). The Powershell stuff we have for the CLI so far is pretty nasty (and is hopefully going away)...

chucklehead05:06:23

I would lean toward dotnet install also. With the PowerShell approach clojure and clj are only shell aliases so they can’t be invoked in a cmd shell or via CreateProcess, Process.Start, etc. Having a tool that can actually be somewhere on the system/user PATH is preferable imo. I don’t see any reason to add the complexity of an MSI installer given how easy it is to do a tool install, but I’d be happy to make a version of the clj-msi installer for clr if there is interest.

dangercoder11:06:16

dotnet tool , easy to install and makes things very accessible

dmiller12:06:15

Thanks for all the input. Valuable perspective on how the decision affects usability in ways that I had not considered. Sounds like dotnet tool or dotnet install. (I'm always pleased when the consensus points to my preference. 🙂 ) @UBN9SNVB4 -- System.CommandLine was my bedtime reading. (I like how it's been in beta for 2.5 years -- and also has almost 16 million downloads over that span.)

dmiller12:06:32

@U1G869VNV re your question on clr-deps vs jvm-deps came up in conversation I was having with @U04V70XH6 on the cross-platforming of tools.cli The root problem is that the edn reader does not support reader conditionalization. Sean had some interesting approaches, but after Sean convened somewhere an enclave of wizards, the conclusion was that the simplest approach would be to have ClojureCLR look first for a deps-clr.edn (actual name TBD) with a fallback to deps.edn on the assumption it might have git/local deps only. a deps-clr.edn really would only be needed on a cross-platform library.

dmiller13:06:24

@U1G869VNV and thanks for the pointer to https://github.com/borkdude/deps.clj. I had run across it before but had forgotten about it. Nor realized that the present circumstance is where it would reveal its utility. Always nice to read through @U04V15CAJ’s code, even more so when the alternative is bash or PowerShell scripts.

borkdude13:06:20

The code of deps.clj is more or less a direct port of the bash script, I didn't write it to produce nice-to-read code :)

borkdude13:06:15

deps.clj supports -Sdeps-file so you could do -Sdeps-file deps-clr.edn

dmiller13:06:03

@U04V15CAJ: @U0ETXRFEW has been turning out some great code. I'll be stealing what I can. Not full deps and its dockerized, so I need to fill in some gaps for the more general use case. Re -Sdeps-file -- I was thinking not to put the burden on the user. Wouldn't it be better to bake it in?

borkdude13:06:16

@U45FQSBF1 I don't know what you are exactly building, but let me add this: The powershell installer will disappear as the official option at one point in favor of a flavor of a standalone executable based on deps.clj which is thing thing: https://github.com/casselc/clj-msi The reason is that a powershell module isn't great for interoperability and there's more reasons that you can find in #clj-on-windows

borkdude13:06:30

@U45FQSBF1 If it's helpful, we could add clojure CLR support to deps.clj (not sure if that is helpful, but I'd be open to it)

dmiller15:06:54

@U04V15CAJ the goal is to provide the same functionality as the cli/`clojure` CLIs with deps.edn configuration. We need the dependency chasing and the equivalent to classpath building. Looking at procurers for local, git, and nuget, but not supporting mvn, poms, etc.

borkdude15:06:44

alright, so basically building tools.deps for clr from scratch (ah yes, you can re-use the git stuff)

dmiller15:06:29

Yep.. I already ported tools.gitlibs. (https://github.com/clojure/clr.tools.gitlibs)

👍 3
dmiller21:06:57

@dangercoder System.CommandLine has a very specific notion of what a command line should look like. Mostly follows POSIX standards, it appears. The specified syntax for the Clojure CLI tools does not appear to follow that standard. I do not see how to map one to the other. Leaving the choices: (1) use System.CommandLine and have a different syntax for the ClojureCLR version. (2) Follow the Clojure CLI tool syntax. For those who want/need to go both ways, I suspect (2) is the only friendly option. Given that we have examples from the PowerShell script and from @U04V15CAJ’s deps.clj, I doubt I would save (much) time over option (1).

seancorfield21:06:40

True, the Clojure CLI is pretty quirky in places... But it is also a relatively small "parsing space"...

👍 2