Fork me on GitHub
#cursive
<
2019-05-11
>
cfleming02:05:50

@nwjsmith Yes, in Preferences | Editor | Code Style | Clojure set Scheme to Project.

kari07:05:56

I found something weird and I'm not sure if I just don't understand how to use REPL or is this a Cursive issue or what. A short explanation. I have mydev.clj in which I keep all kind of development time stuff like:

(defn reset []
  "Resets REPL and starts server."
  (log/debug "ENTER reset")
  (mount/stop)
  (ns-repl/refresh :after 'mydev/start))
I.e. to be able to stop mount states and then refresh everything and start mount states again. I have e.g. my configuration in mount: simpleserver.util.config/config-state (basically reads the configuration from file). Then the weird part. I have a scratch file in IDEA in which I send expressions to REPL with Cursive hot key (Send form before caret to REPL), e.g.:
(mydev/reset)
simpleserver.util.config/config-state
I.e. I first refresh everything and then check the config that my new configuration changes are there. But they are not. BUT: If I go into the actual REPL input window and write those lines there and send them to REPL I can see my configuration changes. This really puzzles me - have I understood something wrong since I thought that the result should be same with both scenarios (send the expressions to REPL using hot key and writing the same expressions in REPL window and sending them to REPL for evaluation there).

kari07:05:39

I think I got it now but I still don't understand the behaviour. The REPL output window says in the first screnario (when I'm sending the expressions with hot key from scratch file):

2019-05-11 10:23:06 DE [nRepl-session-a9d217fb-3d2c-4016-aae3-7e37ca090cc5] DEBUG mydev - ENTER reset
2019-05-11 10:23:06 DE [nRepl-session-a9d217fb-3d2c-4016-aae3-7e37ca090cc5] DEBUG mydev - ENTER stop
2019-05-11 10:23:06 DE [nRepl-session-a9d217fb-3d2c-4016-aae3-7e37ca090cc5] DEBUG mydev - ENTER start
2019-05-11 10:23:06 DE [nRepl-session-a9d217fb-3d2c-4016-aae3-7e37ca090cc5] DEBUG simpleserver.util.config - ENTER create-config
:reloading ()
=> Mount starts and only after that the reloading is happening. In the second scenario (I write the expressions in the REPL input window):
2019-05-11 10:23:16 DE [nRepl-session-a9d217fb-3d2c-4016-aae3-7e37ca090cc5] DEBUG mydev - ENTER reset
2019-05-11 10:23:16 DE [nRepl-session-a9d217fb-3d2c-4016-aae3-7e37ca090cc5] DEBUG mydev - ENTER stop
:reloading ()
=> {:started ["#'simpleserver.util.config/config-state"]}
2019-05-11 10:23:16 DE [nRepl-session-a9d217fb-3d2c-4016-aae3-7e37ca090cc5] DEBUG mydev - ENTER start
2019-05-11 10:23:16 DE [nRepl-session-a9d217fb-3d2c-4016-aae3-7e37ca090cc5] DEBUG simpleserver.util.config - ENTER create-config
=> First REPL is reloading and after that mount starts (and gets the new configuration since we reloaded the namespaces...)

kari07:05:14

What really puzzles me is that I thought these two scenarios should be exactly the same: either sending the exact same expressions from scratch file to repl using hot key, or actually writing the expressions in repl input window and sending the expressions there.

kari07:05:11

The server code is here if you are interested: https://github.com/karimarttila/clojure/tree/master/webstore-demo/simple-server (commit: 88631bb54069c25e80fc0fa9e4cc1670fe6a7f47 ) => in dev-src/myscratch.clj is the scratch file I was talking about. You can demonstrate this by changing e.g. the port number in resources/config/dev/config.edn and then doing the reset and checking the config-state first sending those expressions from the scratch file to repl and then writing the same expressions in the repl input window.

kari07:05:26

Well, I'm glad I figured out that I can use this "reset" workflow in the REPL input window, but I'm not really content regarding this "workaround" since I understood e.g. from one REPL presentation that the best practice is not write stuff in REPL but write stuff in some scratch file and send the stuff for evaluation to REPL.

kari07:05:15

... and BTW. I really love Cursive and I have the commercial Cursive version bought to me by my corporation (I can provide the License ID privately if needed).

joshkh09:05:14

are there tools to provide performance details of all functions called from a parent function at runtime? i have a function that kicks off loads of queries, calculations etc. i could time each function but wasn't sure if there's a way to time them automatically.

joshkh09:05:11

whoops, wrong channel 😇

maximtop17:05:30

I get this error

maximtop17:05:30

and here is the configuration window

ericnormand18:05:01

@maximtop does it work if you run it at the command line?

maximtop18:05:27

Hm, I am not sure You mean if I run at the command line lein repl after setup described in the instruction?

maximtop18:05:34

If I run lein repl from the command line than there is an error

flowthing19:05:35

Try changing the cemerick/piggieback dependency to [cider/piggieback "0.4.0"].

flowthing19:05:44

Might also need to use [nrepl "0.6.0"].

maximtop20:05:26

There is no nrepl or cemerick/piggieback dependency in the https://github.com/lispcast/understanding-re-frame

flowthing20:05:17

And cemerick.piggieback/wrap-cljs-repl -> cider.piggieback/wrap-cljs-repl.

flowthing20:05:31

Piggieback is under dev dependencies.

flowthing20:05:51

nREPL might be a transitive dep.

maximtop20:05:28

I've added dependencies

[cider/piggieback "0.4.1-SNAPSHOT"]
[figwheel-sidecar "0.5.19-SNAPSHOT"]
and changed
:repl-options {:nrepl-middleware [cider.piggieback/wrap-cljs-repl]}
now lein repl starts fine from the command line but I still can't start repl from cursive with the same error I've pasted above

flowthing20:05:08

Yeah, that looks like something unrelated, haven’t seen that before.

maximtop20:05:08

thank you for trying to help me