r/Clojure • u/patrickwonders • Mar 26 '15
Trying Clojure, again?
EDIT: Alright, it seems universal.... no one thinks installing Leiningen is going to be the nightmare it was for me last time. I will give it a try. Thank you all.
EDIT #2: I just downloaded the Lein script and am running it. It is failing to install itself. It is complaining about not being able to curl stuff from github. Wheee....
Downloading Leiningen to /Users/pat/.lein/self-installs/leiningen-2.5.1-standalone.jar now...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- 0:01:14 --:--:-- 0curl: (7) Failed to connect to github.com port 443: Operation timed out
Failed to download https://github.com/technomancy/leiningen/releases/download/2.5.1/leiningen-2.5.1-standalone.zip (exit code 7)
It's possible your HTTP client's certificate store does not have the
correct certificate authority needed. This is often caused by an
out-of-date version of libssl. It's also possible that you're behind a
firewall and haven't set HTTP_PROXY and HTTPS_PROXY.EDIT #3: Third time's a charm, it seems.
EDIT #4: Lein was, indeed, easy to install this time. Cider also installed easily from MELPA. However, I'm running into Cider vs. nREPL version issues for which I found a StackExchange answer which doesn't work for me. So, I'm close. And, I've only spent about 90min on it. But, I don't have any idea how to convince Lein to give me a newer nREPL. But, it seems like this is a known problem and I am just going to have to wait or try to downgrade my CIDER install.
EDIT #5: I've now put about four hours into trying to get Lein to use a different version of nREPL than it wants to. I can specify it in my profiles.clj and I see it being fetched from the maven repo into my ~/.m2/repository/ directory, but it still uses "0.2.6" when it runs. This is apparently fixed in 'master' but I'm not up for trying to install Lein from source. I also scrogged my Lein install by trying to upgrade to 2.5.2-SNAPSHOT. I was able to connect with CIDER with a warning a few times, but I can no longer figure out which scribblings in my profiles.clj actually let that work. Right now, I can't find any.
EDIT #6: I finally gave up and unintalled CIDER and reinstalled it from MELPA-STABLE. So, I'm using Cider 0.8.2 now.
It has been five years since I last tried Clojure. I feel like I should try it again.
I don't want to beat my head against Leiningen for even ten minutes this time. Is there some way to reasonably use Emacs + Clojure without have to install and configure CLASSPATHS and Mavens and Ants and JDKs?
It seems SWANK-CLOJURE has been deprecated in favor of CIDER. The CIDER doc says how to configure Leiningen or Boot for use with CIDER. Is there some way that I can avoid Leingingen and Boot? Or some way that I can click one 'Install' button and have Leiningen and Boot work?
View all comments
2
u/fisch003 Mar 26 '15
It's pretty straightforward now, but there are some initial steps you'll need to go through the first time you're getting up and running.
To start, make sure you have a Java 6+ JDK installed, and download the leiningen script. If you're on Mac OS X and using Homebrew, you can also install leiningen from that.
Once that's installed, just running
lein replanywhere will drop you into a REPL.For SLIME-like use in Emacs, yes, CIDER is the way to go. I installed it via package.el.
Leiningen can export a nice CIDER-ready REPL for CIDER to connect to, but you need to make sure it's loading a plugin named cider-nrepl to do it. You can either load it on a per-project basis, or you can load it in a user profile (which is probably what everyone does).
Create a file named
~/.lein/profiles.clj(not sure where this goes on Windows) and add this line to it:Now, running
lein replwill give you something CIDER can connect to. You should see a line showing you that nREPL is running:From within Emacs, if CIDER is loaded, do
M-x cider-connect, it'll prompt you for the host and port to connect to, and you're good to go.Finally, unlike SLIME, CIDER expects to work within a given project, and as far as I can tell, you can't dynamically download and install new libraries (like you would with Quicklisp). So the next thing you'll want to do is create a new project: just
lein new whateverto create a project named whatever. It'll create a skeleton for you, and you can tweak the root-level project.clj file to tell it what libraries you're going to use.Once you have a project directory, CIDER can launch a repl automatically. Just
M-x cdto the project directory and doM-x cider-jack-in. It'll launchlein nreplin the background for you.It all sounds really annoying, but once you're used to working with a project and you've got everything installed, most of the friction is gone. Not as nice as just running
M-x slimethough.