running command when lein repl starts

529 views
Skip to first unread message

Andy Smith

unread,
Nov 19, 2013, 12:08:04 PM11/19/13
to clo...@googlegroups.com
Hi,

How can I get a command such as '(use 'clojure.math.numeric-tower)' to run when I start the repl with 'lein repl' ? I currently have my leiningen project setup as the following :

(defproject test "1.0.0-SNAPSHOT"
  :description "FIXME: write description"
  :dependencies [[org.clojure/clojure "1.3.0"]
                 [org.clojure/math.numeric-tower "0.0.2"]])
  :repl-options {
                 :dependencies [
                 [org.clojure/math.numeric-tower "0.0.2"]]
                 :init (clojure.core/use 'clojure.math.numeric-tower)}




and the error I get is as follows :


andy@Aspire-V3-571:~/projects/clojure/test$ lein repl
Exception in thread "main" java.lang.ClassNotFoundException: org.clojure (project.clj:1)
    at clojure.lang.Compiler.analyze(Compiler.java:5206)
    at clojure.lang.Compiler.analyze(Compiler.java:5152)
    at clojure.lang.Compiler$VectorExpr.parse(Compiler.java:2592)
    at clojure.lang.Compiler.analyze(Compiler.java:5193)
    at clojure.lang.Compiler.analyze(Compiler.java:5152)
    at clojure.lang.Compiler$VectorExpr.parse(Compiler.java:2592)
    at clojure.lang.Compiler.analyze(Compiler.java:5193)
    at clojure.lang.Compiler.analyze(Compiler.java:5152)
    at clojure.lang.Compiler$MapExpr.parse(Compiler.java:2499)
    at clojure.lang.Compiler.analyze(Compiler.java:5195)
    at clojure.lang.Compiler.analyze(Compiler.java:5152)
    at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:4671)
    at clojure.lang.Compiler$FnMethod.parse(Compiler.java:4329)
    at clojure.lang.Compiler$FnExpr.parse(Compiler.java:3174)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:5368)
    at clojure.lang.Compiler.analyze(Compiler.java:5191)
    at clojure.lang.Compiler.eval(Compiler.java:5422)
    at clojure.lang.Compiler.load(Compiler.java:5858)
    at clojure.lang.Compiler.loadFile(Compiler.java:5821)
    at clojure.lang.RT$3.invoke(RT.java:296)
    at leiningen.core$read_project$fn__2167.invoke(core.clj:127)
    at leiningen.core$read_project.invoke(core.clj:126)
    at leiningen.core$read_project.invoke(core.clj:130)
    at leiningen.core$_main.doInvoke(core.clj:320)
    at clojure.lang.RestFn.invoke(RestFn.java:410)
    at clojure.lang.AFn.applyToHelper(AFn.java:161)
    at clojure.lang.RestFn.applyTo(RestFn.java:132)
    at clojure.core$apply.invoke(core.clj:542)
    at leiningen.core$_main.invoke(core.clj:332)
    at user$eval73.invoke(NO_SOURCE_FILE:1)
    at clojure.lang.Compiler.eval(Compiler.java:5425)
    at clojure.lang.Compiler.eval(Compiler.java:5392)
    at clojure.core$eval.invoke(core.clj:2382)
    at clojure.main$eval_opt.invoke(main.clj:235)
    at clojure.main$initialize.invoke(main.clj:254)
    at clojure.main$script_opt.invoke(main.clj:270)
    at clojure.main$main.doInvoke(main.clj:354)
    at clojure.lang.RestFn.invoke(RestFn.java:457)
    at clojure.lang.Var.invoke(Var.java:377)
    at clojure.lang.AFn.applyToHelper(AFn.java:172)
    at clojure.lang.Var.applyTo(Var.java:482)
    at clojure.main.main(main.java:37)
Caused by: java.lang.ClassNotFoundException: org.clojure
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at clojure.lang.DynamicClassLoader.findClass(DynamicClassLoader.java:61)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:270)
    at clojure.lang.RT.classForName(RT.java:1566)
    at clojure.lang.Compiler$HostExpr.maybeClass(Compiler.java:852)
    at clojure.lang.Compiler$HostExpr.access$300(Compiler.java:654)
    at clojure.lang.Compiler.analyzeSymbol(Compiler.java:5572)
    at clojure.lang.Compiler.analyze(Compiler.java:5173)
    ... 41 more




What am I doing wrong? Thanks in advance.

Andy

Josh Kamau

unread,
Nov 19, 2013, 12:12:29 PM11/19/13
to clo...@googlegroups.com
Is it intentional that you are using clojure 1.3.0 instead of a newer version like 1.5.1 ?

Do  "lein deps"   to download the dependencies. 

Then do lein repl 

Josh


--
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Andy Smith

unread,
Nov 19, 2013, 12:51:24 PM11/19/13
to clo...@googlegroups.com
Ok valid point, but I still get the same kind of errors?

David Powell

unread,
Nov 19, 2013, 12:56:22 PM11/19/13
to clo...@googlegroups.com


On Tue, Nov 19, 2013 at 5:51 PM, Andy Smith <the4th...@googlemail.com> wrote:
Ok valid point, but I still get the same kind of errors?

David Powell

unread,
Nov 19, 2013, 1:05:19 PM11/19/13
to clo...@googlegroups.com
Hmm, no it is just a syntax thing with your project, This works:

(defproject test "1.0.0-SNAPSHOT"
  :description "FIXME: write description"
  :dependencies [[org.clojure/clojure "1.5.1"]
                 [org.clojure/math.numeric-tower "0.0.2"]]
  :repl-options {:init (use 'clojure.math.numeric-tower)}
)

You had closed the opening paren on the :dependencies line.  And :dependencies isn't allowed inside :repl-options, which was causing the org.clojure error.


-- 
Dave

Andy Smith

unread,
Nov 19, 2013, 1:05:43 PM11/19/13
to clo...@googlegroups.com
yes, Ive seen that but it doesnt seem to help me greatly. Just out of curiosity how do you generally setup your repl so it already includes these kind of common libraries? I dont really want to be typing lots of 'use' commands into the repl every time i start it. Is using leiningen the wrong way to do this?

David Powell

unread,
Nov 19, 2013, 1:09:40 PM11/19/13
to clo...@googlegroups.com
I tend to work on files in emacs or an IDE, with a linked repl, rather than at a raw repl, so the file I'm working on will tend to have an ns directive that will require the appropriate namespaces, so I just eval that when I open the file.



On Tue, Nov 19, 2013 at 6:05 PM, Andy Smith <the4th...@googlemail.com> wrote:
yes, Ive seen that but it doesnt seem to help me greatly. Just out of curiosity how do you generally setup your repl so it already includes these kind of common libraries? I dont really want to be typing lots of 'use' commands into the repl every time i start it. Is using leiningen the wrong way to do this?

--

Andy Smith

unread,
Nov 19, 2013, 1:13:16 PM11/19/13
to clo...@googlegroups.com
oops, you are right but if I paste into my project.clj I get a different error when I run lein repl

andy@Aspire-V3-571:~/projects/clojure/test$ lein repl
Exception in thread "main" java.lang.IllegalArgumentException: No value supplied for key: [:init (use (quote clojure.math.numeric-tower))] (NO_SOURCE_FILE:0)
    at clojure.lang.Compiler.eval(Compiler.java:5441)

    at clojure.lang.Compiler.eval(Compiler.java:5392)
    at clojure.core$eval.invoke(core.clj:2382)
    at clojure.main$eval_opt.invoke(main.clj:235)
    at clojure.main$initialize.invoke(main.clj:254)
    at clojure.main$script_opt.invoke(main.clj:270)
    at clojure.main$main.doInvoke(main.clj:354)
    at clojure.lang.RestFn.invoke(RestFn.java:457)
    at clojure.lang.Var.invoke(Var.java:377)
    at clojure.lang.AFn.applyToHelper(AFn.java:172)
    at clojure.lang.Var.applyTo(Var.java:482)
    at clojure.main.main(main.java:37)
Caused by: java.lang.IllegalArgumentException: No value supplied for key: [:init (use (quote clojure.math.numeric-tower))]
    at clojure.lang.PersistentHashMap.createWithCheck(PersistentHashMap.java:89)
    at clojure.core$hash_map.doInvoke(core.clj:327)
    at clojure.lang.RestFn.applyTo(RestFn.java:137)
    at clojure.core$apply.invoke(core.clj:540)
    at leiningen.repl$repl_options.invoke(repl.clj:16)
    at leiningen.repl$repl_server.doInvoke(repl.clj:69)
    at clojure.lang.RestFn.applyTo(RestFn.java:146)
    at clojure.core$apply.invoke(core.clj:546)
    at leiningen.repl$repl.invoke(repl.clj:145)
    at clojure.lang.Var.invoke(Var.java:365)
    at clojure.lang.AFn.applyToHelper(AFn.java:161)
    at clojure.lang.Var.applyTo(Var.java:482)
    at clojure.core$apply.invoke(core.clj:542)
    at leiningen.core$apply_task.invoke(core.clj:262)
    at leiningen.core$_main.doInvoke(core.clj:329)

    at clojure.lang.RestFn.invoke(RestFn.java:410)
    at clojure.lang.AFn.applyToHelper(AFn.java:161)
    at clojure.lang.RestFn.applyTo(RestFn.java:132)
    at clojure.core$apply.invoke(core.clj:542)
    at leiningen.core$_main.invoke(core.clj:332)
    at user$eval73.invoke(NO_SOURCE_FILE:1)
    at clojure.lang.Compiler.eval(Compiler.java:5425)
    ... 11 more

Reply all
Reply to author
Forward
0 new messages