technomancy / leiningen

Moved to Codeberg; this is a convenience mirror
https://codeberg.org/leiningen/leiningen
Other
7.29k stars 1.61k forks source link

leiningen cannot talk to an IPv6-only maven repository #2000

Closed martinraison closed 9 months ago

martinraison commented 9 years ago

I am using a mirror to fetch my project's dependencies. This mirror is IPv6-only, which doesn't seem to be supported by leiningen (I am getting a No route to host error). I tried adding -Djava.net.preferIPv6Addresses=true to JVM_OPTS and LEIN_JVM_OPTS, without success.

Any ideas? I should add that this setup was working perfectly before, the only change is that the mirror is now IPv6-only.

winks commented 9 years ago

To investigate this, I just created a temporary maven repo here with only storm-core and storm-kafka in it.

Trying to dig into this, but if anyone succeeds faster...

you can test connectivity like this:

curl  'http://[2a01:238:421a:4400:58b4:be26:41f:6fde]:81/org/' -g
martinraison commented 9 years ago

Thanks for doing this. When I specify a URL with an IPv6 address directly (with the brackets, like http://[2a01:238:421a:4400:58b4:be26:41f:6fde]:81/org/), I get this stacktrace:

Exception in thread "Thread-3" java.lang.NumberFormatException: For input string: "238:421a:4400:58b4:be26:41f:6fde]:81"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:580)
at java.lang.Integer.parseInt(Integer.java:615)
at org.apache.maven.wagon.PathUtils.port(PathUtils.java:281)
at org.apache.maven.wagon.repository.Repository.setUrl(Repository.java:147)
at org.apache.maven.wagon.repository.Repository.<init>(Repository.java:91)
at org.sonatype.aether.connector.wagon.WagonRepositoryConnector.<init>(WagonRepositoryConnector.java:143)
at org.sonatype.aether.connector.wagon.WagonRepositoryConnectorFactory.newInstance(WagonRepositoryConnectorFactory.java:142)
at org.sonatype.aether.impl.internal.DefaultRemoteRepositoryManager.getRepositoryConnector(DefaultRemoteRepositoryManager.java:346)
at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:453)
at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:216)
at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:193)
at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom(DefaultArtifactDescriptorReader.java:281)
at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.readArtifactDescriptor(DefaultArtifactDescriptorReader.java:186)
at org.sonatype.aether.impl.internal.DefaultDependencyCollector.process(DefaultDependencyCollector.java:412)
at org.sonatype.aether.impl.internal.DefaultDependencyCollector.collectDependencies(DefaultDependencyCollector.java:240)
at org.sonatype.aether.impl.internal.DefaultRepositorySystem.resolveDependencies(DefaultRepositorySystem.java:333)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:93)
at clojure.lang.Reflector.invokeInstanceMethod(Reflector.java:28)
at cemerick.pomegranate.aether$resolve_dependencies_STAR_.doInvoke(aether.clj:720)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.core$apply.invoke(core.clj:630)
at cemerick.pomegranate.aether$resolve_dependencies.doInvoke(aether.clj:729)
at clojure.lang.RestFn.invoke(RestFn.java:2088)
at leiningen.core.classpath$fn__6725.invoke(classpath.clj:115)
at clojure.lang.AFn.applyToHelper(AFn.java:160)
at clojure.lang.AFn.applyTo(AFn.java:144)
at clojure.core$apply.invoke(core.clj:630)
at clojure.core$memoize$fn__5479.doInvoke(core.clj:6082)
at clojure.lang.RestFn.invoke(RestFn.java:436)
at leiningen.core.classpath$get_dependencies.doInvoke(classpath.clj:276)
at clojure.lang.RestFn.invoke(RestFn.java:425)
at clojure.lang.AFn.applyToHelper(AFn.java:156)
at clojure.lang.RestFn.applyTo(RestFn.java:132)
at clojure.core$apply.invoke(core.clj:634)
at leiningen.core.classpath$resolve_dependencies.doInvoke(classpath.clj:320)
at clojure.lang.RestFn.invoke(RestFn.java:425)
at leiningen.core.eval$prep.invoke(eval.clj:68)
at leiningen.core.eval$eval_in_project.invoke(eval.clj:352)
at leiningen.repl$server$fn__11848.invoke(repl.clj:243)
at clojure.lang.AFn.applyToHelper(AFn.java:152)
at clojure.lang.AFn.applyTo(AFn.java:144)
at clojure.core$apply.invoke(core.clj:630)
at clojure.core$with_bindings_STAR_.doInvoke(core.clj:1868)
at clojure.lang.RestFn.invoke(RestFn.java:425)
at clojure.lang.AFn.applyToHelper(AFn.java:156)
at clojure.lang.RestFn.applyTo(RestFn.java:132)
at clojure.core$apply.invoke(core.clj:634)
at clojure.core$bound_fn_STAR_$fn__4439.doInvoke(core.clj:1890)
at clojure.lang.RestFn.invoke(RestFn.java:397)
at clojure.lang.AFn.run(AFn.java:22)
at java.lang.Thread.run(Thread.java:745)

It looks like the URL is being parsed incorrectly. I don't know if that's fixed in more recent versions of maven wagon. Also in my original problem, I was using a hostname, not an IPv6 address, so the error was different (No route to host instead).

winks commented 9 years ago

@martinraison could you maybe post the relevant snippet where you actually configure this repo? Could be an escaping issue of the [] for all I know

winks commented 9 years ago

Sorry, there's already an AAAA record. just use chuck.art-core.org, it should have no A record.

martinraison commented 9 years ago

Alright, so I tried with this in ~/.lein/profiles.clj

{:user {:mirrors {#".*" {:name "mymirror"
                     :url "http://chuck.art-core.org:81"}}}}

And did a simple lein new app testipv6, then added the [org.apache.storm/storm-core "0.9.3-rc1"] dependency as follows:

(defproject testipv6 "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url "http://example.com/FIXME"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.7.0"]
                 [org.apache.storm/storm-core "0.9.3-rc1"]]
  :main ^:skip-aot testipv6.core
  :target-path "target/%s"
  :profiles {:uberjar {:aot :all}})

And after lein repl I'm getting a bunch of errors like this:

Sep 30, 2015 7:39:15 AM org.apache.http.impl.execchain.RetryExec execute
INFO: I/O exception (java.net.NoRouteToHostException) caught when processing request to {}->http://chuck.art-core.org:81: No route to host

Previously I also tried with this in ~/.lein/profiles.clj:

{:user {:mirrors {#".*" {:name "mymirror"
                         :url "http://[2a01:238:421a:4400:58b4:be26:41f:6fde]:81"}}}}
winks commented 9 years ago

This is what I get:

hostname:

Could not find artifact org.clojure:clojure:jar:1.7.0 in mymirror (http://chuck.art-core.org:81)
Could not find artifact org.clojure:clojure:jar:1.7.0 in mymirror (http://chuck.art-core.org:81)
Could not find artifact org.clojure:tools.nrepl:jar:0.2.10 in mymirror (http://chuck.art-core.org:81)
Could not find artifact org.clojure:tools.nrepl:jar:0.2.10 in mymirror (http://chuck.art-core.org:81)
Could not find artifact clojure-complete:clojure-complete:jar:0.2.3 in mymirror (http://chuck.art-core.org:81)
Could not find artifact clojure-complete:clojure-complete:jar:0.2.3 in mymirror (http://chuck.art-core.org:81)
Could not find artifact org.apache:apache:pom:10 in mymirror (http://chuck.art-core.org:81)
This could be due to a typo in :dependencies or network issues.
If you are behind a proxy, try setting the 'http_proxy' environment variable.
Exception in thread "Thread-3" clojure.lang.ExceptionInfo: Could not resolve dependencies {:suppress-msg true, :exit-code 1}

With IP:

Exception in thread "Thread-4" java.lang.NumberFormatException: For input string: "238:421a:4400:58b4:be26:41f:6fde]:81"
        at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
winks commented 9 years ago

Could be a pomegranate issue, I'm out of ideas atm :/

martinraison commented 9 years ago

Interesting, you don't seem to have any problem with the hostname (apart from the fact that deps are missing). At least you have the parsing problem with the IP.

winks commented 9 years ago

Yeah I'm pretty sure we have some ipv6 parsing problem upstream. Or in lein, but I can't find where it would be.

martinraison commented 9 years ago

For anyone having the same issue, a simple super-kludgy workaround is to use socat:

sudo socat TCP4-LISTEN:10081,fork,su=nobody TCP6:chuck.art-core.org:81

and specify http://localhost:10081 for the mirror URL. This is still far from ideal, though.

oliviervaussy commented 8 years ago

Seem related to https://bugs.openjdk.java.net/browse/JDK-8132520

hypirion commented 8 years ago

This also is a problem when localhost resolves to ::1 before 127.0.0.1, or if 127.0.0.1 is not present at all.

telmich commented 4 years ago

ping6 - has there been any changes since the bug opening in 2015?

technomancy commented 9 months ago

If anyone has any ipv6 repositories we could check against, that would be nice. It's not unlikely that this has been fixed upstream since this was reported.

marcobiscaro2112 commented 9 months ago

I believe this is fixed (not sure if on stable, but for sure in the latest main branch, commit 6e17ebb13a12fba84df05f65a18e6c50427b83bb).

Maven Central now supports IPv6:

$ dig +short -t AAAA repo1.maven.org
2a04:4e42:4c::209
2a04:4e42:4d::209

Running a slightly modified version of leiningen (that depends on slf4j-simple instead of slf4j-nop):

$ export LEIN_JVM_OPTS="-Djava.net.preferIPv6Addresses=true -Dorg.slf4j.simpleLogger.defaultLogLevel=debug"
$ lein-main deps
[...]
[main] DEBUG org.apache.http.impl.conn.PoolingHttpClientConnectionManager - Connection request: [route: {s}->https://repo1.maven.org:443][total available: 0; route allocated: 0 of 20; total allo
cated: 0 of 40]
[main] DEBUG org.apache.http.impl.conn.PoolingHttpClientConnectionManager - Connection leased: [id: 0][route: {s}->https://repo1.maven.org:443][total available: 0; route allocated: 1 of 20; tota
l allocated: 1 of 40]
[main] DEBUG org.apache.http.impl.execchain.MainClientExec - Opening connection {s}->https://repo1.maven.org:443
[main] DEBUG org.apache.http.impl.conn.DefaultHttpClientConnectionOperator - Connecting to repo1.maven.org/[2a04:4e42:4d:0:0:0:0:209]:443
[main] DEBUG org.apache.http.conn.ssl.SSLConnectionSocketFactory - Connecting socket to repo1.maven.org/[2a04:4e42:4d:0:0:0:0:209]:443 with timeout 1800000
[main] DEBUG org.apache.http.conn.ssl.SSLConnectionSocketFactory - Enabled protocols: [TLSv1.3, TLSv1.2]
[... handshake ...]
[main] DEBUG org.apache.http.impl.conn.DefaultHttpClientConnectionOperator - Connection established 2804:14c:193:85f2:d8d2:e695:40c:b76b:64124<->2a04:4e42:4d:0:0:0:0:209:443
technomancy commented 9 months ago

Awesome; thanks!