对于我的一个CS课程,我们正在学习Clojure,为了做到这一点,我们当然需要设置我们的计算机以便他们可以运行Clojure。我教授的指示如下:
“如果你想要一个很好的Clojure IDE,我推荐以下内容:
安装Java Development Kit(JDK)最新版本
安装Leiningen:leiningen.org
安装IntelliJ IDEA。安装后,为Clojure语法高亮显示安装“Cursive”插件。“
首先,如果这对我有帮助,我就在macOS Sierra上。我已经安装了JDK,所以我直接进入第二步:安装leiningen。根据网站上列出的安装leiningen的说明,我下载了lein脚本,并将其移至〜/ bin。然后我尝试chmod a+x ~/bin/lein
并没有真正做任何事情,或者至少我没有被告知它做了什么。
leiningen.org的下一步是运行脚本,所以我使用./lein
运行,但是当我将lein
输入终端时,终端提示我:-bash: /usr/local/bin/lein: No such file or directory
。然后我尝试了一些不同的东西试图让lein工作,但最后我最终使用了brew install leiningen
,我本来应该做的,但完全忘了我已经安装了自制软件。
我真的不记得这是什么时候开始发生的,但每当我打开一个新的终端窗口时,我都会受到欢迎:
Last login: Tue Oct 18 16:46:04 on ttys000
.clojure.lein.swp: Permission denied
Michaels-MacBook-Air:~ Michael$
终端似乎工作得很好,但.clojure.lein.swp: Permission denied
真的很烦我,我无法弄清楚如何解决它。我已经尝试卸载leiningen但它似乎没有用。如果它有所帮助,这是我的终端历史,从我试图让莱宁根工作时:
389 cd /Users/Michael/Documents/
390 chmod a+x ~/bin/lein
391 chmod a+x ~/bin/lein.txt
392 chmod a+x /lein
393 chmod a+x ~ /lein
394 chmod a+x ~/lein
395 chmod a+x ~/Documents/lein
396 chmod a+x ~/Documents/lein.txt
397 ./lein
398 cd ~/bin
399 cd bin
400 ls
401 chmod a+x ~/Documents/lein.txt
402 chmod a+x ~/Documents/lein
403 lein
404 cd ~
405 pwd
406 (chmod a+x ~/lein)
407 (chmod a+x ~/lein.txt)
408 lein.txt
409 ./lein.txt
410 lein -version
411 lein help $TASK
412 lein
413 lein new app my-stuff
414 -o
415 ./lein
416 ./lein.txt
417 lein help
418 lein help $TASK
419 echo $PATH
420 (chmod a+x ~/lein)
421 lein
422 $echo $PATH
423 cd /bin
424 pwd
425 cd /usr/local/bin/
426 chmod a+x ~/bin/lein
427 chmod a+x /usr/local/bin/lein.txt
428 ./lein.txt
429 lein
430 lein
431 lein self-install
432 .//Users/Michael/.lein/self-installs/leiningen-2.7.1-standalone.jar
433 cd /Users/Michael/.lein/self-installs/
434 pwd
435 ls
436 ./leiningen-2.7.1-standalone.jar
437 sudo ./leiningen-2.7.1-standalone.jar
438 lein
439 echo $PATH
440 mkdr /Applications/clojure
441 mkdir /Applications/clojure
442 cd /Applications/clojure
443 sudo curl-o
444 sudo curl-O
445 sudo curl -O https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein
446 sudo chmod a+x lein
447 cd /etc/paths.d/
448 sudo vi clojure.lein
449 echo $PATH
450 sudo vi clojure.lein
451 echo $PATH
452 lein
453 lein repl
答案 0 :(得分:1)
从您的shell命令历史记录中,您看起来一直在以{root(clojure.lein
)编辑sudo vi clojure.lein
文件。关闭vi
并移除.clojure.lein.swp
文件(如果存在)(以root身份使用sudo
)。
答案 1 :(得分:0)
以下是设置使用Clojure lein
的基本环境的步骤。在Ubuntu linux上为新用户帐户执行。它应该在OSX上大致相同:
# Create a new user and login to the new account
> sudo adduser cljuser
Adding user `cljuser'
<snip>
~/cool/notes > sudo su - cljuser
# Starting with a new, empty user account. Define a useful alias
cljuser@brandy:~$ alias d="ls -ldF"
# Display where I have java installed on this computer
cljuser@brandy:~$ d /opt/*
lrwxrwxrwx 1 root root 11 Feb 1 2016 /opt/java -> jdk1.8.0_72/
drwxr-xr-x 8 alan alan 4096 Dec 22 2015 /opt/jdk1.8.0_72/
# Set up env var for java, and augment the path to find the java executable file
cljuser@brandy:~$ export JAVA_HOME=/opt/java
cljuser@brandy:~$ export PATH=${JAVA_HOME}/bin:${PATH}
cljuser@brandy:~$ java -version
java version "1.8.0_72"
Java(TM) SE Runtime Environment (build 1.8.0_72-b15)
Java HotSpot(TM) 64-Bit Server VM (build 25.72-b15, mixed mode)
# We will install the lein shell script launcher in ~/bin
cljuser@brandy:~$ mkdir ~/bin
cljuser@brandy:~$ d ~/bin
drwxrwxr-x 2 cljuser cljuser 4096 Oct 18 20:16 /home/cljuser/bin/
cljuser@brandy:~$ cd bin
cljuser@brandy:~/bin$ curl https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein > lein
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 12871 100 12871 0 0 48805 0 --:--:-- --:--:-- --:--:-- 48939
# We have the script, but need to make it executable
cljuser@brandy:~/bin$ d *
-rw-rw-r-- 1 cljuser cljuser 12871 Oct 18 20:16 lein
cljuser@brandy:~/bin$ chmod a+x lein
cljuser@brandy:~/bin$ d *
-rwxrwxr-x 1 cljuser cljuser 12871 Oct 18 20:16 lein*
# Update to path so lein will run from any location
cljuser@brandy:~/bin$ cd
cljuser@brandy:~$ export PATH=~/bin:${PATH}
cljuser@brandy:~$ which lein
/home/cljuser/bin/lein
# First time downloads the actual "lein" executable. 2nd & later runs skip the download
cljuser@brandy:~$ lein --version
Downloading Leiningen to /home/cljuser/.lein/self-installs/leiningen-2.7.1-standalone.jar now...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 605 0 605 0 0 928 0 --:--:-- --:--:-- --:--:-- 927
100 14.6M 100 14.6M 0 0 1583k 0 0:00:09 0:00:09 --:--:-- 2015k
Leiningen 2.7.1 on Java 1.8.0_72 Java HotSpot(TM) 64-Bit Server VM
cljuser@brandy:~$ lein --version
Leiningen 2.7.1 on Java 1.8.0_72 Java HotSpot(TM) 64-Bit Server VM
# We are in the home dir, but we could still run lein
cljuser@brandy:~$ d *
drwxrwxr-x 2 cljuser cljuser 4096 Oct 18 20:16 bin/
-rw-r--r-- 1 cljuser cljuser 8980 Oct 18 20:13 examples.desktop
# create a new Clojure project named "sample" and run it
cljuser@brandy:~$ lein new app sample
Generating a project called sample based on the 'app' template.
cljuser@brandy:~$ cd sample
# first run downloads some *.jar files
cljuser@brandy:~/sample$ lein run
Retrieving org/clojure/clojure/1.8.0/clojure-1.8.0.pom from central
Retrieving org/sonatype/oss/oss-parent/7/oss-parent-7.pom from central
Retrieving org/clojure/tools.nrepl/0.2.12/tools.nrepl-0.2.12.pom from central
Retrieving org/clojure/pom.contrib/0.1.2/pom.contrib-0.1.2.pom from central
Retrieving clojure-complete/clojure-complete/0.2.4/clojure-complete-0.2.4.pom from clojars
Retrieving org/clojure/tools.nrepl/0.2.12/tools.nrepl-0.2.12.jar from central
Retrieving org/clojure/clojure/1.8.0/clojure-1.8.0.jar from central
Retrieving clojure-complete/clojure-complete/0.2.4/clojure-complete-0.2.4.jar from clojars
Hello, World!
# 2nd & later runs skip download
cljuser@brandy:~/sample$ lein run
Hello, World!
# All finished! Enjoy!