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.
Rowan Barnard 2021-04-01T03:26:26.056300Z

Hi @borkdude this shebang.bat is helpful for my issues on the Powershell commandline?

Rowan Barnard 2021-04-01T03:27:08.057Z

If so how would I use it? An example would be nice if you can ๐Ÿ™‚

Rowan Barnard 2021-04-01T05:12:43.060700Z

I have Babashka installed now and want to get the :args correct like this in Powershell: clojure -X:new :template luminus :name yourname/example.webapp :output '"mywebapp"' :args '["+h2" "+http-kit"]' I'm not having much luck though, it is becoming trial and error for me, I looked up Powershell escapes and it just seems to confuse me further. Here are my outputs so far:

borkdude 2021-04-01T09:20:10.061400Z

Sorry, the shebang.bat script was just a general remark of how you could get a shebang working on Windows. It wasn't related to your problem.

borkdude 2021-04-01T09:23:21.061600Z

@flyingpython I think this works:

bb -e "(map edn/read-string *command-line-args*)" '[\"foo\" \"bar\"]'
(["foo" "bar"])

Rowan Barnard 2021-04-01T09:32:51.063500Z

OK thanks I'll give that a try ๐Ÿ™‚

borkdude 2021-04-01T09:19:21.061300Z

deps.clj is now available as a babashka .bat script on Windows! The fastest way to get a Clojure REPL on Windows: curl -sLO https://raw.githubusercontent.com/borkdude/deps.clj/master/deps.bat & deps

borkdude 2021-04-01T09:25:47.062600Z

Honestly I don't think the -X API is better here: https://clojurians.slack.com/archives/CFN4QDHPS/p1617253963060700 I assume @flyingpython can still use the -main API @seancorfield ? I honestly don't think -X improves command line APIs in these cases. Why make it more complicated for users. I do understand the convenience of calling functions both from Clojure and the command line, but how much work is it really to maintain both and offer a good experience on the command line. I feel bad about seeing beginners struggle like this.

Rowan Barnard 2021-04-01T10:21:11.068600Z

OK I checked the output like you showed me @borkdude and I think it is correct, though I am not sure what is correct from a Linux/Unix point of view so it makes it hard for me to tell, but at least I get a different error now though, maybe progress?:

clojure -X:new :template luminus :name Rowan/guestbook :output '"mywebapp"' :args '[\"+h2\" \"+http-kit\"]'
Generating a Luminus project.
Execution error (IllegalArgumentException) at leiningen.new.templates/->files (templates.clj:171).
No implementation of method: :as-file of protocol: #'<http://clojure.java.io/Coercions|clojure.java.io/Coercions> found for class: clojure.lang.Symbol

Full report at:
C:\Users\celap\AppData\Local\Temp\clojure-10223585383419122293.edn
I think probably it is best for me to stop stubbornly trying to get this working on Windows and just get WSL2 installed and try it from there. Unless there is a simple solution to the above error?

borkdude 2021-04-01T10:22:05.068900Z

what is :name supported to be? maybe also a string?

Rowan Barnard 2021-04-01T10:23:06.069900Z

name is the project name it should be in the folder structure generated by the template

borkdude 2021-04-01T10:23:18.070300Z

(again: it makes me sad, angry, etc. that people have to go through this. just write an ff-ing command line interface!)

Rowan Barnard 2021-04-01T10:23:22.070400Z

Hang on I just grab Sean's original example for you

Rowan Barnard 2021-04-01T10:23:42.070600Z

clojure -X:new :template luminus :name yourname/example.webapp \
      :output '"mywebapp"' :args '["+http-kit" "+h2" "+reagent" "+auth"]'

Rowan Barnard 2021-04-01T10:24:07.071200Z

That slash in the middle is just a newline that Github puts there

Rowan Barnard 2021-04-01T10:24:41.072Z

So I take that out, didn't realise that at first and that gave me issues too ๐Ÿ˜…

borkdude 2021-04-01T10:24:46.072300Z

I suspect this error is about the :name, but I'm not sure.

Rowan Barnard 2021-04-01T10:26:13.073900Z

Nah it's OK I think it's a lot of me being stubborn trying to do things above my level before I reach that level - I could easily do it with Leiningen but I like Sean's setup and deps.edn and the Clojure CLI

borkdude 2021-04-01T10:26:36.074200Z

try :name '"Rowan/guestbook"'

Rowan Barnard 2021-04-01T10:26:49.074500Z

OK I'll try that

Rowan Barnard 2021-04-01T10:28:16.074800Z

No same error still so it's not that

lread 2021-04-01T11:23:47.077900Z

Hmmm... @borkdude, youโ€™ve just convinced me to also support the regular cmd line in addition to -X for a tool I am writing. Its docs currently have a tip for Windows users saying โ€œWindows users, trying to correctly escape -X args on the command line can lead to frustration. Consider instead specifying options under :exec-args in your :gen-doc-tests alias in deps.edn.โ€

borkdude 2021-04-01T11:25:03.078300Z

Imo regular command line has better UX as it's designed for... the command line, or at least up to the degree that people want to put effort into it. -X is convenient (for the author), but more limiting and frustrating when it comes to regular strings (be it top level strings or nested strings).

Rowan Barnard 2021-04-01T13:39:20.085200Z

I just found on https://github.com/practicalli/clojure-deps-edn what I think you are referring to (the commandline interface I mean): clojure -M:project/new luminus practicalli/full-stack-app +http-kit +h2 +reagent +auth So it has no string stuff which might cause problems I guess is the point right, so an easier interface for users? I think I better tell this Practicalli person whoever they are of the issues I had with this as they are supporting the edn argument passing method too and recommending that over the above. So it might be wise to re-visit that recommendation in light of my experience with this?

borkdude 2021-04-01T13:39:35.085500Z

yes!

Rowan Barnard 2021-04-01T13:40:24.086500Z

OK I'm going to bed now but will look at grabbing this tomorrow and seeing if that works for me ๐Ÿ™‚

borkdude 2021-04-01T13:40:46.086900Z

clojure -X:new :template luminus :name yourname/example.webapp :output '"mywebapp"' :args '["+http-kit" "+h2" "+reagent" "+auth"]'
clojure -M:project/new luminus practicalli/full-stack-app +http-kit +h2 +reagent +auth

Rowan Barnard 2021-04-01T13:41:32.087600Z

Do you know this person? I think someone should link him/her to this and maybe we can change their recommendation on that

borkdude 2021-04-01T13:42:52.087800Z

@jr0cket please read the conversation of yesterday and today and draw your own conclusions

Rowan Barnard 2021-04-01T13:43:33.088200Z

Oh cool thanks!