leiningen icon indicating copy to clipboard operation
leiningen copied to clipboard

lein repositories appear to never fall back from :mirrors

Open philip-doctor opened this issue 8 years ago • 5 comments

I have

:mirrors {#"central" {:name "Internal central mirror"
                                :url "http://maven.example.lan:8081/nexus/content/repositories/central/"
                                :snapshots false}

I see all of my dependencies get resolved through it, awesome. Then I disconnect from my VPN, so I can no longer resolve maven.example.lan, I get

$ lein compile
Could not transfer artifact lein-exec:lein-exec:pom:0.3.2 from/to Internal central mirror (http://maven.example.lan:8081/nexus/content/repositories/central/): maven.example.lan: unknown error

I tried explicitly specifying central in my repositories

:repositories [["central" {:name "Public central"
                                       :url "https://repo1.maven.org/maven2"
                                       :snapshots false}]

But no dice. Same error.

I would expect that if a mirror wasn't available that lein would fallback to the repositories available, but that doesn't appear to be the case.

Note: I have a clojars mirror as well, I just didn't list it here for brevity, but I'm aware that those plugins should be obtained by clojars, however it looks like lein fails on the first mirror here based on the error message.

Leiningen 2.7.0 on Java 1.8.0_91 Java HotSpot(TM) 64-Bit Server VM

philip-doctor avatar Jan 26 '17 18:01 philip-doctor

I'm seeing the same behavior, related to the pom task, in 2.7.1.

hlship avatar Nov 13 '17 23:11 hlship

Our environment is a locked-down VM where there's no access to Clojars or Central; everything must go through an internal Nexus into which white-listed artifacts are copied, we use :mirrors in the :user profile in profiles.clj to set this up.

That works fine for lein test, etc., but for lein install it hangs after creating the JAR file, and eventually times out accessing https://repo1.maven.org/maven2, i.e., ignoring mirrors entirely.

13:36:51 Applying task install to []
13:36:51 Applying task javac to nil
13:36:51 Running javac with [@/tmp/.leiningen-cmdline1472238735037897660.tmp]
13:36:51 Applying task compile to nil
13:36:51 All namespaces already AOT compiled.
13:36:51 Created /home/jenkins/looperJobs/CPH/lang/ws/target/lang-1.10.2.jar
14:02:18 Could not transfer artifact org.clojure:clojure:pom:1.8.0 from/to central (https://repo1.maven.org/maven2/): Connect to repo1.maven.org:443 [repo1.maven.org/151.101.184.209] failed: Connection timed out (Connection timed out)

hlship avatar Nov 13 '17 23:11 hlship

There is a very big difference between putting the :mirrors into the :user profile in profiles.clj, vs. putting the :mirrors into project.clj directly. Using profiles, failure. Using project.clj, success.

hlship avatar Nov 14 '17 18:11 hlship

The jar task (called by install) strips out the :user profile in order to prevent user-level settings from interfering with downstream consumers; however there is code which is intended to let certain settings like :mirrors thru from the user profile because they shouldn't affect the outcome of the jar.

It sounds like there may be a bug in the jar whitelisting code, but it would be helpful to know whether it's present in the latest stable release since 2.7.1 is over a year old.

technomancy avatar Nov 14 '17 19:11 technomancy

(Note that the whitelisting bug doesn't have anything to do with this mirror-fallback issue, so please create a new one for that.)

technomancy avatar Nov 14 '17 19:11 technomancy