Fork me on GitHub
#dirac
<
2018-01-27
>
adamrenklint19:01:27

Just discovered Dirac, wow, am blown away. But I have an issue where I can see all the refers and aliases of the current namespace in the autocomplete menu, but when I try to access or use them, I get back undefined. Using the fully qualified symbols works just fine. Any guidance on how I can resolve this?

darwin20:01:56

hi, this will be tricky diagnose over slack, it would be great if you could isolate it to minimal case and share your project

darwin20:01:03

I would look into it

darwin20:01:01

btw. do you use figwheel or some hot-reloading? autocompletion goes out-of-sync for hot-reloaded code

adamrenklint20:01:26

Yeah, I have boot-figreload as well

darwin20:01:56

just make sure that you are seeing the problem after first full load without any hot-reloading

adamrenklint20:01:13

Yeah, that's the case

adamrenklint20:01:26

Will create a minimal repro :thumbsup:

darwin20:01:17

it uses clojure.tools.namespace.parse

darwin20:01:57

@adamrenklint wait, maybe you are not in proper namespace? did you use in-ns to switch? please follow https://github.com/binaryage/dirac-sample#hello-world

adamrenklint20:01:42

Yeah, definitely did that. A minimal repro comes in ~10 minutes, just finishing up the instructions.

darwin21:01:51

thanks, going look into that right now

darwin21:01:57

@adamrenklint having some problem running boot dev on my machine, clojure.lang.ExceptionInfo: Call to clojure.core/defn- did not conform to spec:

darwin21:01:02

what is your boot version?

adamrenklint21:01:17

Same as you 😕

darwin21:01:24

it looks like something is wrong with generate-lein-project-file! in boot

darwin21:01:55

I noticed my clojure updated recently (via homebrew), maybe they have some more strict specs included

adamrenklint21:01:34

Ok, let me install Clojure via Brew and see if I get the same error

darwin21:01:54

ok, mine is at 1.9.0.315

darwin21:01:01

brew info clojure

darwin21:01:52

hm, I switched brew to 1.9.0.297 and still the same issue, so that is probably not the case

adamrenklint21:01:32

Yeah, I have 1.9.0.315 via brew now, and boot dev is still working

adamrenklint21:01:47

Need to lookup what this generate-lein-project-file! is, never heard of it before

darwin21:01:42

I will try to disable spec checks for now

darwin21:01:11

I should be able to disable it via clojure.spec.skip-macros, but setting it as env variable does not work for me

darwin21:01:13

btw. no boot commands work, all throwing

darwin21:01:26

I’m going to install it differently

darwin21:01:28

not via brew

darwin21:01:07

hm, no, even their one-liner installer script is broken for me

darwin21:01:53

this is definitely something about my machine, investigating

adamrenklint21:01:14

But yeah, sounds like your machine has other issues

darwin21:01:59

the problem is how to force that fancy boot trace to show full paths

darwin21:01:14

maybe I have some obsolete boot version lingering somewhere and it is using it

darwin21:01:53

looking for a way how to disable it or at least change it to full paths

darwin21:01:54

the problem is that generate-lein-project-file! does not conform to fn or macro specs, so it looks like old code or I have too recent specs or my specs are somehow confused

darwin21:01:04

maybe by installing some dev version of clojure or something like that

adamrenklint21:01:00

It's weird, because the project I sent you has a boot.properties file, so the Clojure and Boot version used should come from there

adamrenklint21:01:29

Of course, the Boot loaded (a Go app, I think) is the one installed with Brew or by other means

adamrenklint21:01:50

Try deleting ~/.boot 😸

adamrenklint21:01:09

That's what I do when things get messy

adamrenklint21:01:07

Oh BTW, I have JDK9. Not sure how that would make a difference in any way, but mentioning it anyway

darwin21:01:51

ok, removing ~/.boot fixed it

darwin21:01:02

there was something fishy there I guess

darwin21:01:01

I’m not familiar with boot, didn’t start using it, but I agree it is a better way than lein

darwin21:01:13

ok, I confirm that your steps are reproducible here with my dev build of dirac

darwin21:01:20

so I will be able to investigate

adamrenklint21:01:24

Ok cool, so I'm not crazy 😛

darwin22:01:45

@adamrenklint I think the issue is in your REPL, normally you should do (require 'dirac-repro.core) before you in-ns into it

darwin22:01:15

this way REPL would be generating code aware of all definitions in the namespace

darwin22:01:26

but for some reason it does not work with your repl

darwin22:01:04

I’m not sure what boot is doing there, but we should be able to run stanalone clojurescript repl driven by boot and test it there

darwin22:01:38

btw. the code generated by the REPL can be seen in devtools unders Sources/left tree/dirac-repl

darwin22:01:56

it looks like require in your REPL is broken and it does not read the file

darwin22:01:00

on repl side

darwin22:01:42

(require 'dirac-repro.core) followed by (in-ns 'dirac-repro.core) and then as-aliased generates dirac_repro.core.as_aliased javascript

darwin22:01:36

it should generate dirac_repro.as_aliased javascript

adamrenklint22:01:32

When you say your repl, which piece are you referring to?

adamrenklint22:01:06

org.clojure/tools.nrepl?

adamrenklint22:01:31

Sorry, a complete noob when it comes to REPLs, so not much experience to draw from

adamrenklint22:01:42

A child of save->reload trying to evolve 🙂

darwin22:01:19

I’m not sure here, because whole REPL situation is pretty huge mess, right now I have unloaded whole context out of my head

darwin22:01:29

I’m now goint to try the same thing in dirac-sample project, which is driven by lein’s repl machinery, and compare the behaviour

darwin22:01:59

@adamrenklint ok, now I understand

darwin22:01:19

the system works as expected, your only mistake was not using require

darwin22:01:46

using namespace alias alone does not refer to the namespace javascript object, e.g. reagent or as-aliased alone is not treated as something meaningful

darwin22:01:00

as-aliased/some-func will work

adamrenklint22:01:53

Thanks for digging into it, much appreciated!

darwin22:01:20

I got confused by that namespace-only thing, I would also expect it to work

adamrenklint22:01:27

I'll boot up my large project and try it there

darwin22:01:57

btw. figwheel’s repl is able to do those requires automagically for you, because figwheel knows about your cljs project (for hotloading) and is loading them anyways

darwin22:01:26

but it is not easy to force dirac to use figwheel’s repl, that is very advanced setup

adamrenklint22:01:05

Ok, will read through that and play a bit 🙂

adamrenklint22:01:13

Is there a reference implementation of that setup somewhere?

darwin22:01:30

it starts vanilla clojure REPL, inside it starts figwheel’s sidecar and Dirac Agent

darwin22:01:49

Dirac should be able to detect this situation and talk to figwheel’s repl

adamrenklint22:01:03

Ok interesting, I'll give that a try tomorrow

adamrenklint22:01:13

Thanks a bunch for taking the time to help me!

darwin22:01:29

I just tested it and it works here, running lein repl-figwheel instead of lein repl

darwin22:01:41

then in dirac prompt dirac :fig shows fighweel status

darwin22:01:55

dirac :ls shows all compiler sessions on server side

darwin22:01:07

dirac :switch 2 switches to figwheel session in my case

darwin22:01:38

from that point repl is aware of hot-reloaded code and requires are no longer needed

darwin22:01:19

unfortunately dirac command in dirac prompt has broken formatting, some CSS went wrong, will fix this eventually