leiningen安装记录

Leiningen是Clojure项目管理工具Leiningen is the easiest way to use Clojure,官网:http://leiningen.org/

1:首先下载Leiningen安装脚本:https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein

2:将其保存为lein文件然后移动到/usr/bin/目录下面(Ubuntu14.0.4 LST 64Bit)

y@y:~$ sudo mv my_note/lein /usr/bin/

修改lein权限,让其可以执行:

y@y:/usr/bin$ chmod +x lein 

3:执行lein命令,进行安装:

y@y:~$ lein 
Downloading Leiningen to /home/y/.lein/self-installs/leiningen-2.4.3-standalone.jar now...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   361    0   361    0     0    297      0 --:--:--  0:00:01 --:--:--   297
  0     0    0     0    0     0      0      0 --:--:--  0:01:05 --:--:--     0
curl: (22) The requested URL returned error: 403 Forbidden
Failed to download https://github.com/technomancy/leiningen/releases/download/2.4.3/leiningen-2.4.3-standalone.jar
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. Either upgrade it or set HTTP_CLIENT
to turn off certificate checks:
  export HTTP_CLIENT="wget --no-check-certificate -O" # or
  export HTTP_CLIENT="curl --insecure -f -L -o"
It's also possible that you're behind a firewall haven't yet
set HTTP_PROXY and HTTPS_PROXY.
[由于国内网络原因不能访问下载链接]
首先清除:
y@y:~$ rm .lein/ -rf

采用VPN或代理进行联网,再次运行下载成功!

y@y:~$ lein 
Downloading Leiningen to /home/y/.lein/self-installs/leiningen-2.4.3-standalone.jar now...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   357    0   357    0     0    310      0 --:--:--  0:00:01 --:--:--   310
100 14.2M  100 14.2M    0     0   195k      0  0:01:14  0:01:14 --:--:--  126k
(Retrieving org/clojure/tools.nrepl/0.2.3/tools.nrepl-0.2.3.pom from central)
(Retrieving org/clojure/pom.contrib/0.1.2/pom.contrib-0.1.2.pom from central)
(Retrieving org/sonatype/oss/oss-parent/7/oss-parent-7.pom from central)
(Retrieving clojure-complete/clojure-complete/0.2.3/clojure-complete-0.2.3.pom from clojars)
(Retrieving org/clojure/tools.nrepl/0.2.3/tools.nrepl-0.2.3.jar from central)
(Retrieving clojure-complete/clojure-complete/0.2.3/clojure-complete-0.2.3.jar from clojars)
Leiningen is a tool for working with Clojure projects.

Several tasks are available:
change              Rewrite project.clj by applying a function.
check               Check syntax and warn on reflection.
classpath           Print the classpath of the current project.
clean               Remove all files from project's target-path.
compile             Compile Clojure source into .class files.
deploy              Build and deploy jar to remote repository.
deps                Download all dependencies.
do                  Higher-order task to perform other tasks in succession.
help                Display a list of tasks or help for a given task.
install             Install the current project to the local repository.
jar                 Package up all the project's files into a jar file.
javac               Compile Java source files.
new                 Generate project scaffolding based on a template.
plugin              DEPRECATED. Please use the :user profile instead.
pom                 Write a pom.xml file to disk for Maven interoperability.
release             Perform :release-tasks.
repl                Start a repl session either with the current project or standalone.
retest              Run only the test namespaces which failed last time around.
run                 Run a -main function with optional command-line arguments.
search              Search remote maven repositories for matching jars.
show-profiles       List all available profiles or display one if given an argument.
test                Run the project's tests.
trampoline          Run a task without nesting the project's JVM inside Leiningen's.
uberjar             Package up the project files and dependencies into a jar file.
update-in           Perform arbitrary transformations on your project map.
upgrade             Upgrade Leiningen to specified version or latest stable.
vcs                 Interact with the version control system.
version             Print version for Leiningen and the current JVM.
with-profile        Apply the given task with the profile(s) specified.

Run `lein help $TASK` for details.

Global Options:
  -o             Run a task offline.
  -U             Run a task after forcing update of snapshots.
  -h, --help     Print this help or help for a specific task.
  -v, --version  Print Leiningen's version.

See also: readme, faq, tutorial, news, sample, profiles, deploying, gpg,
mixed-source, templates, and copying.
y@y:~$ 

4:运行lein repl进入控制台,发现报以下异常:

y@y:~$ lein repl
nREPL server started on port 40433 on host 127.0.0.1 - nrepl://127.0.0.1:40433
Exception in thread "nREPL-worker-0" java.lang.NoSuchMethodError: clojure.tools.nrepl.StdOutBuffer.length()I
    at clojure.tools.nrepl.middleware.session$session_out$fn__7630.doInvoke(session.clj:43)
    at clojure.lang.RestFn.invoke(RestFn.java:460)
    at clojure.tools.nrepl.middleware.session.proxy$java.io.Writer$ff19274a.write(Unknown Source)
    at java.io.PrintWriter.write(PrintWriter.java:456)
    at java.io.PrintWriter.write(PrintWriter.java:473)
    at clojure.core$fn__5471.invoke(core_print.clj:191)
    at clojure.lang.MultiFn.invoke(MultiFn.java:231)
    at clojure.core$pr_on.invoke(core.clj:3392)
    at clojure.core$pr.invoke(core.clj:3404)
    at clojure.lang.AFn.applyToHelper(AFn.java:154)
    at clojure.lang.RestFn.applyTo(RestFn.java:132)
    at clojure.core$apply.invoke(core.clj:624)
    at clojure.core$prn.doInvoke(core.clj:3437)
    at clojure.lang.RestFn.applyTo(RestFn.java:137)
    at clojure.core$apply.invoke(core.clj:624)
    at clojure.core$println.doInvoke(core.clj:3457)
    at clojure.lang.RestFn.invoke(RestFn.java:408)
    at clojure.main$repl_caught.invoke(main.clj:158)
    at clojure.tools.nrepl.middleware.interruptible_eval$evaluate$fn__7569$fn__7582.invoke(interruptible_eval.clj:76)
    at clojure.main$repl$fn__6634.invoke(main.clj:259)
    at clojure.main$repl.doInvoke(main.clj:257)
    at clojure.lang.RestFn.invoke(RestFn.java:1096)
    at clojure.tools.nrepl.middleware.interruptible_eval$evaluate$fn__7569.invoke(interruptible_eval.clj:56)
    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.tools.nrepl.middleware.interruptible_eval$evaluate.invoke(interruptible_eval.clj:41)
    at clojure.tools.nrepl.middleware.interruptible_eval$interruptible_eval$fn__7610$fn__7613.invoke(interruptible_eval.clj:171)
    at clojure.core$comp$fn__4192.invoke(core.clj:2402)
    at clojure.tools.nrepl.middleware.interruptible_eval$run_next$fn__7603.invoke(interruptible_eval.clj:138)
    at clojure.lang.AFn.run(AFn.java:22)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)
REPL-y 0.3.2, nREPL 0.2.0-beta5NoSuchMethodError clojure.tools.nrepl.StdOutBuffer.length()I  clojure.tools.nrepl.middleware.session/session-out/fn--7630 (session.clj:43)NoSuchMethodError clojure.tools.nrepl.StdOutBuffer.length()I  clojure.tools.nrepl.middleware.session/session-out/fn--7630 (session.clj:43)#<Namespace user>Exception in thread "nREPL-worker-2" java.lang.NoSuchMethodError: clojure.tools.nrepl.StdOutBuffer.length()I
    at clojure.tools.nrepl.middleware.session$session_out$fn__7630.doInvoke(session.clj:43)
    at clojure.lang.RestFn.invoke(RestFn.java:460)
    at clojure.tools.nrepl.middleware.session.proxy$java.io.Writer$ff19274a.write(Unknown Source)
    at java.io.PrintWriter.write(PrintWriter.java:456)
    at java.io.PrintWriter.write(PrintWriter.java:473)
    at clojure.core$fn__5471.invoke(core_print.clj:191)
    at clojure.lang.MultiFn.invoke(MultiFn.java:231)
    at clojure.core$pr_on.invoke(core.clj:3392)
    at clojure.core$pr.invoke(core.clj:3404)
    at clojure.lang.AFn.applyToHelper(AFn.java:154)
    at clojure.lang.RestFn.applyTo(RestFn.java:132)
    at clojure.core$apply.invoke(core.clj:624)
    at clojure.core$prn.doInvoke(core.clj:3437)
    at clojure.lang.RestFn.applyTo(RestFn.java:137)
    at clojure.core$apply.invoke(core.clj:624)
    at clojure.core$println.doInvoke(core.clj:3457)
    at clojure.lang.RestFn.invoke(RestFn.java:408)
    at clojure.main$repl_caught.invoke(main.clj:158)
    at clojure.tools.nrepl.middleware.interruptible_eval$evaluate$fn__7569$fn__7582.invoke(interruptible_eval.clj:76)
    at clojure.main$repl$fn__6634.invoke(main.clj:259)
    at clojure.main$repl.doInvoke(main.clj:257)
    at clojure.lang.RestFn.invoke(RestFn.java:1096)
    at clojure.tools.nrepl.middleware.interruptible_eval$evaluate$fn__7569.invoke(interruptible_eval.clj:56)
    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.tools.nrepl.middleware.interruptible_eval$evaluate.invoke(interruptible_eval.clj:41)
    at clojure.tools.nrepl.middleware.interruptible_eval$interruptible_eval$fn__7610$fn__7613.invoke(interruptible_eval.clj:171)
    at clojure.core$comp$fn__4192.invoke(core.clj:2402)
    at clojure.tools.nrepl.middleware.interruptible_eval$run_next$fn__7603.invoke(interruptible_eval.clj:138)
    at clojure.lang.AFn.run(AFn.java:22)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)


Error loading namespace; falling back to userNoSuchMethodError clojure.tools.nrepl.StdOutBuffer.length()I  clojure.tools.nrepl.middleware.session/session-out/fn--7630 (session.clj:43)NoSuchMethodError clojure.tools.nrepl.StdOutBuffer.length()I  clojure.tools.nrepl.middleware.session/session-out/fn--7630 (session.clj:43)user=> 

google了一番原来是leiningen2.4.3的一个BUG:https://github.com/technomancy/leiningen/issues/1625

解决方法:将其回退到2.4.2版

y@y:~$ lein downgrade 2.4.2
Downloading Leiningen to /home/y/.lein/self-installs/leiningen-2.4.2-standalone.jar now...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   355    0   355    0     0    320      0 --:--:--  0:00:01 --:--:--   320
100 13.2M  100 13.2M    0     0   432k      0  0:00:31  0:00:31 --:--:--  611k
The script at /usr/bin/lein will be upgraded to the latest 2.4.2 version.
Do you want to continue [Y/n]? Y

Upgrading...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   136    0   136    0     0    123      0 --:--:--  0:00:01 --:--:--   123
100 11871  100 11871    0     0   2603      0  0:00:04  0:00:04 --:--:--  7693
mv: 无法将"/tmp/lein-12771-upgrade" 移动至"/usr/bin/lein": 权限不够
Leiningen 2.4.2 on Java 1.7.0_55 Java HotSpot(TM) 64-Bit Server VM

5:再次运行lein repl 成功

y@y:~$ lein repl
nREPL server started on port 33169 on host 127.0.0.1 - nrepl://127.0.0.1:33169
REPL-y 0.3.1
Clojure 1.6.0
    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=> 

输出helo,world

user=> (println "Hello,world!")
Hello,world!
nil
user=> 

 

posted @ 2014-08-30 13:40 yshy 阅读(...) 评论(...) 编辑 收藏