technomancy / leiningen

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

Mac OSX: Leiningen 2.8.1 Cannot Resolve Repos (Connection Refused) #2368

Closed ibcoleman closed 6 years ago

ibcoleman commented 6 years ago

I installed Leiningen via the script (according to these instructions: http://www.lispcast.com/clojure-mac). After installing lein will return the version, and will successfully create a project with lein new app foobar.

The odd thing is, it won't resolve any dependencies. For example, if I do:

lein new droid second-droid-clj
Could not find metadata droid:lein-template/maven-metadata.xml in local (/Users/ian/.m2/repository)
Could not transfer metadata droid:lein-template/maven-metadata.xml from/to central (https://repo1.maven.org/maven2/): Connect to  [localhost/127.0.0.1] failed: Connection refused (Connection refused)
Could not transfer metadata droid:lein-template/maven-metadata.xml from/to clojars (https://repo.clojars.org/): Connect to  [localhost/127.0.0.1] failed: Connection refused (Connection refused)
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.
Could not find template droid on the classpath.

For some reason, lein seems to be trying to connect to localhost instead of maven.org or clojars.org. I have a VPN client (which is not active) but I do not have any proxy env variables set:

➜  clojure-droid echo $HTTP_PROXY

➜  clojure-droid echo $HTTPS_PROXY

If I add some arbitrary dependency to my ~/.lein/profile.clj, I get the following failure to resolve dependencies, again looking like it can't resolve the URLs:

➜  Projects lein new droid second-droid-clj 
Leiningen's classpath: /Users/ian/.lein/self-installs/leiningen-2.8.1-standalone.jar
Could not transfer artifact lein-pprint:lein-pprint:jar:1.1.1 from/to central (https://repo1.maven.org/maven2/): Connect to  [localhost/127.0.0.1] failed: Connection refused (Connection refused)
Could not transfer artifact lein-pprint:lein-pprint:jar:1.1.1 from/to clojars (https://repo.clojars.org/): Connect to  [localhost/127.0.0.1] failed: Connection refused (Connection refused)
Could not transfer artifact lein-pprint:lein-pprint:jar:1.1.1 from/to private-plugins (private repo url): Cannot access private repo url with type default using the available connector factories: BasicRepositoryConnectorFactory
Could not transfer artifact lein-pprint:lein-pprint:pom:1.1.1 from/to central (https://repo1.maven.org/maven2/): Connect to  [localhost/127.0.0.1] failed: Connection refused (Connection refused)
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.
clojure.lang.ExceptionInfo: Could not resolve dependencies
 at clojure.core$ex_info.invokeStatic (core.clj:4617)

Finally, I have no issues resolving, say, clojars.org from the CL.

➜  Projects ping clojars.org
PING clojars.org (23.253.149.7): 56 data bytes
64 bytes from 23.253.149.7: icmp_seq=0 ttl=53 time=6.472 ms
64 bytes from 23.253.149.7: icmp_seq=1 ttl=53 time=5.399 ms
^C

I've posed the question on the clojure::leiningen slack channel, and asked in a few other places, but no one seems to have a clue why this clean install can't resolve URLs. Any suggestions?

Thanks!

--Ian

technomancy commented 6 years ago

This seems like a DNS or networking problem. I can't think of anything in Leiningen that would cause this.

ibcoleman commented 6 years ago

It's extremely odd. There's no other piece of software on this machine where networking behaves like this. (e.g gradle, git, etc, etc, etc...)

danielcompton commented 6 years ago

@ibcoleman can you try some older versions of Leiningen?

ibcoleman commented 6 years ago

@danielcompton I get the same error. On a whim I tried running as sudo and it looks like it was able to resolve the addresses of the remote repositories. I installed leiningen to /usr/local/bin:

curl https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein > lein
sudo mkdir -p /usr/local/bin/
sudo mv lein /usr/local/bin/lein
sudo chmod a+x /usr/local/bin/lein
export PATH=$PATH:/usr/local/bin

But if I install it as a non-root user to ~/bin then things look like they're working properly. I'm going to chalk this up to Mac OSX weirdness.

technomancy commented 6 years ago

Sorry, do you mean to say that the ability of the JVM to correctly resolve domain names depends on the location in which the shell script is located? Or that it depends on whether it's being run as root or not?

ibcoleman commented 6 years ago

Names were being resolved as root but not as a non-privileged user. It seems like the name resolution was in a broken state after an OSX upgrade. It was only failing in terminal. Bizarre. On Fri, Dec 15, 2017 at 12:31 PM Phil Hagelberg notifications@github.com wrote:

Sorry, do you mean to say that the ability of the JVM to correctly resolve domain names depends on the location in which the shell script is located? Or that it depends on whether it's being run as root or not?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/technomancy/leiningen/issues/2368#issuecomment-352064860, or mute the thread https://github.com/notifications/unsubscribe-auth/ABj6DUt50MxZ71SocR1Zlhwe_1fp34z7ks5tAq0JgaJpZM4Q8QtO .

ghost commented 5 years ago

We have exactly the same issue on Ubuntu, where name resolution works as sudo, but not as an unprivileged user. Could not transfer artifact org.clojure:tools.namespace:pom:0.2.11 from/to central (https://repo1.maven.org/maven2/): Connect to [localhost/127.0.0.1] failed: Connection refused (Connection refused)

winks commented 5 years ago

@j-pb Could you please give the output of lsb_release -a and java -version? And I assume you're running lein 2.8.1?

alek-sys commented 5 years ago

I have the same problem on Mac OS 10.14.2 + Lein 2.8.3. In my case the problem was in empty http_proxy environment variable (set by Bash It I believe). It was tricky to spot because echo $http_proxy gave no output, however variable was set to an empty string. So just running unset http_proxy did the trick.

Duan-fei commented 4 years ago

I think it's the DNS problem, adding a nameserver 8.8.8.8 to solve this problem.

enthusiast17 commented 4 years ago

Well, I had the same issue Ubuntu 20.04/Windows 10. Please, follow below steps: 1) Check clojars.org website. If you can not visit website (your Internet Provider blocks this website), then:

     1) Use OpenVPN on Ubuntu (the easiest way)/I don't know VPN tools on Windows 10 (so, google it)
     2) Or other methods to get access to visit this website from terminal

  If you can visit website

     1) Don't give up, ask somebody (community) to help in clojure channel (slack, discord and etc)