- Start a terminal
- Install Git
- Configure Git
- Make sure Java is installed
- Install Leiningen
- Install Light Table
- Test your setup
For these instructions, and for much of the class, you will need to have a terminal, or command line, open. This is a text-based interface to talk to your computer, and you can open it by clicking "Dash Home" and typing Terminal
. You can also open a terminal at any time by pressing CTRL-ALT-T
. If you have never used the terminal before, you may want to spend some time reading up on command-line basics.
Go ahead and open your terminal now. It should look something like this:
The prompt (where you will type your commands) may look different: it usually shows the computer name and user name, as well as the folder or directory you are currently in.
For the rest of this setup, I will tell you to run commands in your terminal. When I say that, I mean "type the command into the terminal and press the Return key."
See if you already have Git installed with git version
.
If the git
command is not found, install it with this command in the terminal:
sudo apt-get install git`
If you've used Git before then you should already have user.name and user.email configured. Otherwise, type this in the terminal:
git config --global user.name "Your Actual Name"
git config --global user.email "Your Actual Email"
TIP: Use the same email address for git, github, and ssh.
Verify by typing this in the terminal:
git config --get user.name
Expected result:
your name
git config --get user.email
Expected result:
your email address
Run java -version
in your terminal. If you do not have Java installed, Ubuntu will prompt you to install it. It should look something like this:
Follow all of the directions Ubuntu gives you, selecting the package "openjdk-7-jre" then return to this part of the tutorial and run java -version
again.
If Java is installed, you will see something like this in your terminal:
The details of Java's version may differ from what you see above; that is perfectly fine.
Leiningen is a tool used on the command line to manage Clojure projects.
Go to the Leiningen website. You will see a link to the lein
script under the "Install" heading. Right-click that link and choose "Save Link As...". Save it in your Downloads directory.
After that, run the following commands in your terminal. You will be prompted to enter your password.
sudo mkdir -p /usr/local/bin/
sudo mv ~/Downloads/lein* /usr/local/bin/lein
sudo chmod a+x /usr/local/bin/lein
export PATH=$PATH:/usr/local/bin
After you run the above commands, run the lein version
command. It should take a while to run, as it will download some resources it needs the first time. If it completes successfully, you are golden! If not, ask an instructor for help.
LightTable is only available for 64-bit version of Ubuntu (or you can build it from source for 32-bit Linux). To find out if you have 64-bit Ubuntu, click Dash Home and type Details. You should see a window like this:
Alternatively, open your terminal and type uname -m
if the output says "x86_64" you have a 64-bit OS, if it says "i686" you have a 32-bit OS.
Go to the Light Table site and click the "Linux64" button and select the "Save file".
Open up your terminal and cd to the directory where your downloads go cd ~/Downloads
.
Check to see that your file is there. ls
Extract the compressed file tar -xzf LightTableLinux64.tar.gz
Check to see that there is now a directory called LightTable ls
Move the LightTable directory to "/usr/local/bin" sudo mv LightTable /usr/local/bin
Set your path so you can launch LightTable from the command line export PATH=$PATH:/usr/local/bin/LightTable
Launch LightTable LightTable
If you want, you can create a launcher for Light Table. sudo gnome-desktop-item-edit /usr/share/applications/ --create-new
You should see a window like this:
Name the launcher LightTable. Type the path to the command /usr/local/bin/LightTable/LightTable
. Click the icon. The LightTable icon can be found at /usr/local/bin/LightTable/core/img/lticon.png
.
If you'd prefer, you can open files/folders in LightTable from the command line by typing light-table /path/to/the/file/you/want/to/open.clj
.
You have set up Java, Leiningen, Light Table, and Git on your computer--all the tools you will need for this course. Before starting, we need to test them out.
Go to your terminal and run the following command:
git clone https://github.com/ClojureBridge/welcometoclojurebridge
This will clone welcometoclojurebridge
repository which includes sample Clojure apps.
Your terminal should look similar to this picture:
Then run the command:
cd welcometoclojurebridge
This will take you to the directory with the source code. After that completes, run:
lein repl
This could take a long time, and will download many other pieces of code it relies on. You should see lines that start with Retrieving ...
on your screen. When it finishes, your terminal should look like the following:
This is starting a REPL, which we will learn about soon. It's a
special terminal for Clojure. At the REPL prompt, type (+ 1 1)
and
press Return. Did you get the answer 2
back? You will learn more
about that in the course. For now, press the Control button and D
button on your keyboard together (abbreviated as Ctrl+D). This should
take you out of the Clojure REPL and back to your normal terminal
prompt. Then, the terminal will show you the following message: user=> Bye for now!
Now we will open and run the sample Clojure apps in Light Table, so start Light Table
In Light Table, click on the menu "File" then choose "Open Folder." Find the
directory, welcometoclojurebridge
, which was created when you ran
git clone
command. Click "Upload." In the workspace menu on the
left, click on welcometoclojurebridge
- src
-
welcometoclojurebridge
- core.clj
. Double-click the core.clj
file
to open it. This is a Clojure program.
Click on the file contents and press the following key combination:
Ctrl + Shift + Enter
You should see a fun welcome message.
Next, in the workspace menu on the left, click on
welcometoclojurebridge
- src
- clojurebridge-turtle
-
walk.clj
. Double-click the core.clj file to open it.
press the following key combination:
Ctrl + Shift + Enter
An initial image of the turtles app will pop up.
Type (forward 40)
at the end of the walk.clj
and press the
following combination:
Ctrl + Enter
You should see this on the Light Table:
also, your turtle should move.
Pressing the Control button and Space Bar together (abbreviated
Ctrl+Space
) is how you start giving Light Table a command.
Congratulations! You have opened and run your first Clojure apps, and your install and setup are all completed!