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).
Related
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.
I'm trying to build a project that uses leiningen -- though my issue seems to be with leiningen and not with the project.
When I run lein figwheel dev (for a project that has a /dev folder configured correctly) I get the following:
Figwheel: Cutting some fruit, just a sec ...
Unrecognized option: --add-modules
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
Which indicates it's an error with the JVM, but I'm not familiar enough with working with any of JVM / clojure / lein to know what I should be doing to fix it.
Some (hopefully!) helpful information about my stack:
$ java --version
openjdk 11.0.1 2018-10-16
OpenJDK Runtime Environment (build 11.0.1+13-Debian-2)
OpenJDK 64-Bit Server VM (build 11.0.1+13-Debian-2, mixed mode, sharing)
$ lein --version
Leiningen 2.8.1 on Java 1.8.0_171 OpenJDK 64-Bit Server VM
Clone this repo and see if it solves your problems: https://github.com/cloojure/cljs-template
Be sure to read the README.txt file and follow the instructions.
For this project, all you need is:
> lein figwheel
I'm not sure what you have in your ./dev folder - that's probably the problem.
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.
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.
Exception in thread "main" java.lang.IllegalAccessError: repositories-for does not exits.
This is error while issuing command lein deps in cygwin.
If you access internet via a proxy make sure you have configured it in cygwin (using export http_proxy="...") and then check that you can access maven repositories with maven.
I think leiningen uses maven behind the scenes.