OS X Setup¶
- Start a terminal
- Make sure Java is installed
- Get Leiningen installed
- Get Heroku installed (includes Git)
- Test installation
Starting a terminal¶
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 running Terminal.app, which is found under
/Applications/Utilities. 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.”
Making sure Java is installed¶
java -version in your terminal.
If Java is installed, you will see something like this in your terminal:
If Java is not installed, or the version number is less than 1.8 you can download it here Java Downloads
Click the Java download button.
Accept the license agreement, and download the version for Mac OS X.
Double-click the jdk-8u111-macosx-x64.dmg file in your Downloads directory and walk through the installer.
Leiningen is a tool used on the command line to manage Clojure projects.
lein, execute the following commands in your terminal. You will be prompted to enter your password.
curl https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein > lein sudo mkdir -p /usr/local/bin/ sudo mv lein /usr/local/bin/lein sudo chmod a+x /usr/local/bin/lein cd $HOME echo 'PATH=$PATH:/usr/local/bin' >> .bashrc source .bashrc
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.
Getting setup with Heroku¶
Heroku is the tool we will use in order to put your application online where others can see it.
First, we need to create an account. Go to Heroku and click the “Sign up” link.
You will be taken to a form where you can create an account. Fill out that form, and you will be sent an email with a link to click to continue the signup process.
After clicking on the link, you will be taken to another form where you will need to choose a password. Choose one and enter it twice.
After all that, go here and click “Download Heroku Toolbelt for Mac OS X”.
If you do not see this link, you can download the toolbelt from toolbelt.heroku.com.
This will download a .pkg file. Double-click it to install the Heroku Toolbelt and follow all prompts from the installation wizard. You will need your OS X account password to complete installation. If you are prompted to create an SSH key, say yes. It may also prompt you to install git. Once the Heroku Toolbelt is installed, go to your terminal and run the command
heroku login. You will be prompted for your email and password on Heroku. If you enter them and the command ends successfully, congratulations!
Testing your setup¶
You have set up Java, Leiningen, Atom, Git, and Heroku 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/heroku/clojure-sample.git
This will check out a sample Clojure application from GitHub, a central repository for lots of source code. Your terminal should look similar to this picture:
Then run the command:
This will put you in the directory with the source code for this sample bit of Clojure code. After that completes, run:
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, enter
(quit) to quit the REPL. (NOTE: you can also type
(exit) or press the Control button and D button on your keyboard together).
This should take you out of the Clojure REPL and back to your normal terminal prompt.
You should still be in the
Run this command:
There should be output about something being created. A URL will be displayed. Look at the following example:
Next, run the following commands:
git push heroku master heroku open
Enter “yes” if you are asked if you are sure you want to connect, like in the following image:
Your browser should open (and take a long time to load), and you should see a website like the following:
If your browser does not open after running
heroku open, start a browser and go to the URL displayed after you ran
Congratulations! That website is running code you have on your computer that you have uploaded. You have actually made a very simple Clojure app, and your computer is all set up to make more.