Install Clojure CLIλ︎
Clojure CLI is a command line tool for running a Clojure REPL, project or tool.
Clojure CLI automatically downloads required library dependencies, including the Clojure Standard library.
Clojure distributed as a library
Clojure is distributed as a library (.jar
Java ARchive) via Maven Central.
A deps.edn
file specifies the version of Clojure to be used with a project.
The Clojure CLI tool provides a default Clojure library version if not specified in the project or user deps.edn
files.
Practicalli Clojure CLI Config extends the Clojure CLI with a range of development tools as well as configuration for Clojure LSP and cljstyle code format tool.
Use the Linux script installer from Clojure.org - Getting Started to install or update to the latest stable release
curl -L -O https://github.com/clojure/brew-install/releases/latest/download/linux-install.sh && \
chmod +x linux-install.sh && \
sudo ./linux-install.sh
The installation creates /usr/local/bin/clojure
, /usr/local/bin/clj
wrapper and /usr/local/lib/clojure
directory.
Use alternative location - unattended install
--prefix
option specifies an alternative lolcation for the Clojure CLI install.
When permissions are not available or for automating the install without password prompt, use a local user specific install, e.g.
Include version number for specific release
Each Clojure CLI version is a number that represents the version of Clojure used and the build version of the Clojure CLI tool, e.g. 1.11.1.1413
.
Include the version in the script name for repeatable environments, e.g. in Dockerfile configuration and Continuous Integraion workflows.
Practically recommends setting XDG_CONFIG_HOME
to the .config
directory, to avoid creating another dot directory in the root of the user account. Add the following to ~/.bashrc
for the bash shell or ~/.zshenv
for Zsh.
Use the Homebrew command with the clojure/tools tap, as defined in the Clojure.org Getting started guide
Use Homebrew to update an install of Clojure CLI to the latest release
For Windows 10 use Windows Subsystem for Linux and Windows Terminal are recommended if you have administrative privileges and are comfortable using a Unix system on the command line.
Alternatively install scoop.sh, a command line installer for windows. Powershell 5 or greater is required. Follow the scoop-clojure getting started guide, summarized here:
Open "Windows PowerShell" and enter the following commands to configure the shell:
Then in the same PowerShell window, install the Clojure related tools using the following commands:Reference: Clojure CLI Install - Clojure.org Getting Started - official guide
Practicalli Clojure CLI Configλ︎
Add a wide range of community tools to extend the capabilities of Clojure CLI via the aliases.
Clone Practicalli Clojure CLI Config GitHub repository, first removing the $XDG_CONFIG_HOME/clojure
and $HOME/.clojure
directory if they exist.
User configuration locations
If XDG_CONFIG_HOME
environment variable is set, then the user configuration is $XDG_CONFIG_HOME/clojure/deps.edn
Otherwise the user configuration is $HOME/.clojure/deps.edn
.
CLJ_CONFIG
environment variable can be used to set a custom location, overriding any other location.
Practicalli recommends FreeDesktop XDG location
Practically recommends setting XDG_CONFIG_HOME
to the .config
directory to simplify versioning of configuration.
Configure ~/.bashrc
for the bash shell
Configure ~/.zshenv
for Zsh
If XDG_CONFIG_HOME
environment variable is set, clone the repository to $XDG_CONFIG_HOME/clojure
Via SSH
Via HTTPS:
Clojure CLI will look for its configuration in $HOME/.clojure
directory if $XDG_CONFIG_HOME
and CLJ_CONFIG
environment variables not set.
Via SSH
```shell
git clone git@github.com:practicalli/clojure-cli-config.git $HOME/.clojure
```
Via HTTPS
```shell
git clone https://github.com/practicalli/clojure-cli-config.git $HOME/.clojure
```
Check Configurationλ︎
clojure -Sdescribe
shows the version of Clojure CLI installed and configuration locations used.
The output of the command includes the version of Clojure CLI in the :version
key
{:version "1.11.1.1386"
:config-files ["/usr/local/lib/clojure/deps.edn" "/home/practicalli/.config/clojure/deps.edn" ]
:config-user "/home/practicalli/.config/clojure/deps.edn"
:config-project "deps.edn"
:install-dir "/usr/local/lib/clojure"
:config-dir "/home/practicalli/.config/clojure"
:cache-dir "/home/practicalli/.cache/clojure"
:force false
:repro false
:main-aliases ""
:repl-aliases ""}
clojure -Sversion
will shows the version of Clojure CLI being when theclojure
command is used to run a REPL or other Clojure command.
Optional rlwrap readlineλ︎
The rlwrap
binary is a basic readline tool that provides a history of commands entered into a terminal UI when running a Clojure REPL with the clj
wrapper script.
Pressing the Up and Down keys will scroll through the code previously entered in the REPL.
rlwrap
is available with most Linux systems. Look for install instructions by searching for rlwrap in a web browser or build from source from the rlwrap GitHub repository.
Use Rebel Readline for a rich terminal UI experience
rebel readline is an advanced readline tool providing auto-completion, documentation, signature help and multi-line editing, all within a terminal UI
Rebel is a much richer experience than the clj
wrapper with rlwrap
. Rebel should not be used with clj
.
Rebel Readline is part of the Practicalli Clojure CLI config.