lein安装问题

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/tonylee0329/article/details/40393059
本文为作者原创,转载请标明出处。原作者:Tony_老七
  
   clojure使用lein作为包管理及编译工具,所以在开始你的clojure之旅的开始,需要安装一下leiningen(注意读音)

     lein的项目维护在github:https://github.com/technomancy/leiningen,可以按照安装方案进行,不赘述,以下是安装过程中碰到的问题

安装环境:
OS: 
[dcli@nfzm ~]$ head -n 1 /etc/issue 
CentOS release 5.8 (Final)

一、无法下载安装包

下载lein的脚本后,执行lein,或者lein install,它会去下载leiningen-xxx-standalone.jar(xxxx为版本,我的是2.5.0)
报错如下:
Failed to download https://github.com/technomancy/leiningen/releases/download/2.5.0/leiningen-2.5.0-standalone.jar (exit code 7)

It's possible your HTTP client's certificate store does not have the
correct certificate authority needed. This is often caused by an
out-of-date version of libssl. It's also possible that you're behind a
firewall and haven't set HTTP_PROXY and HTTPS_PROXY.

搜了一下网上的解决办法
https://github.com/technomancy/leiningen/issues/1634

解决方法:
export HTTP_CLIENT="wget --no-check-certificate -O"
然后再此执行,下载成功

二、无法启动repl

leiningen的执行jar下载完成后,在学习clojure起初,我们常用的是repl这个交互式的终端
我的在启动的时候,报错如下

Could not transfer artifact org.clojure:tools.nrepl:pom:0.2.6 from/to central (https://repo1.maven.org/maven2/): Connection timed out
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-4" clojure.lang.ExceptionInfo: Could not resolve dependencies {:suppress-msg true, :exit-code 1}
        at clojure.core$ex_info.invoke(core.clj:4403)
        at leiningen.core.classpath$fn__5769.invoke(classpath.clj:185)
        at clojure.lang.AFn.applyToHelper(AFn.java:160)
        at clojure.lang.AFn.applyTo(AFn.java:144)
        at clojure.core$apply.invoke(core.clj:624)
        at clojure.core$memoize$fn__5097.doInvoke(core.clj:5846)
        at clojure.lang.RestFn.invoke(RestFn.java:436)
        at leiningen.core.classpath$get_dependencies.doInvoke(classpath.clj:306)
        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:628)
        at leiningen.core.classpath$resolve_dependencies.doInvoke(classpath.clj:350)
        at clojure.lang.RestFn.invoke(RestFn.java:425)
        at leiningen.core.eval$prep.invoke(eval.clj:64)
        at leiningen.core.eval$eval_in_project.invoke(eval.clj:333)
        at leiningen.repl$server$fn__10685.invoke(repl.clj:229)
        at clojure.lang.AFn.applyToHelper(AFn.java:152)
        at clojure.lang.AFn.applyTo(AFn.java:144)
        at clojure.core$apply.invoke(core.clj:624)
        at clojure.core$with_bindings_STAR_.doInvoke(core.clj:1862)
        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:628)
        at clojure.core$bound_fn_STAR_$fn__4140.doInvoke(core.clj:1884)
        at clojure.lang.RestFn.invoke(RestFn.java:397)
        at clojure.lang.AFn.run(AFn.java:22)
        at java.lang.Thread.run(Thread.java:662)
Caused by: org.sonatype.aether.resolution.DependencyResolutionException: Failed to collect dependencies for [#<Dependency org.clojure:tools.nrepl:jar:0.2.6 (test)> #<Dependency clojure-complete:clojure-complete:jar:0.2.3 (test)>]
        at org.sonatype.aether.impl.internal.DefaultRepositorySystem.resolveDependencies(DefaultRepositorySystem.java:371)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        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:624)
        at cemerick.pomegranate.aether$resolve_dependencies.doInvoke(aether.clj:729)
        at clojure.lang.RestFn.invoke(RestFn.java:2088)
        at leiningen.core.classpath$fn__5769.invoke(classpath.clj:176)
        ... 27 more
Caused by: org.sonatype.aether.collection.DependencyCollectionException: Failed to collect dependencies for [#<Dependency org.clojure:tools.nrepl:jar:0.2.6 (test)> #<Dependency clojure-complete:clojure-complete:jar:0.2.3 (test)>]
        at org.sonatype.aether.impl.internal.DefaultDependencyCollector.collectDependencies(DefaultDependencyCollector.java:258)
        at org.sonatype.aether.impl.internal.DefaultRepositorySystem.resolveDependencies(DefaultRepositorySystem.java:333)
        ... 39 more
Caused by: org.sonatype.aether.resolution.ArtifactDescriptorException: Failed to read artifact descriptor for org.clojure:tools.nrepl:jar:0.2.6
        at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom(DefaultArtifactDescriptorReader.java:296)
        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)
        ... 40 more
Caused by: org.sonatype.aether.resolution.ArtifactResolutionException: Could not transfer artifact org.clojure:tools.nrepl:pom:0.2.6 from/to central (https://repo1.maven.org/maven2/): Connection timed out
        at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:538)
        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)
        ... 43 more
Caused by: org.sonatype.aether.transfer.ArtifactTransferException: Could not transfer artifact org.clojure:tools.nrepl:pom:0.2.6 from/to central (https://repo1.maven.org/maven2/): Connection timed out
        at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$4.wrap(WagonRepositoryConnector.java:951)
        at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$4.wrap(WagonRepositoryConnector.java:941)
        at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$GetTask.run(WagonRepositoryConnector.java:669)
        at org.sonatype.aether.util.concurrency.RunnableErrorForwarder$1.run(RunnableErrorForwarder.java:60)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
        ... 1 more
Caused by: org.apache.maven.wagon.TransferFailedException: Connection timed out
        at org.apache.maven.wagon.shared.http4.AbstractHttpClientWagon.fillInputData(AbstractHttpClientWagon.java:892)
        at org.apache.maven.wagon.StreamWagon.getInputStream(StreamWagon.java:116)
        at org.apache.maven.wagon.StreamWagon.getIfNewer(StreamWagon.java:88)
        at org.apache.maven.wagon.StreamWagon.get(StreamWagon.java:61)
        at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$GetTask.run(WagonRepositoryConnector.java:601)
        ... 4 more
Caused by: java.net.ConnectException: Connection timed out
        at java.net.PlainSocketImpl.socketConnect(Native Method)
        at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)
        at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)
        at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
        at java.net.Socket.connect(Socket.java:529)
        at com.sun.net.ssl.internal.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:570)
        at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:522)
        at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:401)
        at org.apache.maven.wagon.shared.http4.ConfigurableSSLSocketFactoryDecorator.connectSocket(ConfigurableSSLSocketFactoryDecorator.java:64)
        at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:177)
        at org.apache.http.impl.conn.ManagedClientConnectionImpl.open(ManagedClientConnectionImpl.java:304)
        at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:611)
        at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:446)
        at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:863)
        at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
        at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:57)
        at org.apache.maven.wagon.shared.http4.AbstractHttpClientWagon.execute(AbstractHttpClientWagon.java:746)
        at org.apache.maven.wagon.shared.http4.AbstractHttpClientWagon.fillInputData(AbstractHttpClientWagon.java:886)
        ... 8 more




参考:
https://github.com/technomancy/leiningen/wiki/HTTP-Proxies


网络问题是在蛋疼,这台机器又是公司测试机,没敢大动
安装了个windows的先玩,同样遇到无法下载jar文件问题,直接从linux机器上搞过来了
windows安装
http://leiningen-win-installer.djpowell.net/

启动lein repl,ok:
C:\Users\tony.li>lein repl
Retrieving org/clojure/tools.nrepl/0.2.6/tools.nrepl-0.2.6.pom from central
Retrieving org/clojure/tools.nrepl/0.2.6/tools.nrepl-0.2.6.jar from central
nREPL server started on port 49826 on host 127.0.0.1 - nrepl://127.0.0.1:49826
REPL-y 0.3.5, nREPL 0.2.6
Clojure 1.6.0
Java HotSpot(TM) 64-Bit Server VM 1.6.0_45-b06
    Docs: (doc function-name-here)
          (find-doc "part-of-name-here")
  Source: (source function-name-here)
Javadoc: (javadoc java-object-or-class-here)
    Exit: Control+D or (exit) or (quit)
Results: Stored in vars *1, *2, *3, an exception in *e

user=> (println "hello world")
hello world
nil
user=>






















展开阅读全文

没有更多推荐了,返回首页