0

I'm using a WinXP (sp3) machine with clojure-1.5.1, leiningen-2.3.4, and the Java 1.7.0_45 jdk. I have no trouble creating a new project with leiningen, starting a clojure shell, or creating and running java programs. However, the following command (please see below) results in the error message(s) displayed. I have added the clojure-1.5.1 and leiningen-2.3.4-standalone.jars to user and system path variables in addition to the creation of a new user and system environmental variable, LEIN_JAR that points to the location of the leiningen.jar file. The classpath for both the user and system variables has also been edited as above. My lein.bat is not missing any double quotes around the location of the LEIN_JAR setting as another poster stated in assisting another beginning(?) user of Clojure. Any constructive help would be appreciated.

My project.clj file :

(defproject test10 "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url "http://example.com/FIXME"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.5.1"]])

Edit 2: lein version command output

C:\>lein version

Leiningen 2.3.4 on Java 1.7.0_45 Java HotSpot(TM) Client VM

C:\>lein repl
Error: Could not find or load main class  -Dfile.encoding=UTF-8
Exception in thread "Thread-4" clojure.lang.ExceptionInfo: Subprocess failed {:e
xit-code 1}
        at clojure.core$ex_info.invoke(core.clj:4327)
        at leiningen.core.eval$fn__3532.invoke(eval.clj:226)
        at clojure.lang.MultiFn.invoke(MultiFn.java:231)
        at leiningen.core.eval$eval_in_project.invoke(eval.clj:326)
        at clojure.lang.AFn.applyToHelper(AFn.java:167)
        at clojure.lang.AFn.applyTo(AFn.java:151)
        at clojure.core$apply.invoke(core.clj:619)
        at leiningen.repl$server$fn__7443.invoke(repl.clj:201)
        at clojure.lang.AFn.applyToHelper(AFn.java:159)
        at clojure.lang.AFn.applyTo(AFn.java:151)
        at clojure.core$apply.invoke(core.clj:617)
        at clojure.core$with_bindings_STAR_.doInvoke(core.clj:1788)
        at clojure.lang.RestFn.invoke(RestFn.java:425)
        at clojure.lang.AFn.applyToHelper(AFn.java:163)
        at clojure.lang.RestFn.applyTo(RestFn.java:132)
        at clojure.core$apply.invoke(core.clj:621)
        at clojure.core$bound_fn_STAR_$fn__4102.doInvoke(core.clj:1810)
        at clojure.lang.RestFn.invoke(RestFn.java:397)
        at clojure.lang.AFn.run(AFn.java:24)
        at java.lang.Thread.run(Thread.java:744)
REPL server launch timed out.
C:\>
CaitlinG
  • 1,955
  • 3
  • 25
  • 35
  • 1
    That sounds like the command line to the `java` process is being truncated at some point. This is the [lein code](https://github.com/technomancy/leiningen/blob/243a9918f914afd1bac4da09391f0900a71b65fb/leiningen-core/src/leiningen/core/eval.clj#L198) that builds the command; but I don't see how the `clojure.main` part could be left off. Maybe something in `get-jvm-args` has a newline...? Do any of those variables seem to be defined in your environment? – Shepmaster Jan 04 '14 at 15:31
  • 1
    It's quite odd that `lein new` works but `lein repl` does not. Do any other lein tasks work? – georgek Jan 04 '14 at 17:55
  • what happens if you remove the user and system path variables altogether, re-download a fresh copy of `lein.bat`, and try to run that? That's what I did the first time I installed clojure on my XP machine, and it worked fine... – MattDMo Jan 04 '14 at 21:04
  • @georgek: The other lein tasks appear to work so I am at a loss to explain this behavior. – CaitlinG Jan 05 '14 at 03:25
  • @Shepmaster: Can you elaborate? What variables were you referring to? – CaitlinG Jan 05 '14 at 03:25
  • @CaitlinG I was referring to the variables in the leiningen code I linked to. Environment variables like `LEIN_FAST_TRAMPOLINE`, `JAVA_CMD`, or `DEBUG`, or maybe some values in `project.clj`. Basically, my suggestion boils down to see if any of the values that combine to form `shell-command` could have a newline in them... It would be really great if you could print out the result of calling `shell-command`, but I don't know how to hack on leiningen itself... – Shepmaster Jan 05 '14 at 03:34

3 Answers3

1

Sorry I don't use MS Windows. However I have a couple suggestions.

You said you were able to create a new project with leiningen. What disk/directory did you create that project in?

Per your post, it looks like you are issuing the "lein repl" command from the root disk directory of your "c:" drive. Is that where you created a project?

If you change to a different disk/directory, do you get the same error message?

Perhaps leiningen is picking some artifacts it can't resolve in your root directory (I.E. C:/>). Thus, check to see if you can run "lein repl" from a different disk directory.

If you are only getting an error when you running "lein repl" from the root of a project directory, please post some information about the project (E.G. the contents of your project.clj file).

Hope that helps.

lorinpa
  • 556
  • 1
  • 5
  • 6
  • Hi. I created a subdirectory, C:\example, and ran the command lein repl but the same error appeared. I then created a new project with lein new test10, cd'ed to that folder and ran the command lein repl again. Unfortunately, the problem persists. I recall running the leiningen installer (.exe file) prior to downloading and running lein.bat. Could that have lead to the current dilemma? My project.clj file has been appended to my initial post. Thanks. – CaitlinG Jan 06 '14 at 08:11
  • 1
    Hi, Thank you for the response. Can you run "lein version" and post the result? Also, do have permission to run a server port on localhost (127.0.0.1)? Have you check your system logs to see if you raising any permission error? Just a thought. – lorinpa Jan 06 '14 at 14:03
  • I've always just used the lein .bat as the installer. – georgek Jan 06 '14 at 15:27
  • @user2658013: Thanks for the help. I posted the output from lein version. Yes, I do have permission to run a server at the localhost address. – CaitlinG Jan 06 '14 at 20:51
1

Thank you for the response. The output from lein version looks good. Sorry for the long message :)

Here is my approach to trouble shooting this further. Please make sure you are checking the system logs maintained by Windows. Pertinent messages could be routed to the system logs and not displayed in the console.

So far it appears leinegen can execute, some, but not all of it's commands. If you execute "lein help", you will get list of available commands.

My first thought is, leinegen is having trouble with the "lein repl" defaults. Thus, instead having leinegen choose default values for host and port, set them explictily in the command line. For example: "lein repl :start :host localhost :port 5554" or "lein repl :start :host 127.0.0.1 :port 5554".

I would change in to your "example" directory and verify that "lein deps", "lein check" and "lein compile" all run error free.

Finally, I would edit the example project. Add the following line to project.clj (right after the :dependencies clause)

:main example.core

That line tells leinegen what the entry point of the "example" program is.

Next we need to edit the "src/example/core.clj" file. Delete the contents and replace it with the following "hello word":

(ns example.core)

(defn -main [& args ] (println "Hello, World!"))

Now, from the root of the example project (C:/>example) run "lein run". Please post the results. If "lein run" succeeds try "lein repl" one more time from the root of the example project.

Again. make sure you check the Window's logs for messages. It might also help to run "lein deps", "lein check" and "lein complile" from the root of the example project. See if any errors are raised that are more helpful.

lorinpa
  • 556
  • 1
  • 5
  • 6
1
  1. Check to make sure that lein is not in a directory whose path has any spaces or capitalized characters in it.

  2. Make sure the JDK is in a directory with no spaces or capitalized characters in it.

  3. Make sure JAVA_HOME is set

  4. Make sure java is in your SYSTEM path

Eric Fode
  • 3,667
  • 2
  • 24
  • 29