How to change Clojure or Lein's Clojure default version? - clojure

I'm not sure why but when I enter the REPL through $ clojure or $ lein repl, >(clojure-version) says '1.2.1'. I want it to say '1.5'.
Version 1.5 works fine in my projects managed by lein. I just want to tell lein to always use 1.5 by default, instead of 1.2.

Currently this isn't supported outside a project, but it's being worked on: https://github.com/technomancy/leiningen/issues/966
A workaround for now is just to specify it in your project.clj
Further recommendation: upgrade to Leiningen 2.0.

Related

In LightTable, how do you change Clojure version?

Currently I am using LightTable to run clojure projects, and with Leiningen I can specify a version for a project. However, for .clj files that are not part of a project, it seems the LightTable REPL says the clojure version is 1.5.1.
I would like to set it to 1.7.0 for all .clj files, is there a way to do this?
It is described in LightTable FAQ:
How do I set the default Clojure version when running Instarepl outside of the context of a Clojure project?
Update plugins/clojure/runner/resources/project.clj by adding/changing :dependencies [[org.clojure/clojure "x.x.x" ]] where x.x.x is of course the Clojure version you want to use by default in your Instarepl sessions whenever LightTable doesn't run in the context of a Clojure project (i.e. double clicking on a shortcut on the desktop to run LightTable).
Per http://docs.lighttable.com/#plugins-directory, running the command App: Light Table version to get plugin directory.

Pressing arrow keys do not work correctly in Clojure console

I downloaded the Clojure jar. Its version is 1.6.0.
When I run Clojure in console I press arrow keys but they don't move the cursor but produce these characters "[[D^[[C.
I start Clojure using this command:
java -cp clojure-1.6.0.jar clojure.main
using Java 1.7.0_55 64 bit on Ubuntu 14.04 LTS 64 bit.
How can I get back normal arrow keys behaviour ?
The repl bundled with Clojure is pretty terrible. But that's okay, because you want to install Leiningen anyway, and its repl is much better, including the various readline stuff you're used to.
But in general, if there's some app that does a terrible job of being a repl, you can always use rlwrap to wrap the app in readline.
You are following hopelessly outdated instructions/tutorials. The generally accepted way to interact with all things clojure is through Leiningen. Then start Clojure by running:
lein repl
You can create a new web project by running:
lein new compojure my-project-name
or a new general project by running:
lein new my-project-name

Does Leiningen require a JDK/JRE?

I've tried to install Leiningen according to the official installation instructions. When running lein repl I get the following error message:
/usr/local/bin/lein: line 315: java: command not found
This leads me to believe that Leiningen requires a JDK/JRE to actually run but there is no mention of it in the docs. So, do I first need to install a JDK/JRE?
Yes, see installation instruction https://github.com/technomancy/leiningen#installation
Yes, you need to install JDK first.
Instruction for Windows installation is here
Leinengen comes packaged as a JAR file with a small bash script wrapping it, allowing for easy command line usage. This means that, like any other clojure or java program, it require the JVM to be run.
If you take a look at ~/.lein/self-installs/ you will see the JAR file(s) leiningen utilizes to run it's tasks.
One thing worthy of noting as well is that Leiningen starts its own JVM process before creating a new JVM process for your clojure program. They are not run in the same JVM container (to enforce isolation). Also, this initial Leiningen JVM process will not close until your clojure program has finished running as well (unless you utilize the trampoline).
As always, it's worth reading through the Leiningen docs at some point to better learn about what leiningen is truly doing. Hopefully that helps... happy coding!

Can't open clojure the project in Intellij IDEA with La Clojure

I was going through this tutorial
http://wiki.jetbrains.net/intellij/Getting_started_with_La_Clojure and I got stuck here
http://wiki.jetbrains.net/intellij/Getting_started_with_La_Clojure#Opening_project_in_IntelliJ_IDEA. I don't know way but 'open project' dialog does show the file 'project.clj'. So I'm not able open the clojure project. (And also I don't know how to create new one)
Is this bug of IDEA/La clojure or I did something wrong?
To open/import clj projects, you need to have the Leiningen plugin installed.
Unfortunately, the latest official release of the lein plugin for intellij doesn't work well with Intellij13 (crashed my idea on load every time until removed manually).
I'm guessing that because of Cursive there wasn't a newer release even though the latest version of the plugin on github does work.
I followed the instructions on the lein plugin's git page to create a plugin bundle from the latest version: https://github.com/derkork/intellij-leiningen-plugin
Assuming you're using Intellij13, creating the bundle yourself and then installing it from disk will enable you to open clj project files.

Cannot get clojure-contrib sql to load - FileNotFoundException

I installed clojure and clojure contrib manually, through homebrew and mac ports all of them gives me this error.
I can get other parts to work.
What gives?
edit
this question seems similar
Can not get clojure-contrib to load - FileNotFoundException
However i can load some parts, and i install through ports/brew so the versions should be in sync
It's better to use clojure & clojure-contrib not directly, but through some project, for example, managed by leiningen - it will fetch correct versions of clojure & clojure-contrib, plus some other dependencies that you're specify. You can also look onto my Lein introduction article on this topic
Well I couldn't make it work through fiddling with jars or using macport or homebrew.
But leiningen solved the problem for me.
To see the solution i came up with see:
https://github.com/khebbie/PET
also this article helped a lot:
http://pragprog.com/magazines/2011-07/create-unix-services-with-clojure