Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reloading not working as expected #12

Open
pedroteixeira opened this issue Jul 5, 2017 · 3 comments
Open

Reloading not working as expected #12

pedroteixeira opened this issue Jul 5, 2017 · 3 comments

Comments

@pedroteixeira
Copy link

pedroteixeira commented Jul 5, 2017

Hello! For some reason I'm struggling a bit with hot reloading code from repl in a new project setup (lein).

in user.clj

(reloaded.repl/set-init!
  #(make-system {}))

but (reset) does not pick up changes (no change that I've could detect, after modifying stop and start component protoocols for ex, nor in web routes in the particular case I'm trying to impl)

Tried diffferent many things past in the hour (setting refresh dirs, using deref for the make-system symbol, etc) but the only way I managed to reload the code as I expected was to use this (refresh) function:

(defn refresh
  []
  (tools-ns/refresh-all)
  (reloaded.repl/set-init!
    #(make-system {}))
  (init)
  (go))

Not sure if here is the best place to ask, but if you some have some tips or experiene with related issues, I'd appreciate :)

@weavejester
Copy link
Owner

Could you provide a little more information? What's in make-system, for example? What does your project file look like? If you could set up a small project where the problems you're seeing could be reproduced, that would help a lot.

@arnaudgeiser
Copy link

arnaudgeiser commented May 17, 2021

Hello James,

4 years after is never too late I guess...
I was able to reproduce the reported issue.

Environment (somewhat irrelevant in that case):

* Java: OpenJDK Runtime Environment (build 11.0.10+9-Ubuntu-0ubuntu1.20.04)
* Leiningen 2.9.1 on Java 11.0.10 OpenJDK 64-Bit Server VM
* Editor: GNU Emacs 27.1
* CIDER: 1.1.0snapshot

History

  1. Cloning repository: https://github.com/arnaudgeiser/reloaded.repl-issue-12
  2. Firing REPL (cider-jack-in)
  3. Loading the following namespace : https://github.com/arnaudgeiser/reloaded.repl-issue-12/blob/master/src/reloaded/repl_issue_12.clj
  4. Evaluating these expressions
(set-init! #(new-system))
(go)
  1. Creating new system is printed
  2. Changing the following function definition (!!without evaluating it in the REPL!!)
(defn new-system []
  (prn "Recreating new system")
  (component/system-map))
  1. Evaluating this expression
(reset)
  1. Creating new system is printed

Expectation

Expected to see Recreating new system printed.
However, it seems that clojure.tools.namespace.repl/refresh is not the same as redefining the function in the REPL.

Actual

new-system is always bounded to the previous definition

Impact

While it's surprising, the workaround is quite simple :

(reset)
(set-init! #(new-system))
(go)

@drewverlee
Copy link

drewverlee commented May 15, 2023

Why doesn't the call to (init) inside reloaded.repl/init grab the updated version of new-system?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants