Upgrading to Leiningen 2
We’re using Leiningen for automating our internal Clojure project, and we are specifically using the latest-and-greatest Leiningen version 2.0.0-preview10 (as of this writing). I’d installed my previous version of Leiningen using homebrew and a nice easy brew install leiningen
command, but unfortunately the upgrade to version 2 isn’t the easy. After countless misfires (my system kept installing version 1.7), here’s the steps that finally got it done for me. [Note: I’m running Mac OS X 10.7.4]
1) Check where the folder of your current Leiningen installation is and rename it to stash it away.
Mine was located at ~/myusername/.lein
and you can confirm if yours is in the same spot with the following command in the terminal:
ls -a ~/
Use the mv
command to rename it:
mv ~/.lein ~/.lein1
2) If you previously installed it with homebrew, uninstall it
The following command in terminal will remove it:
brew uninstall leiningen
3) Create a new home for Leiningen right where the old one was.
In the terminal type:
mkdir ~/.lein
mkdir ~/.lein/bin
4) Grab the script that installs the latest version of Leiningen
You can view the script here. There are fancy command line ways to curl
or wget
the script from the URL, or you can just use ‘Save As’ from your browser. Either way, it needs to be saved into the newly created ~/.lein/bin
directory.
NOTE: If you save it from your browser then it will most likely add the .txt file extension. You can remove it/rename it using the command line:
mv ~/.lein/bin/lein.txt ~/.lein/bin/lein
5) Change the new 'lein’ file to be executable:
chmod 755 ~/.lein/bin/lein
6) Check your $PATH
You need to make sure that ~/.lein/bin is on your path before you try and run any 'lein’ commands. Check your current path in the terminal by typing $PATH
and enter. as long as you see something like /Users/yourusername/.lein/bin
then you are o.k. Otherwise open up your ~/.bash_profile
in a text editor and add the following line:
PATH=$PATH:$HOME/.lein/bin
Now, quit Terminal, open it back up, type $PATH and make sure that /Users/yourusername/.lein/bin
is there.
7) Fire it up
If steps 1 through 6 checked out then you should be good to go. You can punch in a command like lein repl
and it will go through the install process before firing up a repl.
Let me know if anyone hits any snags or has any tips.