Skip to content

Conversation

@carloshernandez2
Copy link
Contributor

Fix: Add missing org.clojure/java.classpath dependency

Problem

When using metrepl as an nREPL middleware in projects without org.clojure/java.classpath on the classpath, the REPL fails to start with:

Error loading metrepl.middleware.op-metrics: Syntax error macroexpanding at (metrepl/metrics.clj:1:1).
Error loading metrepl.middleware.tests-metrics: Syntax error macroexpanding at (metrepl/metrics.clj:1:1).

When attempting to require metrepl manually:

(require 'metrepl)
;; Execution error (FileNotFoundException) at metrepl.metrics/eval5380$loading (metrics.clj:1).
;; Could not locate clojure/java/classpath__init.class, clojure/java/classpath.clj or clojure/java/classpath.cljc on classpath.

Root Cause

metrepl.metrics namespace requires clojure.java.classpath:

(ns metrepl.metrics
  (:require
   [clojure.java.classpath :as classpath]  ; <-- this dependency is not declared
   ...))

However, org.clojure/java.classpath is not declared as a dependency in deps.edn. This works in many projects because they transitively pull in java.classpath through other dependencies, but fails in minimal projects (like new Leiningen projects with only org.clojure/clojure as a dependency).

Solution

Add org.clojure/java.classpath as an explicit dependency in deps.edn.

Testing

Verified the fix resolves the issue in a minimal Leiningen project that previously failed to start the REPL with metrepl middleware enabled.

@ericdallo ericdallo merged commit bfc0d99 into ericdallo:master Jan 29, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants