OSX And Leiningen Setup: Spooky Behavior


#1

Hi! I’m trying to set up my environment on Mac OSX (High Sierra), and am coming across a weird situation. Everything seemed to go fine when installing leiningen via brew, and I can create a default project. The problem is leiningen cannot seem to resolve any dependencies. Whenever I add a dependency, lein fails. The odd thing is, it fails while resolving clojars.org and mavne.org to localhost:

->  lein deps 
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: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. 

If I ping either of those from the CL I get:

-> ping repo.clojars.org
PING v.ssl.global.fastly.net (151.101.201.128): 56 data bytes
64 bytes from 151.101.201.128: icmp_seq=0 ttl=59 time=7.657 ms

My leiningen version is:

-> lein version                
Leiningen 2.8.1 on Java 1.8.0_112 Java HotSpot(TM) 64-Bit Server VM

Odd no?

–Ian


#2

Hi Ian,

Yeah, that is weird. I’d love to help you debug this. Could you post your project.clj? Also, do you have anything in the ~/.lein/ directory?

Thanks
Eric


#3

Hey Eric,

The .lein directory is just:

➜  first-clojure-droid ls -al ~/.lein
total 16
drwxr-xr-x   5 ian  staff   160 Dec  7 12:00 .
drwxr-xr-x+ 64 ian  staff  2048 Dec  7 13:39 ..
-rw-r--r--   1 ian  staff   206 Dec  7 11:58 profiles.clj.old
-rw-r--r--   1 ian  staff    28 Dec  7 10:36 repl-history
drwxr-xr-x   3 ian  staff    96 Dec  7 09:43 self-installs

And project.clj is just the default created by lein new app foo

(defproject first-clojure-droid "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.8.0"]]

  :main ^:skip-aot first-clojure-droid.core
  :target-path "target/%s"
  :profiles {:uberjar {:aot :all}})

Thanks!

–Ian


#4

Hey Eric,

I got a chance to dig back into this, and it looks like it may be a permissions thing. If I run Leiningen as sudo lein deps then the remote repository names are properly resolved. If I don’t I get the same error.

If, instead of installing Leiningen to /usr/local/bin w/ sudo, I install it to ~/bin as my non-root user, things also work okay. So there’s definitely something odd and Mac-y going on… :slight_smile:

–ian


#5

Hmm. That does look odd. I’ve always installed it to ~/bin and added that directory to my path. Maybe that is a Mac thing, with siloed permissions.

I’m glad you figured it out, though, I was out of ideas!

Eric