Let's respect CLOJURE_HOME

76 views
Skip to first unread message

Greg

unread,
Jun 30, 2010, 1:45:28 PM6/30/10
to clo...@googlegroups.com
It seems like a lot of n00b (and non-n00b) related problems have to do with the location of clojure.jar and clojure-contrib.jar. People generally don't like having to keep track of all the clojure.jars, and it would be nice if it was easy to switch versions for scripts like clj and such.

May I propose as a possible remedy CLOJURE_HOME. CLOJURE_HOME is the absolute path of a directory containing clojure.jar and possibly clojure-contrib.jar. Scripts should check if it's defined and use it instead of hard-coded paths, as an example, here's my clj script (in newLISP):

http://www.taoeffect.com/other/clj.lsp.html

It's really simple, at least in newLISP, to do this:

(constant 'CLOJURE_HOME (or (env "CLOJURE_HOME") (string (env "HOME") "/.clojure"))

Input welcome!

- Greg

Rick Moynihan

unread,
Jun 30, 2010, 3:53:41 PM6/30/10
to clo...@googlegroups.com

On the face of it this seems like a good idea, however it doesn't
really fit with the models used by tools such as leiningen, mvn or the
JVM. At best a CLOJURE_HOME initiative can only expect to work within
its own world of clj scripts etc.

Though having a clj script adopt CLOJURE_HOME is probably a good idea,
i.e. the script is then reusable across multiple installs of clojure
it's not really a "n00b" friendly solution. Like others I don't think
we can gloss over handling the JVMs classpath; it's part and parcel of
Clojure and the JVM. Trying to dust it under the carpet will only
confuse people more.

This isn't to say that the Clojure community shouldn't work hard to
make this stuff easier. Personally I think that leiningen is the
easiest model for beginners, and it scales nicely up to larger
projects too. This is why I'd love to see "lein swank" styled support
for each of the IDE's/Editors.

R.

Brian Schlining

unread,
Jun 30, 2010, 4:14:04 PM6/30/10
to clo...@googlegroups.com

>
> May I propose as a possible remedy CLOJURE_HOME. CLOJURE_HOME is the absolute path of a directory containing clojure.jar and possibly clojure-contrib.jar. Scripts should check if it's defined and use it instead of hard-coded paths, as an example, here's my clj script (in newLISP):

On the face of it this seems like a good idea, however it doesn't
really fit with the models used by tools such as leiningen, mvn or the
JVM.  At best a CLOJURE_HOME initiative can only expect to work within
its own world of clj scripts etc.

I can't speak for leiningen but many (most?) launcher script in the Java world use this as a standard convention. If you look through the launcher scripts for maven, groovy, scala, ant, etc you will see environment variables JAVA_HOME, M2_HOME (for Maven 2), GROOVY_HOME, SCALA_HOME and ANT_HOME.

cageface

unread,
Jun 30, 2010, 4:36:12 PM6/30/10
to Clojure
My clj file looks like this:

#!/bin/sh

export CLASSPATH=$CLOJUREPATH:./lib/*:.:$CLASSPATH

if [ -z "$1" ]; then
exec java -server jline.ConsoleRunner clojure.main
else
SCRIPT=$(dirname $1)
export CLASSPATH=$SCRIPT/*:$SCRIPT:$CLASSPATH
exec java -server clojure.main "$1" "$@"
fi

Having clj look in the current directory for jars/classes/.clj files
the same way Python and Ruby do makes dealing with libraries easier.

So, +1.

Rick Moynihan

unread,
Jun 30, 2010, 5:17:59 PM6/30/10
to clo...@googlegroups.com

This is true. And I agree that where scripts are used this technique
can be useful. And in this regard it's a good convention.

However, I don't see it helping newcomers to Clojure significantly, as
the classpath issues people face are the deeper issue. Also teaching
newcomers that this is the convention isn't really true, as tools like
Lieningen or maven don't really fit with this approach as they treat
the clojure platform as just another library dependency.

Clojure doesn't yet have a standard launch script. In the past I've
argued that it'd be nice if it had one, though I now feel lein/mvn are
better tools for this job. That said, having a clj launch script can
be useful, and might ease the out of box experience, but again the
true launcher will always be the java JVM executable, and I'm not sure
this is something we should really try and hide.

R.

Steve Molitor

unread,
Jun 30, 2010, 4:46:52 PM6/30/10
to clo...@googlegroups.com
JRuby uses JRUBY_HOME, which contains jruby.jar, a few other other essential jars and gems, and any locally installed gems. (Gems are ruby's packaging mechanism.)  It also includes a jruby (jruby.bat on windows) executable script.  This script parses command line args, sets up the classpath using JRUBY_HOME, and if the first arg is a ruby file, evaluates that file.  It supports options for adding to the 'include path'.  I'm not sure but I think groovy does something similar.  

If something similar were created for clojure, newbie instructions might look like this.  

1.  Download and unpack clojure-for-newbies.zip
2.  Add clojure-for-newbies/bin to your PATH.
3.  Create hello_world.clj with the following contents:
     (println "hello world")
4.  Type 'clojure hello_world.clj' to invoke your script

The 'clojure' script could also support options for adding jars and .clj files to the class/load path.  With this approach a newbie could go a long way without having to worry about lein/maven, projects, packaging, compiling, etc. 

On the other hand I did find it very easy to get started with lein (can't remember how to spell its full name).   I love 'lein repl' (in spite of its current limitations) - very newbie friendly for me as I could start experimenting right away.  I have found clojure to be pretty newbie friendly, but I do come from a Java background.

Steve



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

Steve Molitor

unread,
Jun 30, 2010, 5:44:33 PM6/30/10
to clo...@googlegroups.com
>> the true launcher will always be the java JVM executable, and I'm
>> not sure this is something we should really try and hide.

I think it should be hidden, at least for newbies.  Maven hides it - I invoke 'mvn' and have no idea how it invokes java.  I don't know what jars it puts in the classpath, etc., and I don't need to know.  Lein hides it too and I like that. 

Ideally a clojure installation package would include lein and a launcher that utilized lein for clojure-contrib.jar etc.  

Steve



R.

Mike Anderson

unread,
Jun 30, 2010, 5:46:37 PM6/30/10
to Clojure
On Jun 30, 6:45 pm, Greg <g...@kinostudios.com> wrote:
> It seems like a lot of n00b (and non-n00b) related problems have to do with the location of clojure.jar and clojure-contrib.jar. People generally don't like having to keep track of all the clojure.jars, and it would be nice if it was easy to switch versions for scripts like clj and such.
>
> May I propose as a possible remedy CLOJURE_HOME. CLOJURE_HOME is the absolute path of a directory containing clojure.jar and possibly clojure-contrib.jar. Scripts should check if it's defined and use it instead of hard-coded paths, as an example, here's my clj script (in newLISP):

Sounds sensible in principle, though I think the issue for n00bs is
that configuring *anything* is a barrier because even the slightest
mistake in interpreting the documentation or configuring your
environment is pretty painful.

For n00bs, if it is much more complicated than unzipping a Clojure
distribution or navigating to the right Eclipse update site then
you're already going to lose a lot of people.

For those of us n00bs who primarily use IDEs like myself, I'd vote for
just improving the integration with the IDE's automatic management of
classpaths / build paths etc. To give it credit, Counterclockwise does
a decent job to get people started quickly in terms of adding the
Clojure jars automatically to an Eclipse project.

Greg

unread,
Jun 30, 2010, 5:48:46 PM6/30/10
to clo...@googlegroups.com
> However, I don't see it helping newcomers to Clojure significantly

With respect, I'm a newcomer to Clojure, and the CLOJURE_HOME convention would help me significantly. :-)

I think something that needs to be acknowledged is that "newcomers" and "n00bs" are not necessarily idiots, they're just new to the platform, and they're coming from places where, as Brian pointed, they're used to there being a central location for things (PYTHON_HOME, ANT_HOME, etc.).

> Lieningen or maven don't really fit with this approach as they treat
> the clojure platform as just another library dependency.

Yet Maven has a MAVEN_HOME. :-)

Even if Leiningen/Maven ignore CLOJURE_HOME, that's fine, it certainly doesn't hurt to adopt CLOJURE_HOME as a convention for scripts that currently hard-code clojure.jar's location, or download it themselves, wasting space and adding confusion. When that happens it's hard to know what version of Clojure these scripts are running, and it makes it unwieldy then to interface it with your own code. A problem, I think, that doesn't just affect newcomers to Clojure.

> and I'm not sure this is something we should really try and hide.

CLOJURE_HOME doesn't hide anything, it's set by the user after all.

Cheers,
Greg

Rick Moynihan

unread,
Jun 30, 2010, 8:03:08 PM6/30/10
to clo...@googlegroups.com
On 30 June 2010 22:44, Steve Molitor <stevem...@gmail.com> wrote:
>>> the true launcher will always be the java JVM executable, and I'm
>>> not sure this is something we should really try and hide.
>
> I think it should be hidden, at least for newbies.  Maven hides it - I
> invoke 'mvn' and have no idea how it invokes java.  I don't know what jars
> it puts in the classpath, etc., and I don't need to know.  Lein hides it too
> and I like that.
>
> Ideally a clojure installation package would include lein and a launcher
> that utilized lein for clojure-contrib.jar etc.

Yes, and this is what I've been trying to argue all along... that
lein, with its simplified classpath management/jvm options is probably
the best option for beginners.

My point about the JVM being the true launcher, is more that I don't
think it's Clojure's responsibility to try and dictate how the VM is
invoked, by a script or otherwise. There are many ways to invoke
Clojure (lein, mvn, nailgun, shell script, java -cp, java -jar etc...
from inside a java program etc... ) though confusing, each has its own
merits. And new users will soon need to understand whats going on
underneath.

I'm not saying there shouldn't be a "preferred route" for newcomers to
play with Clojure and have this taken care of for them; I just think
Clojure itself should ship without it, with the only assumption being
it's a jar on the classpath.

R.

Luc Préfontaine

unread,
Jul 1, 2010, 7:12:19 AM7/1/10
to clo...@googlegroups.com
We use a "HOME" reference in our
quite complex software and I think
we do not qualify as n00bs...

Any root symbol that can help derive
locations is just common sense to
us. It's not used internaly in our code
(Clojure/Java/Ruby)
but it's obviously a simple way
to bootstrap our apps and establish
a common ground in the supporting
scripts we use.

It helps structuring the file space were
all our components reside in dev test
and prod.

Honestly, by the time this thread ends
on that simple and obvious matter,
Clojure 1.5 will be released...


Luc P.

Sent from my iPod

Greg

unread,
Jun 30, 2010, 7:46:33 PM6/30/10
to clo...@googlegroups.com
> Sounds sensible in principle, though I think the issue for n00bs is
> that configuring *anything* is a barrier because even the slightest
> mistake in interpreting the documentation or configuring your
> environment is pretty painful.

OK, see my response to Rick. I think we're getting stuck on a stereotype of what a n00b is, and it's hurting the discussion.

I'm not suggestion (and I don't think anyone else is) that CLOJURE_HOME have anything to do with the existing setup processes. *Complete* n00bs, and by that I mean people who generally don't have much of a clue about anything, won't know or see or wish for a CLOJURE_HOME.

A CLOJURE_HOME convention would help everyone else, those who use clojure-related script/projects, etc. Newcomers (perhaps that's a better word) to Clojure, who come from a general UNIX background, would expect something like CLOJURE_HOME to exist, because it's useful convention employed frequently.

If it were a convention in Clojure, n00bs an non-n00bs alike would benefit from it, while those who don't need it won't be affected in any way.

- Greg

Greg

unread,
Jun 30, 2010, 7:50:44 PM6/30/10
to clo...@googlegroups.com
> are not necessarily idiots,

Ooof.. bad choice of words there on my part, it was in jest and I did not mean literal "idiots". :-p

Reply all
Reply to author
Forward
0 new messages