在<华语:《2024 Clojure状态调查!》(https://www.surveymonkey.com/r/clojure2024)中分享您的想法。

欢迎!请访问“<华语:关于”页面以获取更多有关本网站如何运作的信息。

0
工具

你好,

我试图下载所有依赖项,这样CI上的测试和其他步骤就不需要下载了。

我使用以下命令下载所有依赖项
clojure -Sdeps '{:mvn/local-repo ".m2"}' -A:dev:test:prod:frontend -Spath > /dev/null
我可以确认`.m2`和`.cpcache`目录都存在。

但是当我运行
clojure -Sdeps '{:mvn/local-repo ".m2"}' -M:dev:test
所有依赖项都被再次下载。

这种情况在本地和CI上都能复现。

描述
{:version "1.10.3.967" :config-files ["/usr/local/Cellar/clojure/1.10.3.967/deps.edn" "/Users/kirill/.clojure/deps.edn" "deps.edn" ] :config-user "/Users/kirill/.clojure/deps.edn" :config-project "deps.edn" :install-dir "/usr/local/Cellar/clojure/1.10.3.967" :config-dir "/Users/kirill/.clojure" :cache-dir ".cpcache" :force false :repro false :main-aliases "" :repl-aliases ""}

2个答案

+1

选择
 
最佳答案

请共享一个可以复现此问题的deps.edn。

```
  {:deps {;; 平台和系统逻辑
        aero/aero                           {:mvn/version "1.1.6"}
        buddy/buddy-sign                    {:mvn/version "3.2.0"}
        ch.qos.logback/logback-classic      {:mvn/version "1.2.3"}
        clj-htmltopdf/clj-htmltopdf                    {:mvn/version "0.1-alpha7"}
        clojure.java-time/clojure.java-time {:mvn/version "0.3.2"}
        com.novemberain/pantomime              {:mvn/version "2.11.0"}
        cryptohash-clj/cryptohash-clj       {:mvn/version "0.1.6"}
        expound/expound                     {:mvn/version "0.8.7"}
        haversine/haversine                 {:mvn/version "0.1.1"}
        integrant/repl                     {:mvn/version "0.3.2"}
        integrant/integrant                 {:mvn/version "0.8.0"}
        metosin/spec-tools                 {:mvn/version "0.10.4"}
        org.apache.pdfbox/pdfbox            {:mvn/version "2.0.22"}
        org.apache.pdfbox/pdfbox-tools      {:mvn/version "2.0.22"}
        org.bouncycastle/bcprov-jdk15on     {:mvn/version "1.67"}
        org.clojure/clojure              {:mvn/version "1.10.1"}
        org.clojure/core.async              {:mvn/version "1.3.610"}
        org.clojure/core.cache              {:mvn/version "1.0.207"}
        org.clojure/data.csv                {:mvn/version "1.0.0"}
        org.clojure/tools.cli               {:mvn/version "1.0.194"}

        ;; 数据库和SQL
        hikari-cp/hikari-cp       {:mvn/version "2.13.0"}
        honeysql/honeysql         {:mvn/version "1.0.444"}
        lambdaisland/uri          {:mvn/version "1.4.54"}
        migratus/migratus         {:mvn/version "1.3.3"}
        nilenso/honeysql-postgres {:mvn/version "0.4.112"}
        org.clojure/java.jdbc     {:mvn/version "0.7.11"}
        org.postgresql/postgresql {:mvn/version "42.2.18"}

        ;; HTTP和网页
        buddy/buddy-auth      {:mvn/version "2.2.0"}
        clj-http/clj-http     {:mvn/version "3.10.3"}
        hiccup/hiccup         {:mvn/version "1.0.5"}
        metosin/reitit        {:mvn/version "0.5.10"}
        org.clojure/data.json {:mvn/version "1.0.0"}
        ring/ring-defaults    {:mvn/version "0.3.2"}
        ring/ring-json         {:mvn/version "0.5.0"}
        ring/ring             {:mvn/version "1.8.2"}

        与第三方集成
        circleci/rollcage        {:mvn/version "1.0.208"}
        clj-commons/iapetos     {:mvn/version "0.1.11"}
        io.prometheus/simpleclient_hotspot {:mvn/version "0.11.0"}
        clj-commons/clj-ssh     {:mvn/version "0.5.15"}
        com.sun.mail/javax.mail {:mvn/version "1.6.2"}
        ovotech/clj-gcp         {:mvn/version "0.6.11"}}

 :paths ["src/clj" "src/cljc" "resources"]

 :aliases
 {:dev {:extra-paths ["env/dev/clj"]
        :extra-deps  {clj-commons/clj-yaml        {:mvn/version "0.7.0"}
                      criterium/criterium         {:mvn/version "0.4.6"}
                      pogonos/pogonos             {:mvn/version "0.1.1"}
                      ubergraph/ubergraph         {:mvn/version "0.8.2"}
                      vlaaad/reveal               {:mvn/version "1.3.196"}

                      ;; to be deleted?
                      binaryage/devtools {:mvn/version "0.9.10"}}}

  :prod {:extra-paths ["env/prod/clj"]}

  :repl {:extra-paths ["env/dev/resources"]
         :ns-default  cockpit.repl
         :jvm-opts    ["-Dvlaaad.reveal.prefs={:font-size 30 :font-family \"Roboto\"}"]}

  :test {:extra-paths ["test" "test-resources"]
        :extra-deps {clj-http-fake/clj-http-fake {:mvn/version "1.0.3"}
                      nubank/matcher-combinators  {:mvn/version "3.1.4"}
                      cloverage/cloverage           {:mvn/version "1.2.2"}
                      lambdaisland/kaocha {:mvn/version "1.0.887"}
                      lambdaisland/kaocha-cloverage {:mvn/version "1.0.75"}
                      lambdaisland/kaocha-junit-xml {:mvn/version "0.0.76"}}
         :main-opts  ["-m" "kaocha.runner"]}

  :uberjar {:replace-deps {com.github.seancorfield/depstar {:mvn/version "2.1.278"}}
            :exec-fn      hf.depstar/uberjar
            :exec-args    {:jar             "app.jar"
                           :compile-aliases [:prod]
                           :aot             true
                           :main-class      app.server}}

  :frontend {:replace-paths ["src/cljs" "src/cljc"]
             :deps  {thheller/shadow-cljs        {:mvn/version "2.9.10"}
                     camel-snake-kebab           {:mvn/version "0.4.1"}
                     cljs-ajax                   {:mvn/version "0.8.0"}
                     cljs-http                   {:mvn/version "0.1.45"}
                     com.andrewmcveigh/cljs-time {:mvn/version "0.5.2"}
                     day8.re-frame/http-fx       {:mvn/version "0.1.6"}
                     metosin/reitit              {:mvn/version "0.3.10"}
                     re-frame                    {:mvn/version "1.2.0"}
                     reagent                     {:mvn/version "1.0.0"}
                     tongue                     {:mvn/version "0.3.0"}
                     fork                      {:mvn/version "2.2.4"}
                     phrase                      {:mvn/version "0.3-alpha4"}
                     binaryage/oops              {:mvn/version "0.7.0"}
             :main-opts  ["-m" "shadow.cljs.devtools.cli"]}}}
```

首先期望执行命令以获取所有依赖项
```
clojure -Sdeps '{:mvn/local-repo ".m2"}' -A:dev:test:prod:frontend -Spath
```

当运行测试时,预计不会获取任何依赖项
```
clojure -Sdeps '{:mvn/local-repo ".m2"}' -M:dev:test --profile :ci
```
```
by
我还没有深入研究这个问题,但是通过指定不同的别名,你会得到不同的依赖集,所以它会下载新的依赖版本。

例如,第一个版本不使用honeysql,而第二个版本使用了honeysql,因此它必须下载。如果这两个计算之间有版本差异,那么第二个可能下载已经存在的库的新版本。

重新运行你列出的任意一个命令都不会下载新的库,问题在于这些命令不同的依赖集,所以你假定不应该发生下载的假设是不正确的。
by
编辑 by
啊,对了,`frontedn` 排除了很多依赖,有道理。

感谢检查
0


...