Cider: Specify deps.edn alias

Created on 2 Aug 2018  ·  5Comments  ·  Source: clojure-emacs/cider

Expected behavior

That I can easily set a default collection of deps.edn aliases to use when I execute cider-jack-in

Actual behavior

I am unable to set a default collection of aliases to use with cider-jack-in

Steps to reproduce the problem

I have a deps.edn like so:

{:deps {}

 :paths ["src" "resources"]

 :aliases
 {:server {:extra-deps {org.clojure/clojure {:mvn/version "1.9.0"}
                        mount {:mvn/version "0.1.12"}
                        clj-time {:mvn/version "0.14.2"}
                        tick {:mvn/version "0.3.5"}
                        ring/ring-jetty-adapter {:mvn/version "1.6.3"}
                        cheshire {:mvn/version "5.8.0"}
                        garden {:mvn/version "1.3.3"}
                        com.taoensso/timbre {:mvn/version "4.10.0"}
                        hiccup {:mvn/version "1.0.5"}
                        org.clojure/tools.reader {:mvn/version "1.3.0"}
                        clj-http {:mvn/version "3.7.0"}
                        ring/ring-core {:mvn/version "1.6.3"}
                        org.clojure/core.async {:mvn/version "0.4.474"}}}

  :client {:extra-deps {thheller/shadow-cljs {:mvn/version "2.4.24"}
                        com.taoensso/timbre {:mvn/version "4.10.0"}}}

  :client/build {:main-opts ["-m" "shadow.cljs.devtools.cli" "release" "client"]}

  :dev {:extra-deps {binaryage/devtools {:mvn/version "0.9.10"}}
        :extra-paths ["dev"]}}}

To avoid loading server deps while building the client-side code, I had to move them to their own alias and leave the top-level deps map blank.

I would like to be able to somehow specify a set of aliases to use with this particular project, so that cider-jack-in would run clojure with -A:server:client:dev added to it.

Environment & Version information

CIDER version information

CIDER 0.18.0snapshot (package: 20180731.1750)
Clojure 1.9.0

;; CIDER 0.12.0snapshot (package: 20160331.421), nREPL 0.2.12
;; Clojure 1.8.0, Java 1.8.0_31

Lein/Boot version

N/A

Emacs version

Emacs 25.3.1

Operating system

macOS 10.12.16

Most helpful comment

For projects just put the project-specific config in a .dir-locals.el file. That's the standard Emacs mechanism to have project-specific configuration. See http://endlessparentheses.com/a-quick-guide-to-directory-local-variables.html

All 5 comments

I'd simply put this in cider-clojure-cli-global-options:

(setq cider-clojure-cli-global-options "-A:server:client:dev").

Btw, invoking cider-jack-in with a prefix arg will also prompt you for any extra params (e.g. C-u C-c C-x j j).

Thank you, I think the prefix arg (SPACE u SPACE m ' in spacemacs) is what I'll use.

I still think having some way of indicating this for a project (maybe a key in deps.edn?) would be nice but adding the -A:server:client:dev is not unreasonable.

For projects just put the project-specific config in a .dir-locals.el file. That's the standard Emacs mechanism to have project-specific configuration. See http://endlessparentheses.com/a-quick-guide-to-directory-local-variables.html

I tried this on a89b694cc3cec0294d84bf9dbe1163ad2373e8db and got the error:
Wrong type argument: listp, "-A:dev". I also tried (setq cider-clojure-cli-global-options '("-A:dev")) but that failed with a similar error: (wrong-type-argument listp cider-clojure-cli-global-options)

@ro6 you can find examples in the wild using grep.app: https://grep.app/search?q=cider-clojure-cli-global-options

I just checked with the following dir-locals.el file:

((nil
  (cider-clojure-cli-global-options . "-A:async")))

and jacking in gives me access to the async alias as verified by:

;; Connected to nREPL server - nrepl://localhost:50518
;; CIDER 0.26.1 (Nesebar), nREPL 0.8.0
;; ...
;;  Startup: /usr/local/bin/clojure -A:async -Sdeps '{:deps {nrepl {:mvn/version "0.8.0"} cider/cider-nrepl {:mvn/version "0.25.3"}}}' -m nrepl.cmdline --middleware '["cider.nrepl/cider-middleware"]'
user> 

I also checked out the commit you listed a89b694 and everything worked fine for me there as well. Finally i tried (setq cider-clojure-cli-global-options "A:cljs") and was also able to successfully start up with the alias:

;;  Startup: /usr/local/bin/clojure -A:cljs -Sdeps  ...

Can you go into more steps of what you are trying?

Was this page helpful?
0 / 5 - 0 ratings