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 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 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 $'...'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
I get the same error through flymake in emacs 🤔
is it reproducible in the terminal with double quotes or other way to escape '?
i think you could just cat <that-file> | clj-kondo --lint - and see if it agrees?
> 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 shellshave you retyped it? any chance you’ve got some weird characters involved?
also recently switched to ghostty, works in iterm2 facepalm
are you using a fancy font in ghosty that is replacing some characters with ligatures or something?
but cat'ing the file still gives the error
no, stock config
and you said the same thing works in iterm2?
and exactly the same thing? Cat’ing the same file?
aha, it only fails inside my project directory!
so there most be something somewhere there 👍
very interested to know what that could be.
Have to pick up the kids now, but I'll let you know when I figure it out
weird. to be sure it isn't a shell thing, please just lint a file
like this?
> clj-kondo --lint blah.clj
blah.clj:2:2: warning: Unresolved var: io/resource
linting took 9ms, errors: 0, warnings: 1it 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 inafter that you could try to delete it and probably that fixes (works around) the problem
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?dunno?
looks like
deleted that file and now the error is gone
could you look into what anteo/main.clj contains?
deleting is only a temporary workaround, as soon as clj-kondo lints that file again, it'll probably be the same again
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?
shared it with you in a DM
looks fine. don't know how this got into this state. thanks for sharing. are you using clojure-lsp?
no
and/or are you using the --parallel option?
in clj-kondo?
yes
and/or are you using some kind of editor integration to see clj-kondo's feedback in your editor?
yes, flycheck-clj-kondo. don't think I change anything from the defaults
sounds good. I really don't know but let me know next time it happens again
will do, thanks for the help! 🙏