Closed martinklepsch closed 9 years ago
@the-kenny suggested to do
(in-ns 'chad-light.firebase)
(pani/push fb [:messages] {:test "test"})
and that indeed seems to work.
I can't replicate this. C-C M-n
swaps to the desired namespace in the REPL and I can access vars in that namespace from the REPL just fine.
May I ask how you got that nice debug message log? It'd be useful to compare my results with yours.
@tomjakubowski does your namespace require anything and did you try evaluating a function that came with one of the required namespaces? (I'm not sure if this could make a difference, just checking)
Logging can be enabled like this
(setq nrepl-log-messages t)
I'm going to walk through what I've done step by step. Here's my namespace:
(ns weasel-example.example
(:require [weasel.repl :as repl]))
(when-not (repl/alive?)
(repl/connect "ws://localhost:9002"))
(defn alive? [] (repl/alive?))
(defn foo [] 5)
And here's the HTML for this application:
<html>
<head>
<meta charset="UTF-8">
<title>Websocket browser-connected REPL through nREPL with Piggieback</title>
</head>
<body>
<div id="content">
<script type="text/javascript" src="out/goog/base.js"></script>
<script type="text/javascript" src="weasel_example.js"></script>
<input type="text" name="afield" id="afield"/>
<script type="text/javascript">
goog.require('weasel_example.example');
</script>
</div>
</body>
</html>
After running lein cljsbuild once
and piggiebacking, I open index.html
in a browser and use C-c M-n
to switch into the weasel-example.example
namespace in CIDER. I can see a change in the namespace at my prompt. I can run (alive?)
and (foo)
without issue at the REPL. If I run (def bar 10)
, I can see that var from the REPL and also from the browser's JavaScript console.
Here's a log of my CIDER session.
Thats not the issue I was describing, or tried to for that matter.
The issue I encountered was specifically related to running a function that I important from another namespace i.e. (:require [om.core :as om]) or something like this.
See previous messages for my actual ns form. Sorry for brevity I'm on the phone.
On Wednesday, February 11, 2015, Tom Jakubowski notifications@github.com wrote:
I'm going to walk through what I've done step by step. Here's my namespace:
(ns weasel-example.example (:require [weasel.repl :as repl]))
(when-not (repl/alive?) (repl/connect "ws://localhost:9002"))
(defn foo [] 5)
And here's the HTML for this application:
Websocket browser-connected REPL through nREPL with Piggieback After running lein cljsbuild once and piggiebacking, I open index.html in a browser and use C-c M-n to switch into the weasel-example.example namespace in CIDER. I can run (alive?) and (foo) without issue at the REPL. If I run (def bar 10), I can see that var from the REPL and also from the browser's JavaScript console.
Here's a log of my CIDER session https://gist.github.com/tomjakubowski/cbdc8d4560a71af85610.
— Reply to this email directly or view it on GitHub https://github.com/tomjakubowski/weasel/issues/46#issuecomment-73931183.
— Martin http://martinklepsch.org http://martinklepsch.org?ref=email
Ah, I see, sorry! I can run (repl/alive?)
from the REPL after changing into the example namespace too. See the addendum here: https://gist.github.com/tomjakubowski/cbdc8d4560a71af85610#file-addendum-txt
I should be sorry, didn't see you were calling repl/alive?
...
Yours:
(--->
op "eval"
session "6737b441-8f2a-4cd3-b13a-10473c81a07f"
code "(in-ns 'weasel-example.example)"
id "12"
)
[...]
(--->
op "eval"
session "6737b441-8f2a-4cd3-b13a-10473c81a07f"
code "(alive?)\n"
id "15"
)
Mine:
(--->
op "eval"
session "3bf51e12-8240-4885-811f-1807a8d7aaed"
code "(in-ns 'chaf-light.firebase)"
id "8"
)
[...]
(--->
op "load-file"
session "3bf51e12-8240-4885-811f-1807a8d7aaed"
file "(ns chaf-light.firebase)\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n(pani/push! fb [:messages] {:another-message \"TOLO\"})\n"
file-path "/Users/martin/projects/chaf-light/src/cljs/chaf_light/firebase.cljs"
file-name "firebase.cljs"
id "9"
)
This seems to be the difference. I'll check my versions and everything again. In the meantime maybe @bbatsov can give us a hint where that difference is coming from|?
@tomjakubowski could you let me know which versions of piggieback, weasel & nrepl?
@tomjakubowski is there a specific reason Weasel does not have an explicit dependency on piggieback
?
@martinklepsch If you get this log when pressing C-x C-e
you're not using the latest CIDER. Implementing eval
in terms of load-file
was removed about a month ago as it was causing problems with ClojureScript.
@bbatsov cider-nrepl
or emacs cider?
# Emacs
CIDER 0.9.0snapshot (package: 20150208.850) (Java 1.8.0_25, Clojure 1.6.0, nREPL 0.2.7)
# cider-nrepl
[cider/cider-nrepl "0.9.0-SNAPSHOT"]
I stil have no idea what the issue was but rm -rf ~/.m2/repository/cider
fixed it. Thanks everyone.
@martinklepsch there's no Piggieback dependency because you don't strictly need to use Piggieback to use Weasel. For example, you might want to launch a Weasel REPL from a script using (cljs.repl/repl (weasel.repl.websocket/repl-env))
, or something.
Basically similar problems as in #26.
cider-repl-set-ns
properly changes the ns in the REPL but when I try to evaluate something from the buffer that contains the namespace I get:The
ns
form of my namespace:And what I tried to evaluate with C-c C-c:
Also gisted the nrepl debug messages from Cider's
*nrepl-messages*
buffer.This is with Cider snapshot,
weasel 0.6.0-SNAPSHOT
,piggieback "0.1.6-SNAPSHOT
,nrepl "0.2.7
and Cider for Emacs also just updated.@bbatsov would you mind taking a look at the nrepl debug messages and tell me if those seem correct?