cjohansen / portfolio

Eclipse Public License 1.0
236 stars 14 forks source link

clj-kondo gives warning about invalid portfolio config #22

Closed svdo closed 6 months ago

svdo commented 7 months ago

Thanks for Portfolio Christian, it's a great project!

When using clj-kondo and portfolio in my project, clj-kondo ends up creating the file .clj-kondo/no.cjohansen/portfolio/config.edn, as expected. However, that file is empty, which causes clj-kondo to issue a warning when running the linters:

WARNING: error while reading /Users/stefanmm/Documents/Projects/emma-mono/.clj-kondo/no.cjohansen/portfolio/config.edn (EOF while reading)

I don't know if the file is intentionally empty (in which case {} as contents of the file solves the issue), or if there should be something else in there. It would be awesome if this can be fixed. Thanks!!

borkdude commented 7 months ago

I can't repro this with:

$ mkdir -p .clj-kondo
$ clj-kondo --lint "$(clojure -Spath -Sdeps '{:deps {no.cjohansen/portfolio {:mvn/version \"2023.12.07\"}}}')" --copy-configs --dependencies
No configs copied.

Which deps.edn are you using?

svdo commented 7 months ago

Hmm not sure what is going on. The file is actually created when I launch vscode in my repo. In other words: vscode is not running, and in the terminal I type code . to launch it. That's enough to trigger the file being created. So I guess it's either Calva or clojure-lsp doing it?

borkdude commented 7 months ago

Yes, but it depends on what deps you are using. So,

Which deps.edn are you using?

svdo commented 7 months ago

This is a stripped-down version of our top-level deps.edn file (we're using Polylith, so lots of deps.edn files 😄). Is this what you're looking for?

{:mvn/repos {,,,}

 :aliases  {:dev {:extra-paths ["classes" ;; not used currently
                                "development/src"
                                "development/resources"

                                ;; components
                                "components/config/src"
                                ...

                                ;; bases
                                "bases/.../src"
                                ...]
                  :extra-deps {,,, ;; external libraries
                               }

                  :jvm-opts ["-XX:-OmitStackTraceInFastThrow"
                             "-Dguardrails.enabled=true"]}

            :+default {:extra-paths ["components/pathom-dev/src"
                                     "components/dev-config-core/src"]
                       :extra-deps {,,,}}
            :+development {:extra-paths ["components/pathom-dev/src"
                                         "components/dev-config-core/src"]
                           :extra-deps {com.wsscode/pathom-viz-connector {:mvn/version "2022.02.14"}
                                        com.github.jpmonettas/flow-storm-dbg {:mvn/version "3.7.5"}}}
            :profile {:extra-deps {com.clojure-goes-fast/clj-async-profiler {:mvn/version "1.2.0"}}
                      :jvm-opts ["-Djdk.attach.allowAttachSelf"
                                 "-XX:+UnlockDiagnosticVMOptions"
                                 "-XX:+DebugNonSafepoints"]}

            :client {:extra-paths ["client/src" "client/resources" "client/test"
                                   "client/portfolio/src" "components/locale/src" "components/locale/test"]
                             :extra-deps {binaryage/devtools         {:mvn/version "1.0.7"}
                                          no.cjohansen/portfolio     {:mvn/version "2023.12.07"}
                                          com.fulcrologic/guardrails {:mvn/version "1.2.3"}
                                          com.taoensso/tempura       {:mvn/version "1.5.3"}
                                          thheller/shadow-cljs       {:mvn/version "2.27.5"} ;; NOTE: same version must also be updated in `package.json`
                                          cjohansen/gadget-inspector {:mvn/version "0.2023.04.12"}
                                          ,,,}}

            :test {:extra-paths [...]
                   :extra-deps {org.clojure/test.check     {:mvn/version "1.1.1"}
                                lambdaisland/deep-diff2    {:mvn/version "2.11.216"}
                                nubank/matcher-combinators {:mvn/version "3.9.1"}

                                polylith-kaocha/kaocha-wrapper
                                {:git/url "https://github.com/imrekoszo/polylith-kaocha"
                                 :git/tag "v0.8.4"
                                 :git/sha "f096de8f6bdb6dcd27f27789f754d57a2f1a3a45"
                                 :deps/root "projects/kaocha-wrapper"}}}

            :poly {:main-opts ["-m" "polylith.clj.core.poly-cli.core"]
                   :extra-deps {polylith/clj-poly
                                {#_#_:mvn/version "0.2.17-alpha"
                                 :git/url "https://github.com/polyfy/polylith.git"
                                 :git/sha "408ef27ecad00d3443120f2340fd0d95fa642535"
                                 :deps/root "projects/poly"}
                                polylith-kaocha/test-runner
                                {:git/url "https://github.com/imrekoszo/polylith-kaocha"
                                 :git/tag "v0.8.4"
                                 :git/sha "f096de8f6bdb6dcd27f27789f754d57a2f1a3a45"
                                 :deps/root "projects/test-runner"}}}

            :cloverage ;; use with :dev and :test, i.e. clj -X:dev:test:cloverage
            {:extra-paths ["development/test"]
             :extra-deps  {cloverage/cloverage                  {:mvn/version "1.2.4"}
                           lambdaisland/deep-diff2              {:mvn/version "2.11.216"}
                           mvxcvi/puget                         {:mvn/version "1.3.4"}

                           ;; Projects
                           ,,,}
             :exec-fn     test-support.interface.cloverage/run-cloverage
             :exec-args   {:src-ns-path [...]
                           :test-ns-path [...]}}}}

There is also shadow-cljs.edn:

{:deps {:aliases [:client]}
 ,,,}
svdo commented 7 months ago

After removing most of the aliases from deps.edn, removing .lsp/config.edn and .clj-kondo/config.edn, and reducing the :client alias to this, it still happens:

            :client { :extra-deps { no.cjohansen/portfolio     {:mvn/version "2023.12.07"}}}

When I then also remove the portfolio dependency, the file is not created anymore.

borkdude commented 7 months ago

Does it happen with an empty deps edn with only that dependency on the top level? This is what I did above and could not reproduce it that way

borkdude commented 7 months ago

Btw, I'm getting this when I try to use that dep now:

$ clojure -Spath -Sdeps '{:deps {no.cjohansen/portfolio {:mvn/version "2023.12.07"}}}'
Error building classpath. Could not transfer artifact no.cjohansen:phosphor-clj:jar:2023.07.07 from/to clojars (https://repo.clojars.org/): status code: 416, reason phrase: Range Not Satisfiable (416)
svdo commented 7 months ago

This is the most minimal reproduction that I could come up with: https://github.com/svdo/repro. Clone, run clojure-lsp diagnostics, and the empty file gets created on my machine.

Relevant versions:

$ clojure-lsp --version
clojure-lsp 2024.03.01-11.43.56-nightly
clj-kondo 2024.02.13-SNAPSHOT
borkdude commented 7 months ago

Thanks, that's helpful

borkdude commented 7 months ago

I'm still getting:

$ clojure -Spath -A:client
Error building classpath. Could not transfer artifact no.cjohansen:phosphor-clj:jar:2023.07.07 from/to clojars (https://repo.clojars.org/): status code: 416, reason phrase: Range Not Satisfiable (416)
svdo commented 6 months ago

I just did rm -rf ~/.m2/repository/no which removes downloaded phosphor-clj and portfolio. Then I do clojure -Spath -A:client and for me it seems to work:

Downloading: no/cjohansen/portfolio/2023.12.07/portfolio-2023.12.07.pom from clojars
Downloading: no/cjohansen/phosphor-clj/2023.07.07/phosphor-clj-2023.07.07.pom from clojars
Downloading: no/cjohansen/phosphor-clj/2023.07.07/phosphor-clj-2023.07.07.jar from clojars
Downloading: no/cjohansen/portfolio/2023.12.07/portfolio-2023.12.07.jar from clojars
src:[...]

Could it be that one of the servers is misbehaving? IIRC I sometimes see that error pop up in CI for various dependencies, and retrying it tends to solve it.

borkdude commented 6 months ago

Yes, it seems to work after I do that too.

borkdude@m1 /tmp/repro (main) $ clj-kondo --lint $classpath --dependencies --copy-configs
Configs copied:
- .clj-kondo/no.cjohansen/portfolio
borkdude@m1 /tmp/repro (main?) $ ls .clj-kondo/no.cjohansen/portfolio
config.edn
borkdude@m1 /tmp/repro (main?) $ cat .clj-kondo/no.cjohansen/portfolio/config.edn
borkdude@m1 /tmp/repro (main?) $

The logical explanation for this would be that there is an empty config.edn in the clj-kondo.exports section and this is true:

$ zipinfo /Users/borkdude/.m2/repository/no/cjohansen/portfolio/2023.12.07/portfolio-2023.12.07.jar

-rw----     2.0 fat        0 bl defN 23-Dec-07 09:55 clj-kondo.exports/no.cjohansen/portfolio/
-rw----     2.0 fat        0 bl defN 23-Dec-07 09:55 clj-kondo.exports/no.cjohansen/
-rw----     2.0 fat        0 bl defN 23-Dec-07 09:55 clj-kondo.exports/
-rw----     2.0 fat        0 bl defN 23-Oct-13 20:53 clj-kondo.exports/no.cjohansen/portfolio/config.edn

The solution would be to not do this. cc @cjohansen

cjohansen commented 6 months ago

Wow, that is certainly not there intentionally. It's not in the repo. I'll cut a new release without it, thanks for the digging!

borkdude commented 6 months ago

Thank you!

cjohansen commented 6 months ago

Fixed by a proper clj-kondo config in 2024.03.15 🥳