[ANN]: Introducing lein-try

348 views
Skip to first unread message

Ryan Neufeld

unread,
Jul 13, 2013, 9:56:04 AM7/13/13
to clo...@googlegroups.com
Hey folks,

Don't you hate it when someone releases a cool new library and you have to go into a project and add an unwanted dependency just to try it out? Worse, maybe you decide to 'lein new delete-me' and add it there.

No more! Stop this madness. Use lein-try to quickly launch a REPL with new dependencies download automatically - inside of a project, or out.

Once you've dropped [lein-try "0.1.1"] in your ~/.lein/profiles.clj's :user :plugins key, simply copy-paste the leiningen-style dependency after "lein try". For example:

$ lein try [io.rkn/core.async "0.1.0-SNAPSHOT"]
nREPL server started on port 50472
REPL-y 0.2.0
Clojure 1.5.1
Docs: (doc function-name-here)
(find-doc "part-of-name-here")
Source: (source function-name-here)
Javadoc: (javadoc java-object-or-class-here)
Exit: Control+D or (exit) or (quit)

user=> (require '[clojure.core.async :as async :refer [timeout go <!]])
nil
user=> (go (<! (timeout 1000)) (println "Now we're cooking with channels."))
#<ManyToManyChannel clojure.core.async.impl.channels.ManyToManyChannel@3b43b598>
user=>

# one second later...

Now we're cooking with channels.

Wow, that's cool!

Find out more or contribute at https://github.com/rkneufeld/lein-try

-Ryan

Steven Degutis

unread,
Jul 13, 2013, 11:27:59 AM7/13/13
to clo...@googlegroups.com
Very handy! I have to admit, the lack of this functionality has kept me from trying out several libs. Looking forward to "trying" it out! ;)


--
--
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.



xumingmingv

unread,
Jul 13, 2013, 12:00:30 PM7/13/13
to clo...@googlegroups.com
cool!

发自我的 iPhone

Brandon Bloom

unread,
Jul 13, 2013, 12:27:25 PM7/13/13
to clo...@googlegroups.com
This is awesome! I've totally wanted this.

Unfortunately, I can't get it to work...

~ $ lein try '[clj-time "0.5.1"]'
nREPL server started on port 61689
REPL-y 0.1.10
Clojure 1.5.1
    Exit: Control+D or (exit) or (quit)
Commands: (user/help)
    Docs: (doc function-name-here)
          (find-doc "part-of-name-here")
  Source: (source function-name-here)
          (user/sourcery function-name-here)
 Javadoc: (javadoc java-object-or-class-here)
Examples from clojuredocs.org: [clojuredocs or cdoc]
          (user/clojuredocs name-here)
          (user/clojuredocs "ns-here" "name-here")
user=> (use 'clj-time.core)
FileNotFoundException Could not locate clj_time/core__init.class or clj_time/core.clj on classpath:   clojure.lang.RT.load (RT.java:443)

What gives?

Steven Degutis

unread,
Jul 13, 2013, 12:44:43 PM7/13/13
to clo...@googlegroups.com
It looks like you're not supposed to quote the arguments you pass it.


--

Brandon Bloom

unread,
Jul 13, 2013, 12:54:23 PM7/13/13
to clo...@googlegroups.com
Odd. I just assumed that the arguments were being joined by spaces, then clojure.core/read, rather than parsed as individual arguments.

Not all of us use Bash... square brackets are used for special patterns in Zsh.

Without quotes, the arguments are being interpreted in this way:

lein try '[clj-time' '"0.5.1"]'

That seems to work, but it a bit awkward to use.


You received this message because you are subscribed to a topic in the Google Groups "Clojure" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/clojure/YZDYufCtKRA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to clojure+u...@googlegroups.com.

Steven Degutis

unread,
Jul 13, 2013, 1:13:21 PM7/13/13
to clo...@googlegroups.com
I think it also works with just: lein try clj-time 0.5.1, no quotes, no brackets.

Daniel Dinnyes

unread,
Jul 13, 2013, 7:55:55 PM7/13/13
to clo...@googlegroups.com
Well, that's the most convenient way it should work anyway, just a list of key, value, key, value, key, value argument list. Easy to implement. Accepting brackets is criminal.

Sean Corfield

unread,
Jul 13, 2013, 7:56:31 PM7/13/13
to clo...@googlegroups.com
This seems to work beautifully outside a project - and it's very
useful! I will no longer need to create a million scratch projects to
try stuff out - thank you!

However, inside a project, I can't get it to work.

(! 501)-> cd clojure
(! 502)-> lein try hiccup 1.0.2
nREPL server started on port 59442
...
user=> (use 'hiccup.core)
nil
user=> (html [:p "It works!"])
"<p>It works!</p>"
user=> Bye for now!

(! 503)-> lein new testproject
Generating a project called testproject based on the 'default' template.
To see other templates (app, lein plugin, etc), try `lein help new`.
(! 504)-> cd testproject
(! 505)-> lein try hiccup 1.0.2
nREPL server started on port 59477
...
user=> (use 'hiccup.ocre)
FileNotFoundException Could not locate hiccup/ocre__init.class or
hiccup/ocre.clj on classpath: clojure.lang.RT.load (RT.java:443)

user=>

Inside a project, it only seems to pick up the project's deps, not add
to them. Am I doing something wrong?

Sean
> --
> --
> 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.
>
>



--
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/

"Perfection is the enemy of the good."
-- Gustave Flaubert, French realist novelist (1821-1880)

Daniel Dinnyes

unread,
Jul 13, 2013, 7:58:51 PM7/13/13
to clo...@googlegroups.com
Looks promising though. Pomegranate is significantly more complex, and I could never remember the name of the function which dynamically loads the libs.

Daniel Dinnyes

unread,
Jul 13, 2013, 8:07:26 PM7/13/13
to clo...@googlegroups.com
Also, I would call it repl-deps or repl-with-deps. Not as short, but who knows, maybe later on it will be merged into `repl` as some option argument; such naming would support that intention. It is more descriptive too. When I first saw the post I thought `lein try` will be about testing exception handling or something.

Ryan Neufeld

unread,
Jul 13, 2013, 10:26:33 PM7/13/13
to clo...@googlegroups.com
It looks like you tried to use hiccup.ocre instead of core

Ryan Neufeld

unread,
Jul 13, 2013, 10:27:59 PM7/13/13
to clo...@googlegroups.com
I use zsh too and have to prefix commands with noglob. Additional robustness and caveats documentation will be necessary.

Pull requests welcomed.

Sean Corfield

unread,
Jul 14, 2013, 12:30:00 AM7/14/13
to clo...@googlegroups.com
It doesn't work when I spell it correctly either (and I had done
several tests - but of course the results of misspelling it look the
same as it not working - and it's indicative of my day that I pasted
the result of a bad test! :)

C:\Users\Sean\clojure>lein new five
...
C:\Users\Sean\clojure>cd five
C:\Users\Sean\clojure\five>lein try hiccup 1.0.2
Retrieving lein-try/lein-try/0.1.1/lein-try-0.1.1.pom from clojars
Retrieving lein-try/lein-try/0.1.1/lein-try-0.1.1.jar from clojars
Retrieving org/clojure/clojure/1.2.1/clojure-1.2.1.jar from central
nREPL server started on port 51113
REPL-y 0.2.0
Clojure 1.5.1
Docs: (doc function-name-here)
(find-doc "part-of-name-here")
Source: (source function-name-here)
Javadoc: (javadoc java-object-or-class-here)
Exit: Control+D or (exit) or (quit)
user=> (use 'hiccup.core)
FileNotFoundException Could not locate hiccup/core__init.class or
hiccup/core.clj on classpath: clojure.lang.RT.load (RT.java:443)
user=> ^D
Bye for now!

C:\Users\Sean\clojure\five>cd ..
C:\Users\Sean\clojure>lein try hiccup 1.0.2
nREPL server started on port 51183
REPL-y 0.2.0
Clojure 1.5.1
Docs: (doc function-name-here)
(find-doc "part-of-name-here")
Source: (source function-name-here)
Javadoc: (javadoc java-object-or-class-here)
Exit: Control+D or (exit) or (quit)
user=> (use 'hiccup.core)
nil
user=> ^D
Bye for now!
C:\Users\Sean\clojure>

(and that's just to show it failing the same way on Windows 8 (with
GNU on Windows) as it does on Mac!)

Sean

On Sat, Jul 13, 2013 at 9:26 PM, Ryan Neufeld <ry...@thinkrelevance.com> wrote:
> It looks like you tried to use hiccup.ocre instead of core
>

Ryan Neufeld

unread,
Jul 14, 2013, 10:42:34 AM7/14/13
to clo...@googlegroups.com

Can you pop that in an issue on the project. In the mean time I'll see if I reproduce that problem.

You received this message because you are subscribed to a topic in the Google Groups "Clojure" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/clojure/YZDYufCtKRA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to clojure+u...@googlegroups.com.

Softaddicts

unread,
Jul 14, 2013, 10:54:36 AM7/14/13
to clo...@googlegroups.com
After reading this thread, I think we need another plug in to try the try plugin
which in turn may fail which would trigger the need for another try plugin which ....

Isn't this recursive a bit ? :))))

Luc
Softaddicts<lprefo...@softaddicts.ca> sent by ibisMail from my ipad!

Ryan Neufeld

unread,
Jul 14, 2013, 11:17:18 AM7/14/13
to clo...@googlegroups.com

I figured there was a joke somewhere in there, but I just couldn't tease a good one out ;)

Softaddicts

unread,
Jul 14, 2013, 11:22:15 AM7/14/13
to clo...@googlegroups.com
Nice ... try :)

Luc

Sean Corfield

unread,
Jul 14, 2013, 8:53:36 PM7/14/13
to clo...@googlegroups.com
https://github.com/rkneufeld/lein-try/issues/3

Let me know if I can help with testing or provide any additional information.

Sean
Reply all
Reply to author
Forward
0 new messages