clr

dmiller 2023-06-04T03:09:34.433999Z

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.

3
πŸš€ 2
dmiller 2023-06-05T21:12:57.577509Z

@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 @borkdude’s deps.clj, I doubt I would save (much) time over option (1).

seancorfield 2023-06-05T21:15:40.866359Z

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

πŸ‘ 1
djblue 2023-06-04T03:32:39.524129Z

For me, getting started via dotnet tool was easy enough πŸ’―

djblue 2023-06-04T03:35:35.986279Z

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.

djblue 2023-06-04T03:38:25.987429Z

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

djblue 2023-06-04T03:51:32.328729Z

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"

lread 2023-06-04T04:23:55.980469Z

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).

seancorfield 2023-06-04T04:48:18.047869Z

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)...

chucklehead 2023-06-04T05:26:23.712779Z

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.

dangercoder 2023-06-04T11:25:16.080069Z

dotnet tool , easy to install and makes things very accessible

dangercoder 2023-06-04T11:34:05.773479Z

@dmiller if you have to write the command line parsing in C#: https://learn.microsoft.com/en-us/dotnet/standard/commandline/get-started-tutorial

πŸ‘ 1
dmiller 2023-06-04T12:40:15.229369Z

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. πŸ™‚ ) @jarvinenemil -- 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.)

dmiller 2023-06-04T12:58:32.703379Z

@djblue re your question on clr-deps vs jvm-deps came up in conversation I was having with @seancorfield 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.

dmiller 2023-06-04T13:22:24.529519Z

@djblue 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 @borkdude’s code, even more so when the alternative is bash or PowerShell scripts.

borkdude 2023-06-04T13:24:46.547249Z

Have you seen this? It's based on deps.clj /bb as well: https://blog.agical.se/en/posts/how-to-create-a-really-simple-clojureclr-dependency-tool/

borkdude 2023-06-04T13:25:20.114719Z

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 :)

borkdude 2023-06-04T13:26:15.413159Z

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

dmiller 2023-06-04T13:36:03.803449Z

@borkdude: @pez 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?

borkdude 2023-06-04T13:38:16.055639Z

@dmiller 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

borkdude 2023-06-04T13:39:30.913349Z

@dmiller 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)

dmiller 2023-06-04T15:18:54.302889Z

@borkdude 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.

borkdude 2023-06-04T15:19:44.169969Z

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

dmiller 2023-06-04T15:23:29.740169Z

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

πŸ‘ 2