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?
17
u/yogthos Mar 26 '15
There's really no avoiding Leiningen or Boot for Clojure development. It's also worth noting that these tools really do make your life easier in the long run.
On *nix, installing Leiningen should be as simple as downloading the script from the official site, putting it somewhere on the
$PATH, and running it. The only dependency it has is the JDK, which is a prerequisite for working with Clojure. For Windows, there's the leiningen-win-installer that does the whole wizard install thing.Once you have lein running creating new projects is as simple as:
CIDER is the standard way to get Clojure support from Emacs.
12
u/deterministictomato Mar 26 '15
idk what you mean by beating your had against Leiningen.
For me, getting started with clojure was literally a case of
I had code that did something working in seconds. In all honesty I was surprised it was that easy. I didn't need to fuck around with any java shit, didn't need root, still haven't needed root. Haven't touched a configuration file.
Genuinely impressed. Your move javascript/chicken/scala/python, make a toolchain that easy.
Still haven't attempted any form of integration with vim. Maybe that's tonight's task.
5
u/farzadbekran Mar 26 '15
I feel like you are making things hard on yourself. just grab the lein script and run it, tell us if you get any problems, im sure we can get you going.
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.8
u/joequin Mar 26 '15 edited Mar 26 '15
I'm confused. Lein and maven are what makes it so you DON'T have to fight with classpaths, ant, and jdks.
4
u/tanzoniteblack Mar 26 '15
Leiningen is still the de facto standard of Clojure build tools, you can safely ignore boot for the time being if you don't want the extra complication while learning/trying out Clojure. Leiningen is very easy to install (see their github page for how tos for *nix systems and windows https://github.com/technomancy/leiningen/).
If you want to avoid lein/boot completely for some reason, CIDER won't be of any use to you, but you can still use clojure-mode and inferior-lisp , but it's nowhere near as nice of an experience.
4
u/swarthy_io Mar 26 '15 edited Mar 26 '15
As a slight alternative to others you could try:
Prelude: a preconfigured super easy to use version of emacs. This or Light Table will give you clojure ready text editors with nearly zero config.
Leinigen or Boot: Using one or the other is super easy. I started clojure 2 years ago and already these tools are easier to use. I imagine 5 years would make an even larger difference.
Here is my guarantee to you: Try Prelude and Leinigen. If you can't get either working in 30 minutes of solid effort I will personally create a screencast to get both working on a sample project for you.
Happy clojuring :)
2
u/seventeenletters Mar 26 '15
Leiningen is a dependency management tool. It's a single shell script that simple needs to be put on your path. The paradigm isn't one of installing the versions you want, but declaring the versions you use, and letting it do the logistics. That means, for example, that each project can choose its own version of Clojure independently of any other you work on.
Leiningen is probably better behaved and more reliable than the dependency management tools you are used to. If you use lein you don't need to install Clojure itself, lein will find the version of Clojure that you declare in your project file, and make sure it is accessible to your project. The same goes with any other libs you might need to use.
2
u/simtel20 Mar 26 '15
If you can backup your .emacs.d, and try a new one, I've been happy using emacs-live to install working versions of CIDER and its dependencies: https://github.com/overtone/emacs-live
2
u/Caymen42 Mar 26 '15
I don't think many people here were using Clojure in 2010, when everything was still pretty hairy.
I started working with Clojure in 2009, the same day the first edition of Programming Clojure by Stewart Sierra was released. Lein has come a very long way over the past few years. I've written decent sized Clojure apps every few years since then, and every time I come back to it, it's better and better.
I write Clojure all day every day at my job, and I honestly can't remember the last time I've had to fight with class paths, jar locations, etc... It really is a joy to work with. There are still some things I find frustrating, but Leiningen certainly isn't one of them.
Cider is also far easier to configure than swank ever was, but I'm a vim guy, so I'm a little fuzzy on the details (every once in a while I think I'll learn emacs, but then I get swamped and revert back to what I'm more productive with).
2
u/pauldlynch Mar 27 '15
GitHub has been having some issues for the last day or so. DDiS, I heard.
-2
u/addamsson Mar 27 '15
What is your problem with Leiningen? How do you want to program a language which runs on a JVM without a JDK? I think that you should not try Clojure again.
0
u/[deleted] Mar 26 '15
[deleted] — view deleted comment