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-14T06:43:11.195800Z

Thanks @borkdude the usage looks very nice; I am not very familiar with Babashka though so how do I use this script? I place it in a folder somewhere or need to execute the script on the commandline before I can use it?

borkdude 2021-04-14T07:28:26.196100Z

@flyingpython You must install babashka first e.g. using #scoop

borkdude 2021-04-14T07:28:41.196400Z

And then you can execute the script with bb new.clj

borkdude 2021-04-14T07:29:29.197100Z

if you want to execute it globally you can make a .bat script out of it with this "shebang": https://github.com/borkdude/deps.clj/blob/master/deps.bat#L1-L7 so you can then rename it to new.bat and place it somewhere on your path

borkdude 2021-04-14T07:30:14.197600Z

and then you can run C:\Foo> new anywhere

Rowan Barnard 2021-04-14T07:34:15.199Z

OK thanks borkdude, I have some great options now to make these templates pain-free 🙂

pez 2021-04-14T19:32:40.200700Z

I fail to get clojure to work. ps1 module or scoop, I get the same result. Installation seems to get done, but running clj I get

Error: Could not find or load main class clojure.main
Anyone recognize this?

pez 2021-04-14T19:33:53.201300Z

(Tried all three installation options for the PS module.)

seancorfield 2021-04-14T19:41:20.202Z

@pez Just checking: are you sure you didn’t have a clj script on your path before, i.e., a non-official clj?

seancorfield 2021-04-14T19:41:36.202300Z

(what does running clojure produce?)

pez 2021-04-14T19:54:11.203800Z

Running clojure produces:

Error: Could not find or load main class clojure.main
Caused by: java.lang.ClassNotFoundException: clojure.main
It is a completely fresh Windows install. The PC arrived yesterday. No clj there before, I am pretty sure.

borkdude 2021-04-14T19:56:42.204300Z

what does clojure --version produce

pez 2021-04-14T20:02:24.204500Z

Clojure CLI version 1.10.3.822

borkdude 2021-04-14T20:03:05.204700Z

that looks good

borkdude 2021-04-14T20:03:15.205Z

is this still with your user with the space in it?

pez 2021-04-14T20:06:13.205400Z

Yes, that user.

borkdude 2021-04-14T20:07:22.205700Z

might be related? try a user without space?

pez 2021-04-14T20:13:27.205900Z

Doing it.

pez 2021-04-14T20:14:05.206700Z

But it won’t help me, because I need it t work with the user with space in order to have the environment where the thing I am investigating happens.

borkdude 2021-04-14T20:14:24.207Z

yes, but narrowing down the issue helps probably?

pez 2021-04-14T20:15:15.207400Z

Oh, yes, I said, I’m doing it. 😃

borkdude 2021-04-14T20:15:47.207800Z

does this mean: it works, or I'm going to try? just trying to narrow down the meaning ;)

pez 2021-04-14T20:16:50.208300Z

It means I’m trying with the non-space user.

pez 2021-04-14T20:17:20.208900Z

clojure works then.

borkdude 2021-04-14T20:17:42.209400Z

ok, so now we need to figure out if it's the powershell script or something in tools.deps or both

borkdude 2021-04-14T20:18:18.210100Z

if it's in tools.deps, this might explain why you get it with both the official clojure and deps.clj

pez 2021-04-14T20:18:19.210200Z

lein works in both environments

borkdude 2021-04-14T20:18:27.210400Z

yeah, but lein doesn't use tools.deps

pez 2021-04-14T20:18:41.210700Z

I’m just sayin’ 😃

alexmiller 2021-04-14T20:19:44.212400Z

the error sounds like it is a bad command to Java, which leads me to strongly suspect something in the powershell

pez 2021-04-14T20:20:41.213600Z

cmd-clj has the same problem. But that doesn’t mean it is not something in the powershell of course.

borkdude 2021-04-14T20:20:51.213900Z

fwiw there is a similar error in deps.clj (the unofficial one) but we still haven't nailed it down. I can't reproduce it with a Windows user with a space

borkdude 2021-04-14T20:21:06.214300Z

what is cmd-clj?

littleli 2021-04-15T09:08:48.235300Z

fyi cmd-clj and cmd-clojure are scoop shims that launch clojure from the cmd.exe, they still require powershell, but don't expect powershell as a initial prompt.

littleli 2021-04-15T09:09:07.235500Z

I would recommend to avoid them at all costs 🙂

littleli 2021-04-15T09:11:49.235700Z

[[
   "powershell.exe",
   "cmd-clojure",
   "-NoProfile -ExecutionPolicy Bypass -Command Invoke-Clojure"
],
[
   "powershell.exe",
   "cmd-clj",
   "-NoProfile -ExecutionPolicy Bypass -Command Invoke-Clojure"
]]
This is a prescription for those two shims

alexmiller 2021-04-14T20:21:25.215Z

not sure if like this needs some escaping around $ToolsCp ?

& $JavaCmd -classpath $ToolsCp clojure.main -m clojure.tools.deps.alpha.script.make-classpath2 --config-user $ConfigUser --config-project $ConfigProject --basis-file $BasisFile --libs-file $LibsFile --cp-file $CpFile --jvm-file $JvmFile --main-file $MainFile @ToolsArgs

alexmiller 2021-04-14T20:21:59.215600Z

or even in $JavaCmd

alexmiller 2021-04-14T20:22:21.216300Z

or well... all of those file args

pez 2021-04-14T20:22:39.216900Z

The deps.clj problem is what I am trying to nail down. But running deps.clj in dev with lein just gives me a sweet Clojure prompt…

borkdude 2021-04-14T20:23:12.217300Z

@pez what if you execute the deps.bat script?

borkdude 2021-04-14T20:23:24.217500Z

and are you on the master branch?

pez 2021-04-14T20:25:38.218Z

Yes, on master branch. Will try the deps.bat scrit now.

pez 2021-04-14T20:30:28.218800Z

deps.bat gives me back the shell prompt after a short delay. Nothing else.

pez 2021-04-14T20:31:53.220200Z

@alexmiller, I’m not following about the escaping.

pez 2021-04-14T20:37:39.225600Z

For context: On some windows machines deps.clj fails if the user’s home directory has spaces in it. I bought a PC to try investigate it and had some luck there because it happens on that PC. It does not happen on @borkdude’s machine, using the same user name as I am trying with. When trying to narrow it down I want to run deps.clj in dev, and then ran into this problem with not being able to run clojure. Both deps.clj and clojure works on the machine for a username w/o spaces in it.

pez 2021-04-14T20:39:07.227Z

> what is cmd-clj? It’s a command installed together with clojure and clj for running clj from cmd.exe.

borkdude 2021-04-14T20:56:48.227300Z

@pez any luck with deps.bat ?

pez 2021-04-14T21:01:24.227900Z

It just returns the PS prompt.

borkdude 2021-04-14T21:05:32.228400Z

how are you running it?

borkdude 2021-04-14T21:05:58.228700Z

@pez it needs babashka to run. does bb work in your PS?