boot-clj / boot

Build tooling for Clojure.
https://boot-clj.github.io/
Eclipse Public License 1.0
1.75k stars 182 forks source link

Emacs cider-refresh #524

Closed darkleaf closed 6 years ago

darkleaf commented 7 years ago

Hi!

I use last cider, last cider-nrepl(v0.14.0) and last boot(2.6.0).

I read https://github.com/boot-clj/boot/wiki/Repl-reloading and this solution work for clojure.tools.namespace.repl. I want to use cider-refresh function inside emacs for repl reloading. But it dont't work because cider-nrepl don't use clojure.tools.namespace.repl internally. cider-nrepl use clojure.tools.namespace.dir directly instead.

I don't understand why I need specify classpath manually by repl/set-refresh-dirs. clojure.tools.namespace.dir use clojure.java.classpath/classpath-directories if dirs is empty. But (get-env :directories) equivalent (clojure.java.classpath/classpath-directories)

user> (pprint (get-env :directories))
#{"/Users/m_kuzmin/.boot/cache/tmp/Users/m_kuzmin/projects/hobby/quester/7xa/99bt35"
  "/Users/m_kuzmin/.boot/cache/tmp/Users/m_kuzmin/projects/hobby/quester/7xa/mh5540"
  "/Users/m_kuzmin/.boot/cache/tmp/Users/m_kuzmin/projects/hobby/quester/7xa/-boccbb"
  "/Users/m_kuzmin/.boot/cache/tmp/Users/m_kuzmin/projects/hobby/quester/7xa/7of19k"
  "/Users/m_kuzmin/.boot/cache/tmp/Users/m_kuzmin/projects/hobby/quester/7xa/aixfad"}
nil
user> (pprint (clojure.java.classpath/classpath-directories))
(#object[java.io.File 0x422da2ef "/Users/m_kuzmin/.boot/cache/tmp/Users/m_kuzmin/projects/hobby/quester/7xa/mh5540"]
 #object[java.io.File 0x7d131fcb "/Users/m_kuzmin/.boot/cache/tmp/Users/m_kuzmin/projects/hobby/quester/7xa/99bt35"]
 #object[java.io.File 0x6143b7d5 "/Users/m_kuzmin/.boot/cache/tmp/Users/m_kuzmin/projects/hobby/quester/7xa/aixfad"]
 #object[java.io.File 0x241dcabf "/Users/m_kuzmin/.boot/cache/tmp/Users/m_kuzmin/projects/hobby/quester/7xa/7of19k"]
 #object[java.io.File 0x61c7b9d0 "/Users/m_kuzmin/.boot/cache/tmp/Users/m_kuzmin/projects/hobby/quester/7xa/-boccbb"]
 #object[java.io.File 0x4cf0f64 "/var/folders/8n/79tfk40s6pn0yw8gqhtllw4m0000gn/T/boot-repl3209406117862786902"])
nil

How can I use cider-refresh with boot?

PS. cider-nrepl use thomasa/mranderson plugin so this plugin compile dependencies and add prefix for namespaces so we can't access to cider-nrepl deps.

Deraen commented 7 years ago

Only c.t.n 0.3 alpha uses clojure.java.classpath/classpath-directories. 0.2.11, which is still used by cider-nrepl, has it's own code which doesn't work with Boot, if I remember correctly. I have used 0.3 alpha without set-refresh-dirs successfully.

darkleaf commented 7 years ago

Ah, versions. It's my mistake. Thanks! cider-nrepl uses stable version of c.t.n and version hardcoded by thomasa/mranderson. So I write workaround solution for stable version.

(ns user)  ;; ns for repl

(defn setup-class-path []
  (let [separator (System/getProperty "path.separator")
        re-separator (re-pattern separator)
        curr-class-path (System/getProperty "java.class.path")
        curr-class-path-items (clojure.string/split curr-class-path re-separator)
        dirs  (get-env :directories)
        new-class-path-items (distinct (into curr-class-path-items dirs))  ;; distinct for idempotence
        new-class-path (clojure.string/join separator new-class-path-items)]
    (System/setProperty "java.class.path" new-class-path)))

(setup-class-path)

I manually setup "java.class.path". It's work. @Deraen, is this solution correct?

Deraen commented 7 years ago

I guess that works. Not sure if setting java.class.path some undesired other side-effects?

It is also possible to call set-refresh-dirs for c.t.n prefixed by mranderson, at least on 0.13 it is available as cider.inlined-deps.clojure.tools.namespace.repl/set-refresh-dirs.

SevereOverfl0w commented 7 years ago

This will be fixed by the next CIDER release containing https://github.com/clojure-emacs/cider-nrepl/pull/396

SevereOverfl0w commented 7 years ago

That release is now out, I expect this to work.

martinklepsch commented 6 years ago

Can anyone report back if this issue has been resolved?

And is this perhaps related to https://github.com/boot-clj/boot/issues/632?

SevereOverfl0w commented 6 years ago

This is fixed for me using the api from vim. I fully exist this to work.

632 is related, possibly fixed now by another change. But is tracked at refactor, can't be fixed by boot.

On 21 December 2017 22:06:38 GMT+00:00, Martin Klepsch notifications@github.com wrote:

Can anyone report back if this issue has been resolved?

And is this perhaps related to https://github.com/boot-clj/boot/issues/632?

-- You are receiving this because you commented. Reply to this email directly or view it on GitHub: https://github.com/boot-clj/boot/issues/524#issuecomment-353469587

-- Sent from my Android device with K-9 Mail. Please excuse my brevity.

martinklepsch commented 6 years ago

Alright, closing this since @SevereOverfl0w said it works. If it doesn't please feel free to reopen.