1

I have a problem compiling .clj files which reside in a project where I run the nREPL server process:

  1. I've created a new project using lein new xxx.
  2. In the project folder I started up an nREPL by lein repl.
  3. In another terminal window I started a client lein repl :connect localhost:12345/repl.
  4. I created a simple namespace file and saved it inside the project in the appropriate location:

    (ns remote.one)
    (def foo 42)
    
  5. 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

Janos
  • 1,987
  • 3
  • 17
  • 24

1 Answers1

1

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.

  1. Create a new project using lein new remote.
  2. Change the current directory cd remote.
  3. Start the nREPL server from the project folder with lein repl :headless (which I realize now is also different from your description).
  4. Open a new console and start the nREPL client lein repl :connect localhost:port/repl in ~/..
  5. Create the file for the ns in ~/remote/src/remote/one.clj.
  6. 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).

juan.facorro
  • 9,791
  • 2
  • 33
  • 41
  • The remote REPL was started in the project folder, I only omitted that step from my description. Did you start the client from the same folder? Just to make it clear, I got the exception in the client process. – Janos Mar 12 '14 at 14:17
  • @Janos Just updated the answer since I realized I actually started the nREPL server with the `:headless` flag. – juan.facorro Mar 12 '14 at 14:35
  • Doesn't work for me :( It still looks for the clj file in the temp folder. However, if I start up the client in the same directory (that of the project's) then it works fine. Of course, this is not an option. – Janos Mar 12 '14 at 17:54
  • Will try it using JDK 1.7 and let you know how it goes. – Janos Mar 12 '14 at 17:58
  • Juan, are you sure you are not starting the client repl in the project's folder? (Still I'm going to try with 1.7 JDK) – Janos Mar 12 '14 at 18:12
  • It does work. I had such a schoolboy error that I'm hesitant to tell: I wrote ('compile blah.blah) instead of (compile 'blah.blah)... – Janos Mar 12 '14 at 18:17
  • @Janos :) it happens. Glad the answer helped! – juan.facorro Mar 12 '14 at 18:22