:repl-options dont reflect in the ritz nrepl client in emacs - clojure

I am using the :repl-options key in my project.clj to load default options when I start repl using lein2 repl.
I have added ritz plugins to my project.clj and ~/.lein, and once I start the repl using -
a) lein2 repl
and then connect to it using
b) M-x nrepl RET Host: localhost RET Port: 5332 (Port number on which nrepl started in the first step)
The ns that I load using :repl-options are avalaible in the repl that starts using lein2 repl, however they are not avalaible in the client started using M-x nrepl.
Any ideas on how do I get them in the client started by M-x nrepl too ?

Frankly I think that it is best to ask Leiningen related questions on its mailing list. I had an issue with Leiningen recently and Phil Hagelberg, developer of the tool, responded almost instantly.
You could also ask about https://stackoverflow.com/questions/12493003/unmateched-delimiter-exception-but-still-able-to-run-code. I have similar issues with Lein2 (only in Cygwin), so maybe it will result in a bug report.

Related

Launch cljs nREPL connected to lein project template

I have created a ClojureScript project using:
lein new re-frame my-project
I've then opened it in IntelliJ using Cursive. In the terminal after typing lein dev, it prompts me with the message:
shadow-cljs - HTTP server available at http://localhost:8280
shadow-cljs - server version: 2.8.52 running at http://localhost:9630
shadow-cljs - nREPL server started on port 8777
shadow-cljs - watching build :app
[:app] Configuring build.
[:app] Compiling ...
[:app] Build completed. (203 files, 1 compiled, 0 warnings, 3.65s)
I can open the server using the link which directs me to a REPL, but not the nREPL connected to the browser. Following their documentation I type shadow-cljs clj-repl in to another terminal, which opens a REPL but not one that is connected to my browser or project. If I type (js/alert "hi m8") in to the REPL it responds:
Syntax error compiling at (REPL:2:1).
No such namespace: js
My question is, is how do I use the nREPL it says has started and preferably how do I access it in the integrated REPL in IntelliJ?
Thanks.
Update
Have got it working as below but if anyone knows how to get it working here in Cursive / IntelliJ:
That would be super.
The nREPL connection will always start out in Clojure mode. You can switch it to use CLJS by calling (shadow.cljs.devtools.api/repl :app) and return to Clojure mode via :cljs/quit.
You should however be connecting to a "Clojure REPL" -> "Remote" and then "localhost" with port 8777. This is configured as the default in the re-frame template via shadow-cljs.edn :nrepl {:port 8777}.
The screenshot you posted looks like you connected to the random port lein created. This will also work but requires additional configuration for the nREPL middleware.
I figured it. You have to use shadow-cljs cljs-repl app in another terminal.

problems installing clojure lein under mac os 10.13.6

I am using Homebrew with the command brew install leiningen but trying lein repl gives
java.lang.ClassCastException: java.lang.Character cannot be cast to java.uti
l.Map$Entr
followed by many pages ending with
clojure.main.main (main.java:37)
the same happens with Macports or supplied script, boot installs perfectly with Homebrew.
I am learning Clojure from the Brave and True book which needs lein repl
To "install" lein just download the download script from the web page and run it :
https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein
Hope it helps
Consider using sdkman, even if leiningen is straightforward to use:
curl -s "https://get.sdkman.io" | bash
Then open a new terminal and type:
sdk install leiningen
Now try your:
lein repl
While you're at it, sdk can be used to manage your Java installations. Never again worry about dirtying your system with various versions, as they all go in your home directory, cleanly.

How to compile namespace in remote REPL

I have a problem compiling .clj files which reside in a project where I run the nREPL server process:
I've created a new project using lein new xxx.
In the project folder I started up an nREPL by lein repl.
In another terminal window I started a client lein repl :connect localhost:12345/repl.
I created a simple namespace file and saved it inside the project in the appropriate location:
(ns remote.one)
(def foo 42)
Now on the client terminal I called this function
(compile 'remote.one)
I've got the below exception:
CompilerException java.lang.ClassNotFoundException: remote.one, compiling:(C:\Users\xxx\AppData\Local\Temp\form-init2429492334116477513.clj:1:1)
Now I would have expected the compile call to be executed in the server not on the client. Can it be done at all?
Thanks
I just tried it and it worked for me. What happened the first time I tried it was that I missed a step: setting the current directory as the project's. I see that this step is also missing from your description, maybe that's the reason it doesn't work in your case.
Create a new project using lein new remote.
Change the current directory cd remote.
Start the nREPL server from the project folder with lein repl :headless (which I realize now is also different from your description).
Open a new console and start the nREPL client lein repl :connect localhost:port/repl in ~/..
Create the file for the ns in ~/remote/src/remote/one.clj.
From the client evaluate (compile 'remote.one).
(Using Leiningen 2.3.4 on Java 1.7.0 Java HotSpot(TM) 64-Bit Server VM and Clojure 1.5.1).

How can I restart swank in Leiningen's interactive mode?

Let's say I'm running Leiningen in interactive mode ('lein interactive') and have started a Swank Clojure server ('swank'). Now I want to kill/restart the Swank server without killing Leiningen as well. How can I do this? Is this even possible?
So far I've just been using Ctrl-C to kill both, which doesn't make Leiningen's interactive mode all that useful for me since I may as well have just ran 'lein swank' to begin with.
If you are using Slime, you can call ,rest which is bound to (restart-inferior-lisp). This will restart your swank session.
This isn't implemented yet. However, the interactive task is intended for people who don't use swank. Swank already keeps a JVM open for your project, so that kind of defeats the purpose of the interactive task.

Some tweaks to enable Clojure development on Aquamacs

I'm trying to enable Clojure development on Aquamacs. I followed this article: http://mischneider.net/?p=171
When I tried to run (alt+x) slime, Aquamacs asked me if I want to download Clojure and then it tried to download Clojure 1.1.0 , but it got the error:
"Unable to download Clojure jars"
Any way I have the Clojure jar, where I have to put it by hand? should I configure something?
Even better, instead of Clojure 1.1 , can I use Clojure 1.2?
You can easily use 1.2 and you should. I found setting up Clojure with Emacs easy with these instructions. I use Cocoa Emacs, but it should work with Aquamacs as well.
Most probably you have a problem because of your proxy server configuration. Try to set http_proxy environment variable or setup it directly from Emacs. If this doesn't help, check your steps with this tutorial.
You can also use custom version of Clojure with Leiningen's project.clj configuration file.