갈루아의 반서재

아래의 내용을 같이 실행하려면 일단 터미널이 설치되어 있어야 한다. 터미널 화면으로 진입하여 다음의 순서대로 따라해보자. 


자바 설치 여부 확인


터미널에  java -version이라고 입력한다. 자바가 설치되어 있지 않다면, 아래와 같이 보일 것이다. 

1
2
3
4
5
6
7
8
9
10
$ java -version
 
Command 'java' not found, but can be installed with:
 
apt install default-jre
apt install openjdk-11-jre-headless
apt install openjdk-8-jre-headless
apt install openjdk-9-jre-headless
 
Ask your administrator to install one of them.
cs

위의 명령문 중 하나를 이용해 자바를 설치한다. 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
(dominika)~$ apt install openjdk-11-jre-headless
E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?
 
root@133-130-107-97:~# apt install openjdk-11-jre-headless
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  ca-certificates-java java-common libavahi-client3 libavahi-common-data libavahi-common3 libcups2 libjpeg-turbo8 libjpeg8 liblcms2-2 libpcsclite1
  libxi6 libxrender1 libxtst6 x11-common
Suggested packages:
  default-jre cups-common liblcms2-utils pcscd libnss-mdns fonts-dejavu-extra fonts-ipafont-gothic fonts-ipafont-mincho fonts-wqy-microhei
  | fonts-wqy-zenhei fonts-indic
The following NEW packages will be installed:
  ca-certificates-java java-common libavahi-client3 libavahi-common-data libavahi-common3 libcups2 libjpeg-turbo8 libjpeg8 liblcms2-2 libpcsclite1
  libxi6 libxrender1 libxtst6 openjdk-11-jre-headless x11-common
0 upgraded, 15 newly installed, 0 to remove and 78 not upgraded.
Need to get 40.2 MB of archives.
After this operation, 186 MB of additional disk space will be used.
Do you want to continue? [Y/n]
cs

설치 후 다시  java -version을 입력하면 다음과 같이 설치된 자바의 버전을 확인할 수 있다.

1
2
3
4
(dominika) ~$ java -version
openjdk version "10.0.1" 2018-04-17
OpenJDK Runtime Environment (build 10.0.1+10-Ubuntu-3ubuntu1)
OpenJDK 64-Bit Server VM (build 10.0.1+10-Ubuntu-3ubuntu1, mixed mode)
cs


LEININGEN 설치


Leiningen 는 커맨드라인에서 클로져 프로젝트를 관리하기 위한 툴이다. 

Leiningen 웹사이트 (https://leiningen.org)로 가면, Install 아래에 lein 이라는 스크립트를 찾아볼 수 있다. 다른 이름으로 링크 저장을 눌러서 다운로드 디렉토리로 다운로드 받는다. 


다운로드 받은 후 터미널에서 다음과 같은 명령을 실행시킨다. 

1
2
3
4
5
6
7
8
9
10
11
12
13
~$ sudo curl https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein -o /usr/local/bin/lein
[sudo] password for fukaerii:
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 12463  100 12463    0     0  72459      0 --:--:-- --:--:-- --:--:-- 72459
 
~$ cd /usr/local/bin
/usr/local/bin$ ls -al
total 24
drwxr-xr-x  2 root root  4096 Aug  4 15:56 .
drwxr-xr-x 10 root root  4096 Apr 27 04:07 ..
-rw-r--r--  1 root root 12463 Aug  4 15:56 lein
 
cs

누구나 lein utility 를 사용할 수 있도록 퍼미션을 조정한다. 

1
2
~$ sudo chmod a+x /usr/local/bin/lein
[sudo] password for fukaerii:
cs

설치가 끝나고 lein version 명령을 쳐보면 2.8.1 버전이 설치되었음을 확인할 수 있다. 최초 실행시는 필요한 리소스를 다운받기 때문에 다소 시간이 걸린다. 

1
2
3
4
5
6
7
8
~$ export PATH=$PATH:/usr/local/bin
~$ lein version
Downloading Leiningen to /home/fukaerii/.lein/self-installs/leiningen-2.8.1-standalone.jar now...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   618    0   618    0     0    893      0 --:--:-- --:--:-- --:--:--   891
100 12.9M  100 12.9M    0     0  1374k      0  0:00:09  0:00:09 --:--:-- 2596k
Leiningen 2.8.1 on Java 10.0.1 OpenJDK 64-Bit Server VM
cs


셋업 테스트


이상으로 자바와 Leiningen 설치를 마쳤다. 몇 가지 테스트를 해보자. 터미널로 이동하여 다음과 같이 입력한다. 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
~$ lein repl
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 org/sonatype/oss/oss-parent/7/oss-parent-7.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 clojure-complete/clojure-complete/0.2.4/clojure-complete-0.2.4.jar from clojars
nREPL server started on port 43239 on host 127.0.0.1 - nrepl://127.0.0.1:43239
REPL-y 0.3.7, nREPL 0.2.12
Clojure 1.8.0
OpenJDK 64-Bit Server VM 10.0.1+10-Ubuntu-3ubuntu1
    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=>
cs

위는 클로져를위한 특별한 터미널 화면이다. (+ 1 1) 을 입력하고 엔터를 쳐보자. 2 라는 값을 얻었다면 정상적으로 작동하고 있는 것이다. 

1
2
3
4
 
user=> (+ 1 1)
2
 
cs

현재로서는 컨트롤 버튼과 D 버튼을 함께 누르면 (즉, Ctrl+D) 현재의 클로져 REPL 을 빠져나와 기본 터미널 화면으로 이동한다는 정도만 알아두자.

1
2
3
4
 
user=> Bye for now!
~$
 
cs