clj-kondo

hanDerPeder 2025-01-08T14:04:32.648149Z

Is this a bug? or am I doing something wrong here?

> clj-kondo --version
clj-kondo v2024.11.14
> echo '(require \'[ :as io]) (defn a [] (io/resource "foo"))' | clj-kondo --lint -
<stdin>:1:49: warning: Unresolved var: io/resource
linting took 12ms, errors: 0, warnings: 1

dpsutton 2025-01-08T14:13:18.044439Z

i had issues with parsing

❯ echo '(require \'[ :as io]) (defn a [] (io/resource "foo"))' | clj-kondo --lint -
zsh: parse error near `)'
when i switched to " quotes it worked for me.
❯ echo "(require '[ :as io]) (defn a [] (io/resource \"foo\"))" | clj-kondo --lint -
linting took 22ms, errors: 0, warnings: 0

Kirill Chernyshov 2025-01-08T14:13:55.754979Z

something is wrong with escaping

❯ echo $'(require \'[clojure.java.io :as io]) (defn a [] (io/resource "foo"))' | clj-kondo --lint -
linting took 44ms, errors: 0, warnings: 0
you can try ansii-C quoting literal $'...'

Kirill Chernyshov 2025-01-08T14:16:16.129649Z

or more convoluted

'\''
to put a single '
❯ echo '(require '\''[ :as io]) (defn a [] (io/resource "foo"))' | clj-kondo --lint -
linting took 48ms, errors: 0, warnings: 0

hanDerPeder 2025-01-08T14:18:19.668659Z

I get the same error through flymake in emacs 🤔

Kirill Chernyshov 2025-01-08T14:28:29.313819Z

is it reproducible in the terminal with double quotes or other way to escape '?

dpsutton 2025-01-08T14:30:27.436779Z

i think you could just cat <that-file> | clj-kondo --lint - and see if it agrees?

hanDerPeder 2025-01-08T14:36:30.030819Z

> cat blah.clj
(require '[ :as io])
(io/resource "foo")
> cat blah.clj | clj-kondo --lint -
<stdin>:2:2: warning: Unresolved var: io/resource
linting took 9ms, errors: 0, warnings: 1
> echo '(require '\''[ :as io]) (defn a [] (io/resource "foo"))' | clj-kondo --lint -
<stdin>:1:49: warning: Unresolved var: io/resource
linting took 11ms, errors: 0, warnings: 1
seems to happen with both of these suggestions. recently switched to fish, so though that might have something to do with it. But same in other shells

dpsutton 2025-01-08T14:38:24.649399Z

have you retyped it? any chance you’ve got some weird characters involved?

hanDerPeder 2025-01-08T14:38:25.522239Z

also recently switched to ghostty, works in iterm2 facepalm

dpsutton 2025-01-08T14:39:25.077849Z

are you using a fancy font in ghosty that is replacing some characters with ligatures or something?

hanDerPeder 2025-01-08T14:39:29.627169Z

but cat'ing the file still gives the error

hanDerPeder 2025-01-08T14:39:39.962539Z

no, stock config

dpsutton 2025-01-08T14:39:57.868149Z

and you said the same thing works in iterm2?

dpsutton 2025-01-08T14:40:07.674539Z

and exactly the same thing? Cat’ing the same file?

hanDerPeder 2025-01-08T14:43:47.816929Z

aha, it only fails inside my project directory!

hanDerPeder 2025-01-08T14:44:04.450329Z

so there most be something somewhere there 👍

dpsutton 2025-01-08T14:44:18.527579Z

very interested to know what that could be.

hanDerPeder 2025-01-08T14:44:55.737809Z

Have to pick up the kids now, but I'll let you know when I figure it out

borkdude 2025-01-08T14:46:05.273369Z

weird. to be sure it isn't a shell thing, please just lint a file

hanDerPeder 2025-01-08T14:47:42.867329Z

like this?

> clj-kondo --lint blah.clj
blah.clj:2:2: warning: Unresolved var: io/resource
linting took 9ms, errors: 0, warnings: 1

borkdude 2025-01-08T14:47:53.220209Z

it could be that clj-kondo analyzed a namespace called http://clojure.java.io without the resource var somehow. to check this, check inside of your config directory:

.clj-kondo/.cache/v1/clj/clojure.java.io.transit.json
and please send it here as an attachment, so I can see what's in

borkdude 2025-01-08T14:48:07.508269Z

after that you could try to delete it and probably that fixes (works around) the problem

hanDerPeder 2025-01-08T14:50:03.722869Z

aha

~/projects/anteo/planner/.clj-kondo/.cache/v1/clj $ cat clojure.java.io.transit.json 
["^ ","~$file",["^ ","~:row",28,"~:col",1,"~:fixed-arities",["~#set",[1]],"~:name","^0","~:ns","~$","~:top-ns","~$anteo.main","~:type","~:fn"],"~:filename","/Users/peder/projects/anteo/planner/src/anteo/main.clj"]~/projects/anteo
so this guy is shadowing the actual definition?

borkdude 2025-01-08T14:50:34.856649Z

dunno?

borkdude 2025-01-08T14:50:37.844609Z

looks like

hanDerPeder 2025-01-08T14:50:49.876559Z

deleted that file and now the error is gone

borkdude 2025-01-08T14:51:01.965149Z

could you look into what anteo/main.clj contains?

borkdude 2025-01-08T14:51:31.053689Z

deleting is only a temporary workaround, as soon as clj-kondo lints that file again, it'll probably be the same again

hanDerPeder 2025-01-08T14:52:40.453939Z

anteo/main.clj is a main file with typical main stuff. it requires http://clojure.java.io, anything in particular I should be looking for?

hanDerPeder 2025-01-08T14:54:09.424229Z

shared it with you in a DM

borkdude 2025-01-08T14:54:21.849279Z

looks fine. don't know how this got into this state. thanks for sharing. are you using clojure-lsp?

hanDerPeder 2025-01-08T14:54:46.429369Z

no

borkdude 2025-01-08T14:54:49.205989Z

and/or are you using the --parallel option?

hanDerPeder 2025-01-08T14:55:26.151079Z

in clj-kondo?

borkdude 2025-01-08T14:55:29.327259Z

yes

borkdude 2025-01-08T14:55:53.253319Z

and/or are you using some kind of editor integration to see clj-kondo's feedback in your editor?

hanDerPeder 2025-01-08T14:56:36.807989Z

yes, flycheck-clj-kondo. don't think I change anything from the defaults

borkdude 2025-01-08T14:56:55.338999Z

sounds good. I really don't know but let me know next time it happens again

hanDerPeder 2025-01-08T14:57:21.574249Z

will do, thanks for the help! 🙏