• Stars
    star
    238
  • Rank 169,306 (Top 4 %)
  • Language
    Clojure
  • Created over 14 years ago
  • Updated over 14 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

cljr is a Clojure REPL and package management system.

Cljr is a Clojure REPL and package manager. It’s designed to complement the project-oriented approach of dependency management systems like Leiningen and Maven, both of which are my preferred tools for managing traditional-project dependencies. However, much of what I use Clojure for, including Incanter-based data analysis, is not really project-oriented. In these cases, it is more convenient to have access to a REPL (and Swank server) backed by a global package-management system.

Another goal of the cljr project is to improve the out-of-box experience for Clojure. There are many approaches to helping people get started with Clojure, from the streamlined starter-pack called Dejour, which only includes Clojure and Clojure-contrib, to the full-monty approach of labrepl, which includes several additional Clojure libraries, instructions for configuring every available Clojure IDE plugin, and web-based Clojure tutorials.

Cljr takes a third approach by providing an easy to launch REPL combined with the ability to easily search for and install Clojure packages from the Clojars repository.

Cljr uses Leiningen to manage the packages in the .cljr repository, and there is a project.clj file in the .cljr directory that can be customized by hand if desired.

Quick start

Install

  1. Download cljr-installer.jar
  2. Run java -jar cljr-installer.jar
    • Note 1: If your browser added a .zip extension to the jar during download, just run: java -jar cljr-installer.jar.zip.
    • Note 2: Requires java 1.6
  3. Add ~/.cljr/bin/ to your path (or copy the platform appropriate cljr script to your path).

Try it out

  1. Run cljr list to see what packages are installed.
  2. Run cljr search compojure to search for Compojure on Clojars.
  3. Run cljr describe compojure to get a description of the latest version of compojure.
  4. Run cljr install compojure to install the latest version of compojure.
  5. Run cljr repl or cljr swingrepl to launch a REPL configured for all the installed packages.

You can also use the executable jar, cljr.jar, installed in ~/.cljr to run commands:

  • java -jar ~/.cljr/cljr.jar list
  • java -jar ~/.cljr/cljr.jar repl

Documentation

Usage: cljr command [arguments]

Available commands

  • repl: Starts a Clojure repl.
  • swingrepl: Starts a Clojure swingrepl.
  • swank [port]: Start a local swank server on port 4005 (or as specified).
  • run filename: Runs the given Clojure file.
  • list: Prints a list of installed packages.
  • search term: Prints a list of packages on clojars.org with names that contain the given search term.
  • install package-name [package-version]: Installs the given package from clojars.org, defaulting to the inferred latest version.
  • describe package-name [package-version]: Prints the description of the given package as found in the description field of its pom file.
  • versions package-name: Prints a list of the versions of the given package available on clojars.org
  • remove package-name: Removes given package from the cljr-repo package list, must be followed by cljr clean and cljr reload to actually remove packages from the repository.
  • clean: Removes all packages from ~/.cljr/lib directory.
  • reload: Reloads all packages listed by cljr list.
  • list-classpath: Prints classpath.
  • add-classpath dirs-or-jarfiles: Adds directories or jar files to the classpath. Directories should have a trailing / to distinguish them from jar files.
  • list-repos: Prints a list of repositories.
  • add-repo repo-name repo-url: Adds repository.
  • remove-repo repo-name: Removes the given repository.
  • add-jars jar file(s): Copies jar files to the cljr repository.
  • remove-classpath dir-or-jarfile: Removes a directory or jar file from the classpath. Remember to include trailing / for directories.

Options

  • CLOJURE_HOME: If this environment variable is set, jar files in this directory will be included first on the classpath.
    • To use a custom build of Clojure/Clojure-contrib, set the CLOJURE_HOME environment variable, place clojure*.jar and clojure-contrib*.jar files in the specified directory, and remove the current clojure/clojure-contrib jar files from the ~/.cljr/lib directory. Note: Installing new packages will likely reinstall Clojure/Clojure-contrib in the cljr lib directory.
  • DISABLE_JLINE: To disable JLine when using the command line repl, set this environment variable to true. export DISABLE_JLINE="true"
    • Note: JLine is only used in the command line repl on Unix/Linux/Mac OS X, not on Windows.
  • JVM_OPTS: The default value is “-Xmx1G”.
    • For example, to set the server flag, run the following sh command: export JVM_OPTS="-Xmx2G -server"
    • Another example, to set an HTTP proxy add the following options export JVM_OPTS="-Dhttp.proxyHost=my-proxy-host -Dhttp.proxyPort=my-proxy-port"

To view the JVM options from a repl, use the following call:
(.getInputArguments (java.lang.management.ManagementFactory/getRuntimeMXBean))

Packages are installed in $HOME/.cljr/lib, and can be used by applications other than cljr
by including the jars in the directory on the classpath. For instance, to start a command line
REPL with jline, run the following command:

java -cp ~/.cljr/lib/'*' jline.ConsoleRunner clojure.main

Installation
Download the cljr-installer.jar file (or follow the instructions below to build from source):

wget http://incanter.org/downloads/cljr-installer.jar

and either double-click on the jar file to run it from the command line:

java -jar cljr-installer.jar

The installer will

  • create a $HOME/.cljr directory
  • initialize a local reposistory for Clojure packages in $HOME/.cljr/lib
  • create the shell and Windows batch scripts,
    • $HOME/.cljr/bin/cljr
    • $HOME/.cljr/bin/cljr.bat

Alternative installation directories
You can provide alternative CLJR_HOME and USER_HOME directories by passing them as properties to the above java command.

For instance, the following command creates the .cljr and Maven .m2 directories under C: on a Windows box (something I had to do since Windows had problems with my shared home under VMWare, \\vmware-host\…).

java -Duser.home=C: -jar cljr-installer.jar

cljr scripts
Once installation is complete, you should either add $HOME/.cljr/bin to your path, export PATH=~/.cljr/bin:$PATH on Unix/Mac OS X, or move the platform-appropriate cljr script to a directory on your path.

Build instructions

Run script/install

Copyright © 2010 David Edgar Liebke

Distributed under the Eclipse Public License, the same as Clojure.