From Clojure project directory, M-x cider-jack-in starts the nREPL server and the Cider REPL. in the latter:
(clojure.tools.logging/info "hello") does not output anything in the server buffer,
but (clojure.tools.logging/warn "hello") does.
am i missing a configuration? very new to Clojure development...
Related
I'm trying to figure out how to run lein ring server for a Clojure Ring and Compojure application in Eclipse Mars with Counterclockwise on Windows.
I've added the correct dependencies to my project.clj file. Running this command from a command line works without any trouble.
However, if I type it into the repl inside eclipse I get the error : "CompilerException java.lang.RuntimeException: Unable to resolve symbol: lein in this context"
Is there a way to run lein ring server from within Eclipse?
I'm very new to Clojure development and hoping I'm just missing something simple here.
You can run lein commands like this http://doc.ccw-ide.org/documentation.html#lein-generic-launcher .
Trying to run lein commands in repl is wrong as leiningen is build tool, and works like any other console program.
If you want to start ring server from repl you can, to do that you need to switch to namespace where you start ring server and start it, by evaluating server start code in repl. It's described at ring wiki https://github.com/ring-clojure/ring/wiki/Getting-Started , in the pretty much like this
(run-jetty handler {:port 3000})
Also I suggest to take a look at https://github.com/plexus/chestnut (app template) so your start server from repl will look like this
(run-web-server)
assuming you have method like this
(defn run-web-server [& [port]]
(let [port (Integer. (or port (env :port) 10555))]
(println (format "Starting web server on port %d." port))
(run-jetty http-handler {:port port :join? false})))
I started using Clojure with leiningen (and now boot).
Now I sometimes want to get quickly to a Clojure{Script} CIDER REPL in Emacs to execute just a few instructions. I don't want to create a project.clj file for that, since I just want a throwaway REPL.
Is there a way to get a Clojure REPL, for instance in the *scratch* buffer ?
well, you can execute M-x cider-jack-in anywhere you want, even with no project.clj in path. This works for me.
You can just type lein repl in the friendly console / shell / terminal right next to you -- no project.clj required. This will start a REPL as expected, to which you can then connect from Emacs via M-x cider-connect (which in recent versions will handily suggest host and port to connect to).
M-x cider-jack-in basically does the same thing (i.e. lein repl) behind the scenes.
I'm not a boot user, but according to the boot wiki for leiningen users it should be possible to call boot repl -s.
Use M-x cider-jack-in, and if you don't want it to warn you that you're running cider-jack-in without a Clojure project, add the following to your emacs.d/init.el:
(setq cider-allow-jack-in-without-project t)
Newbie Clojure programmer here. NREPL in Emacs isn't working for me.
Aquamacs 2.5 (Emacs 23.4.1)
nrepl.el 0.1.8
Leiningen 2.2.0 on Java 1.6.0_51 Java HotSpot(TM) 64-Bit Server VM
My project is just the lein-generated Hello World.
Running "lein repl" in a shell works, but nrepl.el doesn't work.
Rather than winding up in the project's namespace in the repl,
I just get the default toplevel in the "user" namespace.
Should see something like:
my$ lein repl
nREPL server started on port 57347
REPL-y 0.2.0
Clojure 1.5.1
Hello Project
my.core=>
But instead see:
; nREPL 0.1.8-preview
user> (in-ns my.core)
CompilerException java.lang.ClassNotFoundException: my.core, compiling:(NO_SOURCE_PATH:1:1)
user>
In a clean nrepl.el scenario, I see two java processes going and they look plausible. One has my project on the -classpath and is implementing the actual repl (server), while the other is the client side java (-D MyProjectPath -m leiningen.core.main repl :headless).
I get the same lossage whether I get there by m-x nrepl-jack-in or starting in the shell and then m-x nrepl. I get a repl that doesn't know my project.
I wonder if this stuff works for anyone, or if I have something installed or set up wrong? Lots of "0.xxx" versions of things going on here...
Looks like you are missing a quote before your namespace, try the following:
(in-ns 'my.core)
Note the ' before my.
NRepl always starts in the top-level user namespace. Use M-x nrepl-set-ns, or C-c M-n in a Clojure buffer, to set the namespace of NRepl to the one of the buffer.
In your specific case,
visit src/my/core.clj, press C-c M-j to start NRepl,
switch back to the src/my/core.clj buffer,
press C-u C-c C-z to set the NRepl namespace to my.core and switch back to the NRepl buffer.
C-u C-c C-z is a shortcut for C-c M-n followed by C-c C-z to switch to the NRepl buffer.
I found this website which explains how to use emacs with leiningen, swank, and slime. Is there a way to use slime + swank in non-leiningen projects i.e. how can I connect to slime/swank repl to run a ad-hoc Clojure script while I write it as demonstrated here?
You need to have swank-clojure.jar in CLASSPATH and your script should have following code:
(require 'swank.swank)
(swank.swank/start-repl 4005)
to start swank process on port 4005 (or some other)...
P.S. You can look onto Incanter's swank script, that pass this code in environment variable, and later it evaluated as part of boostrap script
My superficial understanding is that 'swank-clojure' makes 'M-x slime-connect' possible. I mean, it gives a connection to a clojure server something like 'lein swank'. Is my understanding correct? If not, what's the purpose of swank?
Then, is there any 'swank-SOMETHING_ELSE' for other lisp like implementations? For example, swank-clisp?
Do I need 'swank-clojure' for using SLIME/Clojure with 'M-x slime'?
ADDED
I found this link pretty useful.
SLIME and swank form a client server architecture to run and debug lisp programs. SLIME is the emacs frontend and swank is the backend. In between they create a network socket and communicate by sending across messages (S-expressions). In short it is just an RPC mechanism between emacs and the actual lisp backend.
The fact that the slime and swank are separate, are connected over a network and communicate via rpc messages means that they can be anywhere. So, slime can connect to a remote host/port to swank. All other forms you see (lein swank etc etc) do the same. They start swank on a port allowing for a remote connection of slime.
swank-clojure is the clojure port of swank. originally swank-clojure came with a helper elisp file called swank-clojure.el. The job of this file was to enable manual setup of swank parameters like the classpaths, jvm parameters etc. Since other tools like lein came along later, swank-clojure.el was deprecated. But it still lives on at: http://github.com/vu3rdd/swank-clojure-extra and provides the M-x swank-clojure-project which enables starting swank on a lein project.
It should be noted that SLIME originated in (and is still being actively developed for) Common Lisp. Infact, the clojure port of swank only has a subset of the features enjoyed by the original SLIME/swank versions. SLIME exists for all major variants of Common Lisp. There is a partial port of it for Scheme48. There are some partial implementations available under the contrib directory.
If you know that swank is already running on a port, use slime-connect. If you just want to use slime on a project, swank-clojure-project and lein swank seem to be the way to go.
swank-clojure.el is deprecated. Don't use it.
You need slime.el and you need to have swank-clojure "1.2.1" in your dev-dependcies in your project.clj file.
Swank is basically a server that you use slime to connect to from emacs. It it passed, from emacs, what you want run by the Lisp process that it's running.
You should use M-x slime-connect to connect to a swank server after starting with with lein swank.
Swank is the server counterpart to swank clients like emacs SLIME and the MCLIDE lisp development environment for Macintosh. Swank servers exist for many Common Lisp implementations and Lisp dialects such as Clojure and Gambit/scheme.
My understanding is that slime is the emacs part(the client), swank is the common lisp part(the server), swank-clojure is the clojure implementation of the swank server, not the original.