Fix Clojure setup problems caused by shell startup files, `PATH`, `JAVA_HOME`, editor-launched REPLs, proxy variables, and project commands running in different environments.
Environment variable bugs are process bugs. Your terminal, editor, REPL, Maven process, Gradle daemon, and CI job may not inherit the same environment. A Clojure command that works in one place and fails in another is often using a different PATH, JAVA_HOME, working directory, proxy setting, or classpath alias.
Do not start by editing every shell file. First capture the environment used by the failing process.
| Variable | What it controls |
|---|---|
PATH |
Which java, clojure, clj, lein, mvn, and gradle executables are found first. |
JAVA_HOME |
Which JDK Java-aware tools should use when they honor the variable. |
HTTP_PROXY / HTTPS_PROXY |
Whether dependency downloads go through a corporate proxy. |
NO_PROXY |
Hosts that should bypass the proxy. |
MAVEN_OPTS / JAVA_TOOL_OPTIONS |
JVM options that can affect Clojure, Maven, Gradle, and tests. |
CLJ_CONFIG |
Optional Clojure CLI config directory override; useful but dangerous if forgotten. |
CLOJURE_HOME is usually not required for ordinary Clojure CLI use. If a guide tells you to set it, verify which tool actually reads it.
From the failing terminal:
1pwd
2env | sort
3which java
4which clojure
5java -version
6clojure --version
From a Clojure process, print the values the JVM actually sees:
1(System/getProperty "java.version")
2(System/getProperty "java.home")
3(System/getenv "JAVA_HOME")
4(System/getenv "PATH")
If the terminal and editor disagree, the editor is probably launching the REPL from a different shell mode or with a custom command.
On Unix-like systems, login shells, interactive shells, and GUI-launched apps may read different startup files.
| Shell context | Common files involved |
|---|---|
| zsh login shell | ~/.zprofile, then interactive config such as ~/.zshrc |
| zsh interactive terminal | ~/.zshrc |
| bash login shell | ~/.bash_profile, ~/.bash_login, or ~/.profile |
| bash interactive shell | ~/.bashrc |
| GUI-launched editor | Often does not inherit the same shell startup path as Terminal |
Put durable setup in the file your actual workflow reads. If an editor starts the REPL directly, configure the editor command or environment explicitly instead of assuming it reads your terminal profile.
PATH Without GuessingPrefer putting the chosen JDK and tool locations before older installs.
1export JAVA_HOME=/path/to/jdk
2export PATH="$JAVA_HOME/bin:/opt/homebrew/bin:$PATH"
Then verify:
1which java
2which clojure
3java -version
4clojure --version
If which java still points somewhere unexpected, another shell file or version manager is modifying PATH later.
When dependency resolution fails only on a corporate network, inspect proxy and certificate assumptions before changing dependency coordinates.
| Symptom | Environment check |
|---|---|
| Maven Central or Clojars cannot be reached | HTTP_PROXY, HTTPS_PROXY, NO_PROXY, Maven settings, and corporate TLS certificates. |
| Works in terminal but not editor | Editor process does not inherit proxy variables. |
| Works locally but not CI | CI job lacks proxy, credentials, or repository mirror configuration. |
| Works for Maven but not Clojure CLI | Maven settings may have repository/proxy config that the Clojure CLI command path does not share. |
Keep secret tokens and credentials out of shell config committed to Git. Use your team’s secret manager or CI secret mechanism.
After fixing the environment, document the command that should work:
1java -version
2clojure -Spath
3clojure -M:test
If the project uses Leiningen, Maven, or Gradle, document that command instead. The team needs one reliable path, not five local workarounds.