Fork me on GitHub
#cider
<
2016-04-29
>
bbss07:04:48

Hey cider loving folks, I just started to switch away from intellij towards spacemacs. So far so good. But I am running into an issue after running cider-jack-in-clojurescript

bbss07:04:37

I am connecting to a chrome extension. And so figwheel needs this option: :figwheel {:websocket-url ""}

bbss07:04:22

Seems that is not working when running with this approach. Any ideas where I can look?

bbss08:04:14

@plexus, thanks I did follow that one.

plexus08:04:27

yeah I just realized that's probably not the issue

bbss08:04:25

Yeah I think somehow the :figwheel option in [:cljsbuild :builds] build object is not being passed.

bbss08:04:43

But I am pretty new to emacs (second day trying)

plexus08:04:08

it does work from lein figwheel or lein repl ?

bbss08:04:33

let me have a look, usually run script/figwheel.clj using intellij cursive

plexus08:04:39

ok but if it works from there then your configuration isn't the problem, just making sure it's specific to cider

bbss08:04:23

let me doublecheck simple_smile

bbss08:04:35

okay it might be something different, not working in intellij anymore either. Thanks simple_smile

bbss08:04:03

Ah I got it. On to further exploring spacemacs and cider!

bbss10:04:17

So now I've been able to start those two nREPL's using cider-jack-in-clojurescript, my web-app connects but I can't evaluate (js/console.log "ello") in the repl, and evaluating using C-c C-e tells me:

user-error: `cider-eval-last-sexp' needs a ClojureScript REPL.
If you don't know what that means, you probably need to jack-in (`C-c M-J')

bbss10:04:21

Not sure how to proceed

plexus10:04:48

What do you get for M-: (cider-current-connection) ?

bbss10:04:13

Where do I look after running return? messages says #<buffer *cider-repl extension*>

plexus10:04:28

ah wait you're typing that in the repl, and then doing C-c C-e on it?

plexus10:04:51

what happens if you just hit return?

bbss10:04:26

I am typing that in the repl yes, I get an error, that evaluating C-c C-e was in the code file

bbss10:04:51

Was that the expected output of cider-current-connection?

plexus10:04:38

sorry, was just trying some stuff out

plexus10:04:19

I think that output is fine

plexus10:04:56

ok, I'm getting the same error

bbss10:04:38

Oh, I thought it might have been to do with my exotic figwheel/chrome-extension set-up.

plexus11:04:51

probably does have something to do with the figwheel setup, I'm using that snippet that's also in the wiki

plexus11:04:20

ok, so here's one problem: M-: (cider-current-connection "cljs") on a .cljs source file buffer should return a connection, but it returns nil

plexus11:04:54

(mapcar 'cider--connection-type (cider-find-connection-buffer-for-project-directory
                                      nil :all-connections))
;;=> ("clj" "clj")

plexus11:04:21

so CIDER thinks the figwheel REPL is a Clojure REPL

bbss11:04:17

Not that it is very helpful but cursive is also first a clj repl before it properly boots.

bbss11:04:56

I wish I could be more helpful/insightful but I am a super noob in emacs 😄

plexus11:04:27

as a workaround you can do this on the CLJS repl

plexus11:04:38

M-: (plist-put (cider--connection-properties (current-buffer)) :type "cljs")

plexus11:04:24

trying to figure out now how CIDER determines the type of each REPL

bbss11:04:44

That gives me: (:type "cljs" :host nil :port nil :project-dir nil)

plexus11:04:50

yeah, try to evaluate some code now

plexus11:04:37

do you see cljs.user> in your CLJS repl? otherwise figwheel isn't connected

bbss11:04:05

I don't see that

bbss11:04:37

The browser shows it's connected to figwheel though.

bbss11:04:32

` Caused by java.lang.RuntimeException No such namespace: js ... stacktrace `

bbss11:04:48

so yeah, not connected to figwheel

plexus11:04:12

yeah that might have more to do with your chrome extension stuff

bbss11:04:44

weird thing is, in the cljs (supposed) repl I get

;; You can disable it from appearing on start by setting
;; `cider-repl-display-help-banner' to nil.
;; ======================================================================
user> Figwheel: Starting server at 
nil

plexus11:04:13

that's not a lot... here's how it looks for me

bbss11:04:15

earlier today I got at least the notification from figwheel there.

bbss11:04:28

but I don't think I have a different project.clj now.

plexus11:04:32

;; You can remove this message with the ‘cider-repl-clear-help-banner’ command.
;; You can disable it from appearing on start by setting
;; ‘cider-repl-display-help-banner’ to nil.
;; ======================================================================
user> Figwheel: Starting server at 
Figwheel: Watching build - app
Compiling "resources/public/js/compiled/lambdaisland.js" from ["src"]...
Successfully compiled "resources/public/js/compiled/lambdaisland.js" in 1.535 seconds.
Figwheel: Starting CSS Watcher for paths  ["resources/public/css"]
Launching ClojureScript REPL for build: app
Figwheel Controls:
          (stop-autobuild)                ;; stops Figwheel autobuilder
          (start-autobuild [id ...])      ;; starts autobuilder focused on optional ids
          (switch-to-build id ...)        ;; switches autobuilder to different build
          (reset-autobuild)               ;; stops, cleans, and starts autobuilder
          (reload-config)                 ;; reloads build config and resets autobuild
          (build-once [id ...])           ;; builds source one time
          (clean-builds [id ..])          ;; deletes compiled cljs target files
          (print-config [id ...])         ;; prints out build configurations
          (fig-status)                    ;; displays current state of system
  Switch REPL build focus:
          :cljs/quit                      ;; allows you to switch REPL to another build
    Docs: (doc function-name-here)
    Exit: Control+C or :cljs/quit
 Results: Stored in vars *1, *2, *3, *e holds last exception object
Prompt will show when Figwheel connects to your application
To quit, type: :cljs/quit
nil
cljs.user> 

bbss11:04:51

Right, that part.

bbss11:04:00

Okay I will try to mess around some more.

bbss11:04:06

Thanks for taking a look for me simple_smile

plexus11:04:23

I would do a cider-quit, then lein clean to make sure you have no old build artifacts getting in the way, then try lein figwheel to see if figwheel is happy building your project

bbss11:04:43

Okay good suggestion.

plexus11:04:44

if that's all good then come back to cider

bbss11:04:25

is there a way to have a shell buffer?

plexus11:04:30

I'll open an issue about the REPL type, looking at cider-nrepl it seems it only takes piggieback-based repls into account, and I believe the Figwheel REPL isn't based on piggieback

plexus11:04:09

there's ansi-term which mostly behaves like a regular terminal, and there's eshell which is a shell implemented in elisp

bbss11:04:25

because I think if it is not fire and forget then shell-command doesn't cut it?

plexus11:04:30

personally I still do terminal stuff outside of emacs, opinions vary on this

plexus11:04:32

it can get messy with keybindings, especially with command line apps that do their own input handling. And also things that use a lot of escape codes like ncurses based apps will look a bit weird

bbss11:04:50

Okay, makes sense.

plexus11:04:59

YMMV... my workflow is a terminal with tmux next to my emacs

plexus11:04:21

hmmm I may be wrong, to use figwheel with nrepl you should be using piggieback, in which case cider should detect it

plexus11:04:49

and indeed, once figwheel has connected and you see cljs.user> the repl type is correctly set to "cljs". If you try to evaluate before that you will get the "needs a ClojureScript REPL" error

xcthulhu15:04:21

@bbss: I was getting this from time to time until recently

xcthulhu15:04:13

The problem I had is that I didn't have my cljs code in my top-level :source-path and my :test-path ; I had it in a :dev profile

xcthulhu15:04:40

CIDER is sensitive to this; if it can't figure out the file you are clojurescript source in one of those paths specified at the top on leiningen then cider-jack-in-clojurescript has the behavior you are describing

thiagofm16:04:15

I have some feature ideas which I would love to cider have. Anybody can recommend a starting point to contribute with cider?

dpsutton16:04:10

clone/implement/PR

dpsutton16:04:37

also, you can open an issue on the issue tracker to discuss your issue, hear feedback, possible implementations, get collaborations, etc

malabarba20:04:57

@thiagofm: Also feel free to bring these ideas up here or on gitter

malabarba20:04:24

we'll be happy to give pointers on how to implement it

thiagofm20:04:49

I want to make a reverse debugger

thiagofm20:04:35

go back in the clojure call stack

thiagofm20:04:40

would probably involve hacking around with https://github.com/clojure/tools.trace

edbond20:04:28

Clojurescript repl question, every command results in "needs a ClojureScript REPL". I actually have it, alerts shows in browser. What I need to do to evaluate code in browser?

edbond20:04:50

I am using figwheel-sidecar, started repl using cider-jack-in-clojurescript