Fork me on GitHub
#cider
<
2015-07-22
>
malabarba00:07:49

chris_johnson: Yes, thanks for catching that. :)

Chris Bidler00:07:14

so I’m sure I’m still just missing something simple

malabarba00:07:58

What's your issue?

Chris Bidler00:07:36

but I’m trying to just run a really simple Reagent project in my beloved emacs/CIDER environment and when I follow those instructions, after M-x cider-jack-in-clojurescript I get CompilerException java.lang.ClassNotFoundException: weasel.repl.websocket, compiling:(path/to/ugly/filename.clj)

Chris Bidler00:07:38

I’ve come so far but googling for that leads mainly to a Reddit thread where someone is asking about setting up vim-fireplace with Figwheel 😐

Chris Bidler00:07:15

I know that the landscape is very much in flux, and I have not been keeping up with it as well as I’d like, so maybe what I’m trying to do still can’t be done

Chris Bidler00:07:31

I am on 0.10.0snapshot of CIDER and cider-nrepl

malabarba00:07:50

It certainly can be done

malabarba00:07:02

but it's possible I've misconfigured something

malabarba00:07:11

is weasel in your deps?

malabarba00:07:18

What happens if you start a regular cider-jack-in, and then evaluate (weasel.repl.websocket/repl-env :ip "127.0.0.1" :port 9001) at the repl?

Chris Bidler00:07:35

` :dependencies [[org.clojure/clojure "1.7.0"] [org.clojure/clojurescript "0.0-3308"] [reagent "0.5.0"] [weasel "0.6.0"] [com.cemerick/piggieback "0.2.1”]]` that’s my deps form from project.clj

Chris Bidler00:07:49

aaaand backtick doesn’t work across lines :d’oh:

malabarba00:07:08

I got the gist ;)

Chris Bidler00:07:59

ClassNotFoundException weasel.repl.websocket java.net.URLClassLoader.findClass (URLClassLoader.java:381)

malabarba00:07:33

Ok, and what if you (require 'weasel.repl.websocket)?

malabarba00:07:28

If that also fails, then there's something fishy going on

malabarba00:07:37

Since weasel is clearly in your deps

malabarba00:07:02

That fixed it?

Chris Bidler00:07:18

or at least it returned #weasel.repl.websocket.WebsocketEnv{:ip "127.0.0.1", :port 9001}

malabarba00:07:02

then I guess I've misconfigured the feature :)

malabarba00:07:46

Actualy, before I jump to conclusions, evaluate this on the repl, and tell me if it gives you a cljs repl:

malabarba00:07:57

(cemerick.piggieback/cljs-repl (weasel.repl.websocket/repl-env :ip "127.0.0.1" :port 9001))

Chris Bidler00:07:09

yeah, I’m very much certain that this is a case of me doing something wrong

Chris Bidler00:07:17

well, it tried - I got an IOException: No client connected to websocket

Chris Bidler00:07:44

and I can’t seem to hit localhost:9001 with a browser

malabarba00:07:29

that's still progress

Chris Bidler00:07:29

though it did give me a cljs.user> repl prompt

malabarba00:07:11

Did you add something like this to your core namespace?

malabarba00:07:20

`clojure (ns my.cljs.core

malabarba00:07:23

(:require [weasel.repl :as repl])) (repl/connect

malabarba00:07:26

"<ws://localhost:9001>") `

malabarba00:07:48

(ns my.cljs.core
  (:require [weasel.repl :as repl]))
(repl/connect "")

malabarba00:07:25

I think that's the part that connects to the websocket

malabarba00:07:32

Maybe you'll need to evaluate it

malabarba00:07:48

I didn't write that part, so I'm not 100% sure

malabarba00:07:36

I think maybe it was @cichli who wrote that part?

malabarba00:07:41

I'll update the cider-cljs-repl variable with the require

malabarba00:07:04

chris_johnson: Could you check something for me?

malabarba00:07:33

Evaluate the following in Emacs (setq cider-cljs-repl "(do (require 'weasel.repl.websocket) (cemerick.piggieback/cljs-repl (weasel.repl.websocket/repl-env :ip \"127.0.0.1\" :port 9001)))")

malabarba00:07:24

Then quit the repl, and try that cider-jack-in-clojurescript command

malabarba00:07:18

I just want to know if this fixes the ClassNotFoundException

Chris Bidler00:07:33

okay, nREPL server starting up

Chris Bidler00:07:55

so that got further - I get both the CLJ and CLJS REPLs in separate frames

Chris Bidler00:07:13

but the cljs REPL still throws the IOException

Chris Bidler00:07:57

interestingly, it throws it again if I go find that (repl/connect “<ws://localhost:9001”>) line in core.cljs and C-c C-k

Chris Bidler00:07:03

I’d think I need to have a browser loading the page somewhere for the Weasel REPL to work but I can’t figure out where I am either starting a server, or what port to try and hit

Chris Bidler00:07:15

that’s, again, probably something I’m doing not quite right

Chris Bidler00:07:55

thank you so much for taking the time to help me with this, by the way. I hope that I’m actually helping you test new stuff with my flailing about simple_smile

malabarba00:07:00

I'm reading their Readme now

malabarba00:07:45

Apparently, you should get a message like`

malabarba00:07:49

<< started Weasel server on ws://127.0.0.1:9001 >>

malabarba00:07:49

<< waiting for client to connect ...

Chris Bidler00:07:41

"Weasel will block the REPL, waiting for a client to connect."

Chris Bidler00:07:52

The lie detector determine that statement …was a lie.

Chris Bidler00:07:53

though my dependency is 0.6.0, not 0.7.0

Chris Bidler00:07:58

let me see what happens if I change that

Chris Bidler00:07:59

<< waiting for client to connect...

malabarba00:07:01

Did it work?

Chris Bidler00:07:51

okay, I’m much further along and have a better understanding of what I’m doing

malabarba00:07:51

Maybe see if you can get it to work manually, by following those steps on a regular clojure repl

malabarba00:07:51

If that works then we can figure out what Cider is doing wrong.

malabarba00:07:04

Those were some old messages

malabarba00:07:14

I'm on a crappy connection

malabarba00:07:33

Now. IIUC, that repl/connect snippet needs to be part of your clojurescript code, which I think should be compiled and opened in the browse.

malabarba00:07:45

But really, I'm working of what I'm reading :-)

malabarba00:07:04

I've never used weasel, so I could be wrong

malabarba00:07:13

Anyway It's pretty late here. So I gotta go. But let us know how this goes.

Chris Bidler00:07:32

I was thinking I needed to be serving up a webpage

Chris Bidler00:07:43

yeah, no problem - thanks again so much for your help

malabarba00:07:41

Yeah, that's what I thought too, but that cljs snippet needs to be run somehow. And I think you can't run it in the repl if you don't have a repl yet...

malabarba00:07:21

But these are very bold statements from a very tired person. :-) good night and good luck.

jrychter08:07:02

Just as a data point: I never got the weasel+piggieback combination to work. Not once. And not for the lack of trying. I finally gave up: for ClojureScript development I just use figwheel with its reloading, and println for debugging. Perhaps one day…

robert-stuttaford08:07:52

i echo that basic outcome

robert-stuttaford08:07:10

figwheel + println has been the only sustainable way i’ve been able to work

malabarba08:07:54

The cljs rhino repl worked as advertised for me out of the box. But all I did was start it and play around a bit.

robert-stuttaford08:07:13

@malabarba: do you perhaps know how i might configure a variant of an emacslisp global-set-key i have to use the C-u prefix variant to run an alternate function?

malabarba08:07:25

Weasel hasn't worked yet either

robert-stuttaford08:07:58

i’d like to run the first defun here when i C-u C-c r, and the second when i simply C-c r:

malabarba08:07:05

@robert-stuttaford yes, you need to define a new command

robert-stuttaford08:07:12

i tried simply giving it that keybind but it scolded me

malabarba08:07:16

Indeed, you can't bind C-u SOMETHING in Emacs

malabarba08:07:05

You have to write a command that checks forthe prefix, and then calls the appropriate function. And then bind this command to C-c r

robert-stuttaford08:07:14

found http://ergoemacs.org/emacs/elisp_universal_argument.html. i’m sure i’ll figure it out now, thank you

malabarba08:07:28

(defun run-the-test (first)
  (interactive "P")
  (call-interactively
   (if first #'the-first-command
     #'the-second-command)))

malabarba08:07:31

Something like this

malabarba08:07:16

That "P" inside interactive specifies that the first argument is the prefix argument.

robert-stuttaford09:07:08

what is the purpose of call-interactively, there?

robert-stuttaford09:07:08

awesome. works great. thank you, sir!

malabarba09:07:41

robert-stuttaford: It mimics the effect of you invoking those commands through a keybind

malabarba09:07:20

Like passing them some arguments, and setting the value of some interactive variables

malabarba09:07:27

But it's probably not necessary in your case

malabarba09:07:45

You can just use (the-first-command)

Chris Bidler13:07:51

well alright, I’ve gotten (js/alert “Hi, Mom!”) to put up an alert via the Weasel cljs repl

Chris Bidler13:07:35

and while that’s pretty cool, I cannot seem to make changes to core.cljs and see them show up even by reloading the webpage so

Chris Bidler13:07:44

I guess it’s off to figwheel + println for now. Thanks a ton @malabarba for all your assistance, also to @jrychter and @robert-stuttaford for sharing your experience and letting me know that it maybe wasn’t all user error I was running into. simple_smile

malabarba16:07:06

@chris_johnson I'll certainly go into this again when I need to do cljs, then you can be sure we'll make it work our of the box

malabarba16:07:25

And I'll let people know here :-)