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.
seancorfield 2020-06-02T17:41:14.043500Z

@timon01 (continuing from a thread in #beginners ) -- What version of Windows are you running, and what version of Powershell do you have installed?

timonkot13 2020-06-02T18:05:55.048400Z

Windows 10 powershell: 5.1.17134.858. After previous error I decided to go into path System32/WindowsPowerShell/v1.0 and type there scoop install clojure . Install completes fine, but with pic, which errors writed on russian, it is translates like: "Can't find the way for powershell.exe, because it not existing" The second one is about "attrib": Name "attrib" unidentified like name of command, function or script e.t.c. Install is complete, but then I type "clj", I get the same message: Error: Could not find or load main class clojure.main.

borkdude 2020-06-02T18:07:11.049Z

As a temporary workaround you could try deps.clj: https://github.com/borkdude/deps.clj

timonkot13 2020-06-02T18:35:56.059700Z

@borkdude thx. but this is all like kind of my subproblem. My main purpose is that I need to compile my clojure files in android studio, to make my application run with clojure and kotlin/java. I tried clojurephant but it is not compile at all. I thinked it because i miss the quickstart three steps with clojure CLI. I also installed Cursive plugin for android studio, and when i try to debug single function i get the same magic error message. maybe some relation exist between my problems? Error: Could not find or load main class clojure.main Process finished with exit code 1

borkdude 2020-06-02T18:37:03.060400Z

@timon01 Could it be that you have a very old version of clojure installed somewhere? That wouldn't be the first time I've seen it

borkdude 2020-06-02T18:40:08.060800Z

Can you post the output of clojure -Sdescribe?

borkdude 2020-06-02T18:40:18.061Z

or the first lines of clojure -h

timonkot13 2020-06-02T18:47:26.061200Z

maybe it all because cyrilyc symbols in path?

borkdude 2020-06-02T18:55:12.061600Z

The output of this looks ok

borkdude 2020-06-02T18:55:32.061900Z

What do you get for clojure -Spath?

timonkot13 2020-06-02T18:58:42.062Z

borkdude 2020-06-02T19:01:13.062800Z

Also looks ok. What about clojure -e "(+ 1 2 3)" ?

timonkot13 2020-06-02T19:03:12.062900Z

borkdude 2020-06-02T19:08:33.063800Z

Have you tried closing the powershell window, starting a new one and then issue this command again?

borkdude 2020-06-02T19:10:24.064400Z

Other ideas: install lein, and try lein repl, see if that does work. Also try deps.clj, to check if it's something in the powershell scripting of clj on windows.

timonkot13 2020-06-02T19:15:43.065200Z

same problem. ok i'll try these things

alexmiller 2020-06-02T19:21:01.066600Z

I wonder if it's anything with non-latin characters in the user path. clojure just builds on java for all that but depending on your default character encoding I wonder if that's confusing something. just a long shot idea

alexmiller 2020-06-02T19:22:38.067Z

oh, I see that was suggested above

alexmiller 2020-06-02T19:23:54.068200Z

not finding clojure.main means you have a classpath issue. the classpath printed above "looks" like what I'd expect. you can get completely out of clj and just try java -cp <the-path-above> clojure.main

alexmiller 2020-06-02T19:24:15.068600Z

I guess I would verify that the clojure jar actually is where it says it is

👍 1
timonkot13 2020-06-02T19:50:38.068800Z

i get interesting error while java -cp C:\Users\Тимофей\.m2\repository\org\clojure\clojure\1.10.1\clojure-1.10.1.jar clojure.main . I am just replace encoding with cyrilic username.

borkdude 2020-06-02T19:51:39.069700Z

@timon01 That error is expected, since you should also place spec on the classpath. Use the same classpath as output by clojure -Spath.

timonkot13 2020-06-02T20:05:50.069800Z

Wow, it works! thx! Did that problem happened from the encoding characters?

timonkot13 2020-06-02T20:06:36.070500Z

with them, it cannot execute properly

alexmiller 2020-06-02T20:07:04.071200Z

It looked like there were , in that path name before?

borkdude 2020-06-02T20:07:32.071700Z

the difference seems to be quotes around the classpath here.

alexmiller 2020-06-02T20:07:54.072300Z

Well that implies something needing quoting

alexmiller 2020-06-02T20:08:31.073400Z

All of this is in the clj windows script, upstream of the java or Clojure parts

borkdude 2020-06-02T20:09:07.074200Z

Not sure though, -Spath doesn't print quotes, hmm. But then something like clj -Scp "$(clojure -Spath)" should do the trick.

borkdude 2020-06-02T20:09:28.074500Z

the PS equivalent of that

alexmiller 2020-06-02T20:10:37.076300Z

There is probably something to fix here, I just don’t know enough to fix it :)

borkdude 2020-06-02T20:10:48.076700Z

@timon01 for completeness, can you try deps.exe downloadable from here? https://github.com/borkdude/deps.clj/releases/download/v0.0.8/deps.clj-0.0.8-windows-amd64.zip it doesn't use anything from powershell. then we can eliminate that it's in the PS script.

timonkot13 2020-06-02T20:11:12.077300Z

@alexmiller i replace encoded with username and it works

timonkot13 2020-06-02T20:12:46.077800Z

@borkdude ok

timonkot13 2020-06-02T20:14:04.079100Z

maybe the way to fix it is just install clojure for other user?

timonkot13 2020-06-02T20:14:23.079800Z

with latin characters*

borkdude 2020-06-02T20:14:37.080100Z

it might be good to get this fixed and not just work around it

timonkot13 2020-06-02T20:17:08.080900Z

i tryed to open exe, but it just closing after i click on it

borkdude 2020-06-02T20:21:56.081300Z

you shouldn't click on it. run it from the console

borkdude 2020-06-02T20:22:17.081600Z

it's not a GUI, it's a command line tool

borkdude 2020-06-02T20:22:24.081900Z

just like clj

timonkot13 2020-06-02T20:25:26.082100Z

something like that?

borkdude 2020-06-02T20:30:02.082900Z

Ah, let me provide you a new version which doesn't invoke PowerShell anymore.

borkdude 2020-06-02T20:31:21.083400Z

sorry for the hassle

timonkot13 2020-06-02T20:41:34.083500Z

kind of the same. Did i make something wrong?

littleli 2020-06-02T20:53:24.084900Z

Hi, I see I'm quite late to the installfest.

littleli 2020-06-02T20:55:20.086700Z

If powershell.exe cannot be found I would make sure PATH is correctly set. It may also happen sometimes that there is a syntax error and PATH is not explored properly because of the error. But that is a blind shot from my side.

borkdude 2020-06-02T20:55:52.087700Z

@timon01 Make sure you throw away the old deps.exe and only use the new one. It shouldn't be invoking PowerShell in any way

seancorfield 2020-06-02T20:56:13.088500Z

@ales.najmann Welcome! It's been a fascinating discussion -- something to do with Cyrillic characters and encoding in classpath was at least partly to blame.

littleli 2020-06-02T20:57:11.089500Z

yeah 😞 these things can bite. In my language there are characters like these čěřů etc 🙂 but these are still Latin2

littleli 2020-06-02T20:58:15.090600Z

I'm not sure what's going on 😞

borkdude 2020-06-02T20:58:48.091Z

@timon01 In the stacktrace it shows the download function on line 202. That's from a previous version, not in the version that is from here: https://ci.appveyor.com/project/borkdude/deps-clj/builds/32785614/artifacts (which is built using this commit: https://github.com/borkdude/deps.clj/blob/8c512ce5f36aea08d9379509dad56d2fd2b44e9e/src/borkdude/deps.clj#L202)

borkdude 2020-06-02T21:02:10.091600Z

let me just push version 0.0.9 to end all confusion

timonkot13 2020-06-02T21:03:25.091700Z

@borkdude yea, I noticed that, this is stacktrace from new one

borkdude 2020-06-02T21:03:52.092100Z

Gotcha. Let me fix that.

timonkot13 2020-06-02T21:06:09.092400Z

@ales.najmann PATH looks like that, should I add path to powershell.exe?

borkdude 2020-06-02T21:29:46.093200Z

(meanwhile I'm upgrading deps.clj to a newer GraalVM version...)

borkdude 2020-06-02T21:36:12.093500Z

@timon01 ok, try this new version: https://github.com/borkdude/deps.clj/releases/tag/v0.0.9

borkdude 2020-06-02T21:41:15.093900Z

@timon01 when you type deps.exe -Sdescribe it should print :deps-clj-version "0.0.9" among other things.

borkdude 2020-06-02T21:41:30.094300Z

and the final test is then: deps.exe followed by enter should start a Clojure REPL.

timonkot13 2020-06-02T21:43:26.094600Z

It works

🎉 1
borkdude 2020-06-02T21:44:08.095Z

Cool.

borkdude 2020-06-02T21:44:36.095400Z

So it's probably something in the .ps scripts of clj on windows then.

borkdude 2020-06-02T21:47:32.095800Z

@timon01 So at least you can now use this as a workaround until the .ps script is fixed.

borkdude 2020-06-02T21:47:54.096100Z

Might be good to post an issue about this.

timonkot13 2020-06-02T21:52:33.097Z

@borkdude do you mean .ps script is what cyrilic encoding problem?

borkdude 2020-06-02T21:54:10.098300Z

Yes. the clojure CLI consists of two parts: a shell script + a tools.jar which is invoked via java by the shell script. On Windows the shell script is implemented in Powershell. There's probably a bug or omission in that script which can be fixed by quoting the classpath.

borkdude 2020-06-02T21:54:26.098700Z

deps.clj doesn't use shell scripts, it replaces bash and PowerShell with pure Clojure.

littleli 2020-06-02T21:57:44.100Z

I put deps.clj in scoop too, but I wonder how shim behaves in this particular case... I'm afraid it calls Powershell anyway because of the "environment"

borkdude 2020-06-02T22:00:29.101700Z

@ales.najmann Thanks. That probably works. My mistake in deps.clj was probably that "PowerShell" doesn't always work as the executable name on Windows. But now all usage of PowerShell is gone, so that's not a problem. Scoop probably has more intelligent stuff for this.