Fork me on GitHub
#clj-kondo
<
2019-11-24
>
borkdude12:11:10

If someone is using the Windows executable or just wants to do a tedious but useful task: https://github.com/borkdude/clj-kondo/issues/233

sogaiu16:11:36

i am looking into that issue a bit

sogaiu16:11:55

i'm stuck at getting the clj / clojure part working in my windows vm

sogaiu16:11:23

after installation of clj-on-windows, for an invocation of clojure in clj-kondo's directory i get:

Error: Could not find or load main class clojure.main
Caused by: java.lang.ClassNotFoundException: clojure.main
2019/11/24 08:56:38 open .cpcache/ec67dd60.cp: The system cannot find the path specified.
for reference, the above was pilot error

borkdude16:11:32

can you try if leiningen works?

borkdude16:11:44

just for the sake of debugging

sogaiu17:11:34

lein produces the expected help output, and lein test has initiated fetching of deps

sogaiu17:11:11

i'm now greeted by test output with lots of things to tweak / fix(?)

borkdude17:11:27

progress 🙂

borkdude17:11:45

a lot probably has to do with hardcoded file path separators

borkdude17:11:08

so "foo/bar" instead of (.getPath`(io/file "foo" "bar"))`

sogaiu17:11:46

sure for reference, the output at the bottom is:

Ran 120 tests containing 1105 assertions.
44 failures, 2 errors.
Tests failed.

borkdude17:11:10

File paths are used a lot so that might be expected

sogaiu17:11:43

i guess one could take the windows output and make the changes in a non-windows env first

borkdude17:11:06

sure yes, if you can paste that somewhere?

borkdude17:11:15

or maybe attach it at the issue as a .zip file

sogaiu17:11:58

i just did .txt -- is there a reason to use .zip?

borkdude17:11:34

no, .txt is fine 🙂

borkdude17:11:31

actual: .IOException: Cannot run program "rm": CreateProcess error=2, The system cannot find the file specified

borkdude17:11:38

yep, that's also a difference 🙂

borkdude17:11:18

actual: (not (clj-kondo.test-utils/submap? {:file "corpus/defmulti.clj", :row 7, :col 12, :level :error, :message "unresolved symbol greetingx"} {:file "corpus\\defmulti.clj", :row 7, :col 12, :level :error, :message "unresolved symbol greetingx"}))

borkdude17:11:39

corpus/defmulti vs corpus\\defmulti yes, that happens a lot

borkdude17:11:09

I could probably patch assert-submaps to handle that magically for :filename or something, that would already be a quickwin

borkdude17:11:35

@sogaiu could you try again with clj-kondo from master?

borkdude17:11:48

I expect a few less failures now

sogaiu17:11:07

is this the right commit? 594a0236c81815ad27837507145fbd9215000e9b

sogaiu17:11:17

new results added to issue

sogaiu17:11:16

didn't clean first -- trying again

littleli18:11:16

my summary is slightly different:

Ran 120 tests containing 1105 assertions.
41 failures, 2 errors.

sogaiu18:11:31

hmm... what shell did you use, btw?

littleli18:11:38

PS C:\Users\alesn> $PSVersionTable.PSVersion                                                                                                                                                                                     
Major  Minor  Build  Revision
-----  -----  -----  --------
5      1      18362  145

sogaiu18:11:25

> $PSVersionTable.PSVersion

Major  Minor  Build  Revision
-----  -----  -----  --------
5      1      17763  771

littleli18:11:55

I'll attach output as txt to the issue for comparison

👍 4
sogaiu18:11:09

fwiw, when i do lein test from git bash i get:

Ran 120 tests containing 1113 assertions.
44 failures, 2 errors.
Tests failed.

sogaiu18:11:18

number of assertion differs there

sogaiu18:11:39

may be it has access to some things that command prompt and powershell don't

borkdude18:11:39

made a typo, I should have written :file instead of :filename

borkdude18:11:43

I will correct, brb

sogaiu18:11:10

@ales.najmann btw, thanks for the clojure scoop bucket 🙂

littleli18:11:26

You're welcome 🙂 it's actually not such a big deal. Most of the work has been already done before. I just focused a bit more to deliver the experience.

👍 4
littleli19:11:56

I'm not sure it it is helpful, but there is probably better way to deal with filepaths with java.nio.file.Paths.get("foo/bar.txt") and java.nio.file.Path.normalize() but just swap impl. of normalize-filename is obviously not enough.

borkdude19:11:48

I made a windows-tests branch. Feel free to re-test there and make PRs, even small ones

borkdude19:11:12

One useful one would be to port the script/test script to .bat and hook it up on Appveyor

borkdude19:11:02

@ales.najmann normalize-filename just coerces all backward slashes to forward slashes, it's a bit of a hack, but I think it suffices.

sogaiu19:11:39

command prompt results with windows-test branch:

Ran 120 tests containing 1166 assertions.
9 failures, 3 errors.
Tests failed.

littleli19:11:42

that's interesting:

Ran 120 tests containing 1166 assertions.
6 failures, 3 errors.
https://gist.github.com/littleli/a7c77530d3b0a9b5544a65bb2a21da29

littleli19:11:54

why we have different results? 🙂

borkdude19:11:22

@ales.najmann I suspect you have the rm and mv commands on the path?

borkdude19:11:28

or maybe defined aliases for them?

littleli19:11:31

hmm, I have Move-Item and Remove-Item aliases in Powershell, I guess

littleli19:11:57

PS C:\Users\alesn\Projects\clj-kondo> rm

cmdlet Remove-Item at command pipeline position 1
Supply values for the following parameters:
Path[0]:
PS C:\Users\alesn\Projects\clj-kondo> mv

cmdlet Move-Item at command pipeline position 1
Supply values for the following parameters:
Path[0]:

borkdude19:11:08

that's why they work in your case then 🙂

littleli19:11:05

ok, but I still se some exceptions regarding these in the output

littleli19:11:31

ERROR in (import-vars-test) (ProcessBuilder.java:1128)
Uncaught exception, not in assertion.
expected: nil
  actual: .IOException: Cannot run program "mv": ...

sogaiu19:11:38

fwiw, i added my latest results to the issue

borkdude19:11:00

trying to hook the tests up here now. installing littleli's clojure scoop:

sogaiu19:11:24

rough summary:

ERRORS

run!-test
cache-test
import-vars-test

FAIL

extract-cljs-core-vars-test x3
nested-namespaced-maps-test
redundant-let-test
read-error-test
exclude-clojure-test
inline-def-tes
invalid-arity-test

littleli19:11:48

In my case:

312:FAIL in (nested-namespaced-maps-test) (main_test.clj:256)
318:FAIL in (redundant-let-test) (main_test.clj:34)
324:FAIL in (read-error-test) (main_test.clj:238)
331:FAIL in (exclude-clojure-test) (main_test.clj:210)
337:FAIL in (inline-def-test) (main_test.clj:19)
522:FAIL in (invalid-arity-test) (main_test.clj:117)
12:ERROR in (run!-test) (Pattern.java:2027)
115:ERROR in (cache-test) (ProcessBuilder.java:1128)
343:ERROR in (import-vars-test) (ProcessBuilder.java:1128)

littleli19:11:22

@sogaiu that is 6 failures, isn't it?

sogaiu19:11:30

i think so

sogaiu19:11:59

and yet, i see what i see in my output 🙂

🙈 4
sogaiu19:11:17

i see a few cljs things i missed

borkdude19:11:51

It might now be better to run the script/test.bat file

borkdude19:11:56

it will download some necessary deps

borkdude19:11:01

that will be used to extract info from

sogaiu19:11:48

@ales.najmann i missed some -- now i think my list is complete

borkdude19:11:50

(pushed a fix for the bat)

sogaiu19:11:12

i have 3 extract-cljs-core-vars-test which littleli didn't get it seems

borkdude19:11:21

let's hope appveyor will work now

sogaiu19:11:05

i hope we don't have to use windows 7.1 sdk at some point

sogaiu19:11:05

not having much luck with test.bat

sogaiu19:11:25

'clojure' is not recognized as an internal or external command,
operable program or batch file.
'clojure' is not recognized as an internal or external command,
operable program or batch file.
'clojure' is not recognized as an internal or external command,
operable program or batch file.
'else' is not recognized as an internal or external command,
operable program or batch file.
"Testing with Clojure 1.9.0"
'clojure' is not recognized as an internal or external command,
operable program or batch file.
Terminate batch job (Y/N)? y

sogaiu19:11:35

right after that invoking clojure manually works

borkdude19:11:18

Adding ~\scoop\shims to your path.
'lastupdate' has been set to '2019-11-24T19:42:43.8238427+00:00'
Scoop was installed successfully!
Type 'scoop help' for instructions.
powershell -Command "scoop install clojure"
scoop : The term 'scoop' is not recognized as the name of a cmdlet, function, 
script file, or operable program. Check the spelling of the name, or if a path 
was included, verify that the path is correct and try again.
At line:1 char:1
+ scoop install clojure
+ ~~~~~
    + CategoryInfo          : ObjectNotFound: (scoop:String) [], CommandNotFou 
   ndException
    + FullyQualifiedErrorId : CommandNotFoundException
 
Command exited with code 1

littleli19:11:02

adding bucket is missing? 🙂

borkdude19:11:18

> scoop : The term 'scoop' is not recognized

borkdude19:11:43

I'll try this as the first step so I don't have to wait for the compilation to finish

borkdude19:11:40

Adding ~\scoop\shims to your path.
'lastupdate' has been set to '2019-11-24T19:45:23.8762273+00:00'
Scoop was installed successfully!
Type 'scoop help' for instructions.
scoop install clojure"
'scoop' is not recognized as an internal or external command,
operable program or batch file.
Command exited with code 1

borkdude19:11:51

Maybe it needs a fresh shell

sogaiu19:11:24

fun with quoting issues:

> clojure -Sdeps '{:deps {org.clojure/clojure {:mvn/version "1.9.0"}}}' -Spath
Error while parsing option "--config-data {:deps {org.clojure/clojure {:mvn/version 1.9.0}}}": java.lang.NumberFormatException: Invalid number: 1.9.0

borkdude19:11:12

fresh shell didn't work

sogaiu19:11:08

two sets of double quotes seems to work as per the tools.deps wiki advice, fwiw

🙈 4
sogaiu19:11:36

> clojure -Sdeps '{:deps {org.clojure/clojure {:mvn/version ""1.9.0""}}}' -Spath
src;parser;resources;inlined;C:\Users\user\.m2\repository\com\cognitect\transit-java\0.8.337\transit-java-0.8.337.jar;C:\Users\user\.m2\repository\org\clojure\clojure\1.9.0\clojure-1.9.0.jar;C:\Users\user\.m2\repository\commons-codec\commons-codec\1.10\commons-codec-1.10.jar;C:\Users\user\.m2\repository\io\lambdaforge\datalog-parser\0.1.1\datalog-parser-0.1.1.jar;C:\Users\user\.m2\repository\org\clojure\core.specs.alpha\0.1.24\core.specs.alpha-0.1.24.jar;C:\Users\user\.m2\repository\org\clojure\spec.alpha\0.1.143\spec.alpha-0.1.143.jar;C:\Users\user\.m2\repository\com\fasterxml\jackson\dataformat\jackson-dataformat-cbor\2.9.6\jackson-dataformat-cbor-2.9.6.jar;C:\Users\user\.m2\repository\com\googlecode\json-simple\json-simple\1.1.1\json-simple-1.1.1.jar;C:\Users\user\.m2\repository\com\fasterxml\jackson\core\jackson-core\2.9.6\jackson-core-2.9.6.jar;C:\Users\user\.m2\repository\org\javassist\javassist\3.18.1-GA\javassist-3.18.1-GA.jar;C:\Users\user\.m2\repository\org\msgpack\msgpack\0.6.12\msgpack-0.6.12.jar;C:\Users\user\.m2\repository\com\cognitect\transit-clj\0.8.313\transit-clj-0.8.313.jar;C:\Users\user\.m2\repository\cheshire\cheshire\5.8.1\cheshire-5.8.1.jar;C:\Users\user\.m2\repository\tigris\tigris\0.1.1\tigris-0.1.1.jar;C:\Users\user\.m2\repository\com\fasterxml\jackson\dataformat\jackson-dataformat-smile\2.9.6\jackson-dataformat-smile-2.9.6.jar;C:\Users\user\.m2\repository\javax\xml\bind\jaxb-api\2.3.0\jaxb-api-2.3.0.jar

sogaiu19:11:03

being pulled away by niece, sorry 🙂

borkdude19:11:36

ah now scoop works

borkdude19:11:44

added the double quotes

borkdude19:11:50

Installing PowerShell module 'ClojureTools'
Linking ~\scoop\modules\ClojureTools => ~\scoop\apps\clojure\current
'clojure' (1.10.1.489) was installed successfully!
'clojure' suggests installing 'java/adopt8-hotspot' or 'java/adoptopenjdk-lts-hotspot' or 'java/oraclejdk' or 'java/openjdk'.
clojure
'clojure' is not recognized as an internal or external command

littleli19:11:52

almost, I see the same issue as on my machine

littleli19:11:17

I cannot for example run script/test.bat for the same error

borkdude20:11:00

running clojure from powershell does seem to work, but not from the cmd.exe, using your scoop @ales.najmann?

borkdude20:11:14

using powershell I now get:

clojure
The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: Downloading: org/clojure/clojure/1.10.1/clojure-1.10.1.pom from 

borkdude20:11:07

(on Appveyor)

littleli20:11:31

I bet that for that reasons there were those shims in the some of the previous versions

borkdude20:11:30

so what's the next action that should be taken?

borkdude20:11:50

should I add those "-NoProfile -ExecutionPolicy Bypass -Command Invoke-Clojure" to the powershell command?

littleli20:11:29

I think more important is it actually runs powershell.exe as a shell

borkdude20:11:53

yes:

- ps: clojure

borkdude20:11:01

@ales.najmann :

init:
- ps: iex (new-object net.webclient).downloadstring('')
- ps: scoop bucket add java
- ps: scoop bucket add scoop-clojure 
- ps: scoop install java/adopt8-hotspot
- ps: scoop install clojure
- ps: clojure
it fails in the last step

borkdude20:11:51

I can try Set-ExecutionPolicy RemoteSigned -scope CurrentUser

borkdude20:11:47

hm: Set-ExecutionPolicy : The method or operation is not implemented. At line:1 char:1 + Set-ExecutionPolicy RemoteSigned -scope CurrentUser

littleli20:11:01

can you execute: scoop which clojure ?

littleli20:11:20

it is a scoop alternative to unix which

borkdude20:11:13

no output:

Linking ~\scoop\modules\ClojureTools => ~\scoop\apps\clojure\current
'clojure' (1.10.1.489) was installed successfully!
scoop which clojure
git clone -q --branch=windows-tests  C:\projects\clj-kondo
git checkout -qf 957d1efacc3b9f4dfc8015de2ec6b828dd25e4b5
cmd /C "set CLJ_KONDO_TEST_ENV=jvm && call script/test.bat"
'clojure' is not recognized as an internal or external command,
operable program or batch file.
'clojure' is not recognized as an internal or external command,
operable program or batch file.

borkdude20:11:23

I'll deprecate clojure in the script until we find this out

littleli20:11:31

afaik, it is correct, because clojure really is a powershell alias, actually defined directly in distribution from official source. There is psmodule definition. You can find it here on this path: \scoop\apps\clojure\current

littleli20:11:55

well, i think what could help is to add some shim that does not interfere with tools like calva

littleli20:11:43

I don't know... clj-cmd, it will be eventually able to run as a command. because scoop creates shim binary for the command, and you can use clj-cmd.exe as a launching command. but that is theoretical.

borkdude20:11:16

calva? this is on CI

littleli20:11:18

or you could try to use powershell instead of cmd.exe

littleli20:11:44

yes, but I removed shim creation because there was weird issue with calva

borkdude20:11:31

scoop which was already ran using powershell, not cmd.exe

littleli20:11:12

again, clojure is not a command, it is powershell alias... so cmd.exe sees nothing, right? 🙂

littleli20:11:07

PS C:\Users\alesn> cmd                                                                                                                                                                                                           Microsoft Windows [Version 10.0.18362.476]
(c) 2019 Microsoft Corporation. Všechna práva vyhrazena.

C:\Users\alesn>clojure
'clojure' is not recognized as an internal or external command,
operable program or batch file.

borkdude20:11:22

yes, I wasn't using cmd.exe

borkdude20:11:37

- ps: scoop which clojure

borkdude20:11:41

ps means powershell

borkdude20:11:07

the lein tests appear to be running now though: https://ci.appveyor.com/project/borkdude/clj-kondo

littleli20:11:55

PS C:\Users\alesn> scoop which clojure                                                                                                                                                                                           Not a scoop shim.

littleli20:11:24

which is correct, there should be no shims. unfortunately this is not visible in the above output 😕

borkdude20:11:42

maybe a hardcoded c:\projects\foo\clojure works,

littleli20:11:59

it's quite confusing, right? 🙂

borkdude20:11:51

only 10 failures and 2 errors on appveyor, progress. clojure is needed to download a few deps

borkdude20:11:13

I'm done for today, PRs still welcome to the windows-tests branch 🙂

littleli20:11:28

btw lein is in scoop too, in the main bucket.

sogaiu21:11:16

in test.bat, was putting powershell -command in front of the clojure invocations somehow problematic? i see test output here via powershell as well as cmd.

borkdude21:11:37

no, but scoop which clojure did not work, neither did ps: clojure

borkdude21:11:57

I now eliminated the need for clojure in the .bat script

sogaiu21:11:10

ah, less is more

littleli21:11:10

Probably the alias is not activated right after installation but is required to be activated similarly to how update to profile shell files is required to be run on unices (with source command)