Datomic has a repl binary in bin/repl, how can I use this repl from within sublime text via sublime REPL?
This question is similar to this one: How to run existing Clojure programme in Sublime REPL but slightly different
Related
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.
I've been working with Clojure for few weeks now, primarily with Lein+Luminus framework. I've been looking for a way to debug code while on the REPL.
I really like the way how pry(on Ruby) works, when it comes to debugging and runtime invocation. Is there an equivalent to pry for clojure code? or probably a technique/tool that I've missed?
There are two paths to consider to improve your REPL and debugging experience:
Using a REPL and debugger integrated with your editor or IDE of choice
Using an embedded nREPL server
The first is an essential part of setting up your local Clojure development environment and should be done regardless. The second option, using an embedded nREPL server, is closer in usage to how you would use a binding.pry call in your code since it gives you access to the running application, but it isn't used to stop execution at a certain point, but rather give you a REPL with access to your running application and it doesn't provide any additional debugging features on its own.
Editor/IDE with REPL and Debugger
Text editors like Emacs and Vim have excellent Clojure support (both for editing and interacting with a REPL), and most Java IDE's have Clojure support as well.
At this point (May 2015) I'd highly recommend trying Jetbrain's Intellij IDEA with the Cursive plugin because of its excellent support for debugging. You can use the free community edition of Intellij, and the Cursive plugin is (at this point) free as well.
Intellij IDEA
To install Cursive, you go into Intellij's settings, add the correct Cursive plugin repository for the version of Intellij you have, install Cursive, and restart the IDE.
Once Cursive is active, you can simply open an existing Leiningen project in Intellij via "File > Open...". To get a REPL running, click "Run > Edit Configurations" in the main menu. In the window that appears, click the "+" button at the top left and select "Clojure REPL > Local". I'd change the name of the run configuration from "Unnamed" to something like "REPL", but otherwise keep the defaults and press "OK" to save the run configuration.
Now you have a way to run a REPL set up for the project you've opened. You can now click "Run > Run 'REPL'" (or whatever you named that run configuration) for a normal REPL, or better yet click "Run > Debug 'REPL'" to boot up the REPL in a debug mode that allows you to use Intellij's debugging features to debug your Clojure code. Set break points, add breakpoint conditions, run code and inspect frames, variables, etc., like you would in any debugger.
In your case, you'd want to click "Run > Debug 'REPL'" and then execute in that REPL the code you use to boot up your application.
Embedded nREPL Server
The above approach assumes that you first start a Clojure REPL and then boot up your application. If instead you want to have your application boot up normally and then optionally get a REPL that lives inside the running Clojure program, using nREPL directly is your best option.
From its own README:
nREPL is a Clojure network REPL that provides a REPL server and client, along with some common APIs of use to IDEs and other tools that may need to evaluate Clojure code in remote environments.
You should follow these instructions to add a running nREPL server to your application, but here is the most important part:
=> (use '[clojure.tools.nrepl.server :only (start-server stop-server)])
nil
=> (defonce server (start-server :port 7888))
#'user/server
Once you have a running nREPL server as part of your Clojure application, you can attach to it using your editor or IDE of choice (each editor/IDE has a different way of doing this, but most expose a way to attach to a running REPL by providing the host (usually localhost) and the port on which an nREPL server is running), or by invoking Leiningen directly at the command-line like this:
lein repl :connect <port>
You can specify the <port> when you configure the nREPL server as shown above. It also prints it out when it starts.
clj-debugger is a basic REPL debugger which provides features pretty similar to those available in pry-debug. You might consider it as an alternative to using the debuggers available in tools like CIDER & Cursive.
debugging is a huge problem in clojure as we are not aware of where the error occurred as well. define this macro :
(defmacro dbg[x] `(let x# ~x to understand where the eroor is thrown
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
I'm trying to use SublimeREPL with Sublime Text 2 so that I can programme with Clojure. I have installed SublimeREPL using the package manager.
I go to
Tools > SublimeREPL > Clojure
and start a repl this seems to start fine, but whatever I type in and hit enter does nothing. It does not return anything not even an error.
I have Lein installed.
I am using a Windows PC
Has anyone had this problem?
Yes, I have had this trouble with versions 2 and 3. From what I can see, it's a known issue. I have also reported it on GitHub: https://github.com/wuub/SublimeREPL/issues/356
Also, this solution worked for me: Sublime Text, SublimeREPL, Clojure & Windows 8
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Clojure REPL readline like support
I am a clojure newbie. Today i installed it on my Arch box.
%pacman -Q|grep -i jdk
openjdk6 6.b22_1.10.3-1
%pacman -Q|grep -i clojure
clojure 1.2.1-2
clojure-contrib 1.2.0-3
then i run clj:
%clj
Clojure 1.2.1
user=> (+ 1 2)
3
All seems ok however i feel it is VERY difficult to use the clj interactive environment, where i cannot use
arrow key and so on.
What i really want to know is how i can config the clj interactive environment ?
Don't use repl via the command line, install any one of the ide plugins, emacs vim eclipse etc. they all come with integrated repl that way you can directly send statements from your source files to the repl. Plus all of them supports arrow keys history etc. (emacs does)
You already got two nice answers in comments, but this seems like a good chance to plug one of my projects, ClojureX:
https://github.com/citizen428/ClojureX
While developed for conveniently using Clojure on MacOS X, it also works well on Linux and even Windows with Cygwin. It will use rlwrap if it finds it installed and will fall back on the included JLine otherwise.