This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-02-21
Channels
- # architecture (9)
- # beginners (192)
- # boot (1)
- # bristol-clojurians (2)
- # cider (213)
- # cljs-dev (10)
- # clojure (195)
- # clojure-art (2)
- # clojure-austin (3)
- # clojure-belgium (4)
- # clojure-dev (4)
- # clojure-dusseldorf (1)
- # clojure-gamedev (9)
- # clojure-greece (21)
- # clojure-italy (27)
- # clojure-losangeles (2)
- # clojure-russia (1)
- # clojure-seattle-old (2)
- # clojure-serbia (1)
- # clojure-spec (114)
- # clojure-uk (136)
- # clojured (2)
- # clojurescript (100)
- # community-development (19)
- # core-async (12)
- # cursive (7)
- # duct (1)
- # figwheel (7)
- # fulcro (96)
- # hoplon (4)
- # jobs (2)
- # lein-figwheel (28)
- # leiningen (2)
- # luminus (14)
- # lumo (3)
- # off-topic (11)
- # om-next (2)
- # pedestal (10)
- # planck (11)
- # portkey (2)
- # proton (1)
- # protorepl (19)
- # re-frame (27)
- # reagent (12)
- # shadow-cljs (82)
- # spacemacs (42)
- # specter (15)
- # sql (3)
hey folks
took a clojure gig, trying to use cider, i’m an experienced emacs user
i can’t for the life of me get cider-find-var
to work, just says Symbol 'blah/foo' not resolved
no matter what I do, I’m surprised since cider should have access to the jvm and language object model
I’m jacked into a lein
project too and have the nREPL running
any leads? any help would be greatly appreciated
also curious if methods like cider-find-ns
work for *.cljs
@iwannaseethelight 1.) did you compile the code you're trying to resolve a symbol in? 2.) If you did, how did you start the nrepl, and is there a warning at the top of the repl buffer
hey @tanzoniteblack, I just navigated to my lein
project, booted up emacs, and executed M-x cider-jack-in
it’s running properly it seems (it’s a web server)
so that's a yes on the first one then? That you've run cider-load-buffer
or something similar to load the code in the running repl environment?
it seems that M-x cider-jack-in
loads the lein
project, no?
i haven’t explicitly loaded any code
but i can go to the cider repl and execute functions
that are in the project, it’s clearly running
@iwannaseethelight I don’t think that cider-find-var
can discover code you haven’t loaded.
so if (the-ns 'your-missing-namespace)
doesn’t work in the REPL CIDER won’t be able to find it either.
so cider doesn’t load all clojure code in your project?
doesn’t that .. sort of make cider-find-var
totally pointless 😛
No it doesn’t. cider-find-var
works great once you’ve loaded your code and are deving.
basically i’m trying to replicate jump to function / symbol
there are about 500 clojure scripts in this big project
i was under the impression that cider was talking to the jvm over nREPL
Remember, CIDER is a feature layer for REPLs with the expectation that your code is loaded into Clojure all the time.
i’m clearly missing something
i’m coming from c++ land at any rate
I guess I thought that when you jack in, it starts up the jvm, loads your project, and communicates with it over the repl
i thought that find var would just ask the jvm about a symbol / function and return a result to you
So think about it this way. When you “boot a REPL” you’re telling the JVM “here’s my main(), go run that”. In this case, your main is the nREPL entry point, so it loads nREPL and Clojure and anything else required to stand the server up.
The JVM only loads code when it needs to, so until you go explicitly (require 'your-ns)
or something else Clojure, nREPL and the JVM are completely oblivious to the fact that it’s valid code.
So if you open up one of your scripts and C-c C-k
to compile and load the namespace, then it’ll be loaded into your nREPL connection and you’ll be able to explore it with cider-find-var
and cider-find-ns
.
Does that help @iwannaseethelight?
question on that - does loading a namespace also load dependencies?
thereby allowing you to jump to shit
so you have to load a file, jump to var, load that file, jump to another thing ..
i wonder if there’s a way to improve that workflow
No. You load one file, and that causes all of its transitive dependencies to become loaded, and then you can go wherever.
i guess I could defadvice around cider-find-var
to load the file first
sort of gross
actually wait
i’m assuming dependencies are loaded recursively
so if i load file a, and it imports namespace b, which imports c, c is implicitly loaded when a is
so i should be able to jump to shit in c
that user.clj
- is that a project-level thing? apologies, new to clojure dev
clojure.core/*loaded-libs*
is a collection of all the namespaces that Clojure thinks it has loaded.
user.clj
is a magical file that clojure.lang.RT
loads before it goes and does whatever you asked it to such as booting nREPL. Typically people will put it in a dev
directory and use it for development utilities.
oh on that note haha - i notice that cider seems to create a user
ns, which sucks because this huge project declares a user
ns so none of the autocomplete works for user
unless it’s fully qualified ..
jesus, I just discovered M-,
, i’ve been a hardcore emacs user for 10+ years, how have I not know about that command
cider-pop-back
i wonder if there’s a way to prevent that, it’s causing problems unfortunately
probably a setting i’m guessing
well i have no problems with a user
ns but unfortunately they declare things like a.b.c.user
, and if you type user/..
nothing happens unless you fully qualify user
in other words, if i’m in like thebigproject.main
, and it imports a.b.c.user :as user
, and you then type user/..
at the repl or in code, nothing happens
cause it thinks you’re referring to the user
ns
so in that file, they import a.b.c.user :as user
yep it’s loaded, everything else works except for user/
Being “in” that namespace != it being loaded FWIW. You can C-c M-n
to namespaces that aren’t loaded yet.
well it’s the main ns that gets loaded when the project is booted via jack in
the repl prompt says thebigproject.main
i mean, it clearly seems to be loaded no?
🤷 recompiling a namespace is super cheap I usually just C-c C-k
all the time just to be sure.
interestingly, some others don’t appear to work
they have one that’s like [a.b.c :as c]
c/ doesn’t work
but others next to it do with longer names
Yeah that probably means that you’re “in” the namespace, but the namespace hasn’t been loaded so it’s empty.
can you restate that?
didn’t quite parse 🙂
btw, that :as c
thing up there
if i type a.b.c/
it works fine
but it doesn’t if it’s just c/
bug maybe?
No worries. Being “in” a namespace means that clojure.core/*ns*
points to the namespace named thebigproject.main
. Changing current namespace to thebigproject.main
via (in-ns 'thebigproject.main)
will create that namespace and set *ns*
appropriately, but it won’t load any code in the file that corresponds to thebigproject.main
.
This means that you’re “in” the namespace, but the (ns)
form that defines all your (:require ... :as ...)
hasn’t been executed
would i do like
why do some aliases work then?
Because they aren’t the aliases they’re the fully qualified names I think based on what you’re saying.
yeah just tried that, no change
for c/
or user/
- everything else works
in other words, i have other aliases like a.b.x.stuff foobar
and foobar/
works
thanks for your time btw 😉
ah shit haha
that’s just funny
hah, you’re right.
not sure about user/
nothing happens with user
kinda sucks, they use it all over the place unfortunately
nothing happens for that
interestingly, if i do like
yep, fully qualifying works
btw, just did this
switched to user
ns in repl, defined two functions, switched back
then user/
shows those two functions as completions
i wonder if there’s a way to change the name of that generated ns
maybe it can be deleted? 😛
that’s really hacky though
you’d think that it’d use the most derived (aka, the alias in the ns i’m in)
btw, do you usually do (in-ns 'thing)
at the repl to switch?
ah kewl
2 other questions btw
is there a separate repl for cljs?
@iwannaseethelight (ns-aliases *ns*)
what does that print?
strange, it says user #namespace[x.y.z.user]
that’s odd
i’d add another alias but it’d piss everyone off 😉
did you say you can execute custom clojure when the repl boots up?
yeah seems so
maybe i should file a bug
are you a maintainer?
I’m a contributor to CIDER and a bunch of other stuff but I don’t maintain anything worthwhile.
i was curious, there’s a helm
interface to the repl history etc, but there doesn’t seem to be for cider-find-ns
et al
oh scratch that, there is for cider-find-ns
but not for jump to symbol i guess, because it uses what’s under point?
thought i’d just be able to start typing which would be ideal
maybe there’s nothing quite like that
is there one where you can just start typing though
that’d be pretty nice
i wonder if there’s a ivy one
that’s a pretty common thing
unless folks are using just like helm-do-ag or something
helm-do-ag
rather
you use emacs much?
at any rate, thanks for all your help!
oh, i remember another question - is there a separate repl for cljs
?
or am i just fucked there 🙂
There is a separate REPL - figwheel was how people did that song and dance last I checked but I don’t have much experience on that side of the house.
cheers
if anyone else happens to show up in this channel, what’s the proper way to boot up a clojurescript repl, and can you have both a clojure and clojurescript repl going at the same time in emacs?
you can have both going; let me see if I can find a good readme on getting that set up right
https://github.com/bhauman/lein-figwheel/wiki/Using-the-Figwheel-REPL-within-NRepl ; if you already have figwheel set up in the way specified in the beginning you can jump down to https://github.com/bhauman/lein-figwheel/wiki/Using-the-Figwheel-REPL-within-NRepl#integration-with-emacscider
and as an FYI, while that example suggests setting the emacs variable cider-cljs-lein-repl
in your .emacs.el
or .emacs.d/init.el
; I'd actually recommend putting a file called .dir-locals.el
in the root directory of your project (i.e. next to project.clj
) with the contents:
((nil . ((cider-cljs-lein-repl . "(do (require 'figwheel-sidecar.repl-api)
(figwheel-sidecar.repl-api/start-figwheel!)
(figwheel-sidecar.repl-api/cljs-repl))"))))
This accomplishes the same thing, but sets this variable per project, instead of globally@tanzoniteblack thanks! so that .dir-locals.el, is that read from cider
?
i assume it’s just arbitrary elisp
It's a emacs thing, nothing cider specific
I need some help on this question https://emacs.stackexchange.com/questions/38857/the-formatted-string-passed-to-cider-eval-function-error. Can confirmed the problem is on Elisp CIDER side. The problem is as this comment said https://emacs.stackexchange.com/questions/38857/the-formatted-string-passed-to-cider-eval-function-error#comment61517_38857
This problem is really weird.
Is there some elisp guru want to check it out?
@tanzoniteblack when is that file being loaded? and by what package?
Umm... Going offline now for family time, but it's a built in emacs thing, no special package https://www.gnu.org/software/emacs/manual/html_node/emacs/Directory-Variables.html
thanks i’ll take a look
I'm brand new to emacs using spacemacs and cider. I'm running into this issue where when I send an expression for evaluation at the repl, one of my CPU cores jumps up to 100% usage, and spacemacs freezes totally. Killing the process, restarting, and evaluating that same expression seems to work fine (making me think I didn't necessarily create an infinite loop in my code). Any ideas?
So it happens once in a while, but not every time? And not necessarily the same expression?
I feel like I’ve seen a similar odd long pause “at first” before, but I can’t recreate and I’m not sure what the issue was. I think I just upgraded around then when new versions came out and it magically vanished.
What version of cider does spacemacs install?
Someone put an issue that they saw this when they ran lein repl outside of a project
At the time it wasn’t reproducible, according to the ticket.
You have good memory recall, @dpsutton
Don't have time to commit as much due to school and full time job so I try to at least follow along
Thanks for the input, @dpsutton , @gonewest818. I'm less confident now than I was initially that I'm not just creating infinite loops. In any case, discovering that spamming C-g quickly remedies things has got me back in business for now. I'll keep a watch of that issue and keep looking around if the problem persists.
Another thing to watch out for is printing excessive output to the repl. There are settings you can use to limit repl output (`*print-length*` and *print-level*
), and starting with CIDER 0.17.0, I’m pretty sure CIDER will override those settings even if you’ve configured them in ~/.lein/profiles.clj
. See https://github.com/clojure-emacs/cider/issues/2160
But if you’re using CIDER 0.16 and you haven’t configured those settings, then I would watch for things that print long lists to the repl. (e.g. (range N)
with a large N, or an infinite (range)
)
@triss https://clojurians.slack.com/archives/C03S1KBA2/p1519255131000429 set the emacs variables cider-repl-use-pretty-printing
to t
and cider-pprint-fn
to 'pprint
(or one of the other options: https://github.com/clojure-emacs/cider/blob/master/doc/configuration.md#pretty-printing )