Fork me on GitHub
#clojure
<
2024-05-05
>
Avishay Sanker09:05:52

Hi, i am trying to build Docker for my Clojure code and on "RUN lein deps" I get this error to all of my dependencies:

Could not transfer artifact org.clojure:clojure:jar:1.11.1 from/to central (): transfer failed for 
I am not behind a proxy, tried different networks as well and running the code out of docker build do work

p-himik09:05:52

Is the .m2 directory writable inside the container?

thheller09:05:43

and whats the rest of the error? it should tell you why it fails?

Avishay Sanker09:05:47

the .m2 directory is not created as the build fails. this is the full error:

RUN lein deps:
3.057 Could not transfer artifact com.layerware:hugsql:jar:0.5.1 from/to central (): transfer failed for 
3.057 Could not transfer artifact com.layerware:hugsql:jar:0.5.1 from/to clojars (): transfer failed for 
3.057 Could not transfer artifact compojure:compojure:jar:1.6.1 from/to central (): transfer failed for 
3.057 Could not transfer artifact compojure:compojure:jar:1.6.1 from/to clojars (): transfer failed for 
3.057 Could not transfer artifact http-kit:http-kit:jar:2.3.0 from/to central (): transfer failed for 
3.057 Could not transfer artifact http-kit:http-kit:jar:2.3.0 from/to clojars (): transfer failed for 
3.058 Could not transfer artifact ring:ring-defaults:jar:0.3.2 from/to central (): transfer failed for 
3.058 Could not transfer artifact ring:ring-defaults:jar:0.3.2 from/to clojars (): transfer failed for 
3.058 Could not transfer artifact ring:ring-core:jar:1.10.0 from/to central (): transfer failed for 
3.058 Could not transfer artifact ring:ring-core:jar:1.10.0 from/to clojars (): transfer failed for 
3.058 Could not transfer artifact ring:ring-jetty-adapter:jar:1.8.1 from/to central (): transfer failed for 
3.058 Could not transfer artifact ring:ring-jetty-adapter:jar:1.8.1 from/to clojars (): transfer failed for 
3.058 Could not transfer artifact ring:ring-codec:jar:1.2.0 from/to central (): transfer failed for 
3.058 Could not transfer artifact ring:ring-codec:jar:1.2.0 from/to clojars (): transfer failed for 
3.059 Could not transfer artifact org.clojure:data.json:jar:0.2.6 from/to central (): transfer failed for 
3.059 Could not transfer artifact org.clojure:data.json:jar:0.2.6 from/to clojars (): transfer failed for 
3.059 Could not transfer artifact com.microsoft.sqlserver:mssql-jdbc:jar:12.4.1.jre11 from/to central (): transfer failed for 
3.059 Could not transfer artifact com.microsoft.sqlserver:mssql-jdbc:jar:12.4.1.jre11 from/to clojars (): transfer failed for 
3.059 Could not transfer artifact clj-http:clj-http:jar:3.12.3 from/to central (): transfer failed for 
3.059 Could not transfer artifact clj-http:clj-http:jar:3.12.3 from/to clojars (): transfer failed for 
3.060 Could not transfer artifact hiccup:hiccup:jar:2.0.0-RC2 from/to central (): transfer failed for 
3.060 Could not transfer artifact hiccup:hiccup:jar:2.0.0-RC2 from/to clojars (): transfer failed for 
3.060 Failed to read artifact descriptor for com.layerware:hugsql:jar:0.5.1
3.060 Failed to read artifact descriptor for compojure:compojure:jar:1.6.1
3.060 Failed to read artifact descriptor for http-kit:http-kit:jar:2.3.0
3.060 Failed to read artifact descriptor for ring:ring-defaults:jar:0.3.2
3.060 Failed to read artifact descriptor for ring:ring-core:jar:1.10.0
3.060 Failed to read artifact descriptor for ring:ring-jetty-adapter:jar:1.8.1
3.060 Failed to read artifact descriptor for ring:ring-codec:jar:1.2.0
3.061 Failed to read artifact descriptor for org.clojure:data.json:jar:0.2.6
3.061 Failed to read artifact descriptor for com.microsoft.sqlserver:mssql-jdbc:jar:12.4.1.jre11
3.061 Failed to read artifact descriptor for clj-http:clj-http:jar:3.12.3
3.061 Failed to read artifact descriptor for hiccup:hiccup:jar:2.0.0-RC2
3.061 This could be due to a typo in :dependencies, file system permissions, or network issues.
3.061 If you are behind a proxy, try setting the 'http_proxy' environment variable.
------
Dockerfile:16
--------------------
  14 |     WORKDIR /usr/src/app
  15 |     COPY project.clj /usr/src/app/
  16 | >>> RUN lein deps
  17 |     COPY . /usr/src/app
  18 |     RUN mv "$(lein uberjar | sed -n 's/^Created \(.*standalone\.jar\)/\1/p')" app-standalone.jar
--------------------
ERROR: failed to solve: process "/bin/sh -c lein deps" did not complete successfully: exit code: 1

p-himik09:05:04

I don't know Lein but lein deps seems to be trimming the errors, not letting you see the full context. Perhaps there's some flag that prints out more verbose error messages.

p-himik09:05:19

Heh, apparently lein deps is deprecated because "it's not needed". Bizarre.

thheller09:05:42

thats pretty irrelevant. other tasks just also run it and would fail in the same way.

p-himik09:05:11

Yeah, I'm just sharing me being surprised.

thheller09:05:26

I'm guessing something with the docker network setup prevents proper https transfers in some way

p-himik09:05:42

You get the same exact "Could not transfer artifact" error if .m2 is not writable, which is trivial to achieve with some bad volume configuration or running something as root that creates .m2.

Avishay Sanker09:05:16

i am using the lein deps to preload all dependencies so i will get better run time for the docker but when i build the docker without preloading dependencies the docker is created and i get the same errors when running it

thheller09:05:52

lein deps running outside the container doesn't help anything inside the container. they won't see each other

thheller10:05:17

(unless you are specifically mounting the ~/.m2 dirs, or configured those somehow?)

Avishay Sanker10:05:32

this one works on build but fails on run:

FROM clojure:lein-2.10.0
COPY . /usr/src/app
WORKDIR /usr/src/app
CMD ["lein", "run"]
this one fails on build:
FROM clojure:lein-2.10.0
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY project.clj /usr/src/app/
RUN lein deps
COPY . /usr/src/app
RUN mv "$(lein uberjar | sed -n 's/^Created \(.*standalone\.jar\)/\1/p')" app-standalone.jar
CMD ["java", "-jar", "app-standalone.jar"]

p-himik10:05:00

Fails on run - with the same error?

p-himik10:05:18

Try running run -it --rm clojure:lein-2.10.0 bash. When you get to the prompt, first run

cat <<EOF > project.clj
(defproject my-stuff "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url ""
  :license {:name "Eclipse Public License"
            :url ""}
  :dependencies [[org.clojure/clojure "1.8.0"]]
  :main ^:skip-aot my-stuff.core
  :target-path "target/%s"
  :profiles {:uberjar {:aot :all}})
EOF
Then run lein deps. Does that work?

Avishay Sanker11:05:31

tried it, i get the same error:

Could not transfer artifact org.clojure:clojure:jar:1.8.0 from/to central (): transfer failed for 
Could not transfer artifact org.clojure:clojure:jar:1.8.0 from/to clojars (): transfer failed for 
Failed to read artifact descriptor for org.clojure:clojure:jar:1.8.0
This could be due to a typo in :dependencies, file system permissions, or network issues.
If you are behind a proxy, try setting the 'http_proxy' environment variable

p-himik11:05:37

Does plain curl --output /dev/null work on your machine? Outside of Docker.

Avishay Sanker11:05:43

when running the above it gives me 404 not found but when drooping the --output /dev/null it works

p-himik11:05:25

What do you mean by "it works"? What's the output?

Avishay Sanker11:05:21

sorry I was running it in postman and i got 200 on running the http, when running it in Git Bash I get this:

$ curl  --output /dev/null
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
curl: (35) schannel: next InitializeSecurityContext failed: CRYPT_E_NO_REVOCATION_CHECK (0x80092012) - The revocation function was unable to check revocation for the certificate.

p-himik11:05:08

Something wrong with your setup. I don't know what. Have you ever fiddled with root HTTPS certificates?

Avishay Sanker11:05:09

no i haven't on which setup you are referring? Docker?

p-himik11:05:31

If you run the above curl command on your main machine, then with your machine.

Avishay Sanker11:05:24

i was able to run it with --ssl-no-revoke

$ curl  --ssl-no-revoke --output /dev/null
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 3537k  100 3537k    0     0   510k      0  0:00:06  0:00:06 --:--:--  777k

p-himik12:05:33

That's a band-aid, not a solution. You should figure out why it happens in the first place. Maybe you have some weird antivirus that does that. Maybe something or someone has replaced your root certificates (which would be a terrible thing). SSL errors are not a thing you should just ignore.

mmossler17:05:47

Many organizations use firewall systems with SSL Inspection, introducing additional certificates. VMs and Containers usually come with their own certificate trust store and rightfully complain. Whenever I have to locally test a container I have to install the corporate certificates e.g. with java keystore or debian ca-certificates during container build to get it working and not see similar issues.

👍 1