Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REBL Setup #66

Closed
thecontinium opened this issue Oct 15, 2019 · 7 comments
Closed

REBL Setup #66

thecontinium opened this issue Oct 15, 2019 · 7 comments

Comments

@thecontinium
Copy link

Thanks for the latest release.

I am trying to get REBL working and have it configured as follows on a Mac with clojure installed by homebrew and:

dep.edn from (https://github.com/cognitect-labs/REBL-distro/wiki/Java-11-Usage)

{:deps {}
 :aliases
       {:rebl
        {:extra-deps
         {org.clojure/clojure {:mvn/version "1.10.1"}
          org.clojure/core.async {:mvn/version "0.4.500"}
          com.cognitect/rebl {:local/root "resources/REBL-0.9.220.jar"}
          org.openjfx/javafx-fxml     {:mvn/version "11.0.1"}
          org.openjfx/javafx-controls {:mvn/version "11.0.1"}
          org.openjfx/javafx-swing    {:mvn/version "11.0.1"}
          org.openjfx/javafx-base     {:mvn/version "11.0.1"}
          org.openjfx/javafx-web      {:mvn/version "11.0.1"}}
         :main-opts  ["-m" "cognitect.rebl"]}}}

and run the command:

clj -J-Dclojure.server.jvm="{:port 5678 :accept clojure.core.server/io-prepl}" -R:rebl

along with a clojure.edn

{:conns
 {:dev  {:port 5678
         :hooks {:connect! (fn [conn]
                            #?(:clj
                               (do
                                 (require 'cognitect.rebl)
                                 ((resolve 'cognitect.rebl/ui)))))
                 :result! (fn [{:keys [code result]}]
                           #?(:clj (cognitect.rebl/submit code result)))}}}

The REBL gui is displayed when I edit a new test.clj in neovim but no results are displayed in the REBL.

Does the setup look correct ?

Incidentally I get the same problem from the prepl unless I start a rebl directly from the command line with:

clj -J-Dclojure.server.jvm="{:port 5678 :accept clojure.core.server/io-prepl}" -R:rebl -m cognitect.rebl

rather than from within the prepl with:

clj -J-Dclojure.server.jvm="{:port 5678 :accept clojure.core.server/io-prepl}" -R:rebl 
(cognitect.rebl/ui)

any advice welcome. cheers.

@dharrigan
Copy link
Sponsor Contributor

dharrigan commented Oct 15, 2019

Hi,

This is my clojure deps.edn config, notice the :main-ops is not present:

  :rebl {:extra-deps {org.clojure/core.async {:mvn/version "RELEASE"}
                      org.clojure/data.csv {:mvn/version "RELEASE"}
                      org.clojure/data.json {:mvn/version "RELEASE"}
                      org.yaml/snakeyaml {:mvn/version "RELEASE"}
                      com.cognitect/rebl {:local/root "/home/david/development/workspaces/personal/clojure/rebl/rebl"}
                      org.openjfx/javafx-fxml     {:mvn/version "RELEASE"}
                      org.openjfx/javafx-controls {:mvn/version "RELEASE"}
                      org.openjfx/javafx-graphics {:mvn/version "RELEASE"}
                      org.openjfx/javafx-media    {:mvn/version "RELEASE"}
                      org.openjfx/javafx-swing    {:mvn/version "RELEASE"}
                      org.openjfx/javafx-base     {:mvn/version "RELEASE"}
                      org.openjfx/javafx-web      {:mvn/version "RELEASE"}}}

Then my conjure.edn config:

{:conns
 {:local
  {:port 55555}}
 :hooks
 {:connect! (fn [conn]
              (do (require 'cognitect.rebl)
                  ((resolve 'cognitect.rebl/ui))))
  :result! (fn [{:keys [code result]}]
             (cognitect.rebl/submit code result))}}

This works for me (once I'm in neovim, and I've connected to local and I eval an expression).

Hope that helps!

@Olical
Copy link
Owner

Olical commented Oct 15, 2019

Ah, that'll probably do it! I don't think you want the :main-opts since that starts a REBL UI through some other thread potentially? Leaving it up to Conjure to start is probably for the best, if that solves your issue I think the caveat will need to go into the README.

The REBL docs are correct other than that one thing I guess? (in the context of using it with Conjure)

@thecontinium
Copy link
Author

This setup works - thanks.
In the current readme

:result! (fn [{:keys [code result]}]
                           #?(:clj (cognitect.rebl/submit code result)))}}}}

does not work for me.

This does:

:result! (fn [{:keys [code result]}]
             (cognitect.rebl/submit code result))}}

@thecontinium
Copy link
Author

If I execute this:

(defn fib [x]
  (loop [n x result '(1 0)]
    (if (> n 1)
      (recur (- n 1) (conj result (+ (first result) (first (rest result)))))
      (rest (reverse result))
      )))

it has output in the REBL.
Followed by: (fib 10) gives no output to the REBL.

Can you see any reason for this ?

cheers

@Olical
Copy link
Owner

Olical commented Oct 16, 2019

Hmm, the reader conditional not working isn't great, I'll need to check that out. Really I don't need to recommend it since one conn is one language. I was mainly using reader conditionals in testing when I had the hooks at the top level so every connection got REBL if it was Clojure.

A fun experiment but not really a common use case.

With regards to the fib call: I'm really not sure... maybe lazy sequences aren't rendering correctly? I'll try to have a look soon. This issue will remain open until:

  • Documentation updated to show a minimal working REBL scenario.
  • Reader conditionals in hooks investigated. (I think some hooks will work, others won't depending on your current file name ending in .cljc or not.)
  • Your fib example is working.

@thecontinium
Copy link
Author

thecontinium commented Oct 16, 2019 via email

@Olical
Copy link
Owner

Olical commented May 1, 2020

Going to close this since the whole concept of hooks has gone in the new update. I'll have to reassess how REBL can be hooked in but I suspect it would just be nREPL middleware which would be so cool. Conjure doesn't even have to know about it!

@Olical Olical closed this as completed May 1, 2020
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

No branches or pull requests

3 participants