Skip to content

Commit

Permalink
[Fix #2230] Check for required libraries on the classpath
Browse files Browse the repository at this point in the history
  • Loading branch information
bbatsov committed Mar 6, 2018
1 parent 1e6504e commit 3d3c0ed
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
10 changes: 3 additions & 7 deletions cider-client.el
Expand Up @@ -808,13 +808,9 @@ going to clobber *1/2/3)."
t ; tooling
))

(defun cider-namespace-present-p (ns)
"Check whether NS is present or not."
(if (thread-first (cider-sync-tooling-eval (format "(if (find-ns '%s) 1 nil)" ns))
(nrepl-dict-get "value")
(read))
t
nil))
(defun cider-library-present-p (lib)
"Check whether LIB is present on the classpath."
(seq-find (lambda (s) (string-match-p (concat lib ".*\\.jar") s)) (cider-sync-request:classpath)))

(defalias 'cider-current-repl-buffer #'cider-current-connection
"The current REPL buffer.
Expand Down
12 changes: 7 additions & 5 deletions cider.el
Expand Up @@ -516,17 +516,17 @@ dependencies."

(defun cider-check-figwheel-requirements ()
"Check whether we can start a Figwheel ClojureScript REPL."
(unless (cider-namespace-present-p "figwheel-sidecar.repl-api")
(user-error "Figwheel is not available. Please check http://cider.readthedocs.io/en/latest/up_and_running/#clojurescript-usage")))
(unless (cider-library-present-p "figwheel-sidecar")
(user-error "Figwheel-sidecar is not available. Please check http://cider.readthedocs.io/en/latest/up_and_running/#clojurescript-usage")))

(defun cider-check-weasel-requirements ()
"Check whether we can start a Weasel ClojureScript REPL."
(unless (cider-namespace-present-p "weasel.repl.websocket")
(unless (cider-library-present-p "weasel")
(user-error "Weasel in not available. Please check http://cider.readthedocs.io/en/latest/up_and_running/#browser-connected-clojurescript-repl")))

(defun cider-check-boot-requirements ()
"Check whether we can start a Boot ClojureScript REPL."
(unless (cider-namespace-present-p "adzerk.boot-cljs-repl")
(unless (cider-library-present-p "boot-cljs-repl")
(user-error "The Boot ClojureScript REPL is not available. Please check https://github.com/adzerk-oss/boot-cljs-repl/blob/master/README.md")))

(defconst cider-cljs-repl-types
Expand Down Expand Up @@ -601,7 +601,9 @@ you're working on."

(defun cider-verify-piggieback-is-present ()
"Check whether the piggieback middleware is present."
(unless (cider-namespace-present-p "cemerick.piggieback")
(unless (cider-library-present-p "clojurescript")
(user-error "ClojureScript is not available. See http://cider.readthedocs.io/en/latest/up_and_running/#clojurescript-usage for details"))
(unless (cider-library-present-p "piggieback")
(user-error "Piggieback is not available. See http://cider.readthedocs.io/en/latest/up_and_running/#clojurescript-usage for details")))

(defun cider-create-sibling-cljs-repl (client-buffer)
Expand Down

0 comments on commit 3d3c0ed

Please sign in to comment.