:reload does not always work correctly in leiningen

81 views
Skip to first unread message

Cecil Westerhof

unread,
Feb 28, 2015, 9:25:56 AM2/28/15
to clo...@googlegroups.com
I discovered:
    (require 'project.core :reload)

Very handy indeed and a big time saver. But it does not always work correctly. At a certain moment I got strange results. An exit and a new 'lein repl' solved the problems.

--
Cecil Westerhof

Sam Raker

unread,
Feb 28, 2015, 11:26:34 AM2/28/15
to clo...@googlegroups.com
"does not always work correctly " in what context? In the REPL, `(require '[my.ns :as mine] :reload-all)` should work. `defonce` and `defmulti` might also be causing confusion. You could also look into `clojure.tools.namespace.repl` (https://github.com/clojure/tools.namespace#reloading-code-usage).

James Reeves

unread,
Feb 28, 2015, 11:43:43 AM2/28/15
to clo...@googlegroups.com
The :reload directive re-evaluated the namespace, but does not remove any existing definitions, or reload any dependent namespaces. This may be the cause of your "strange results".

The tools.namespace library contains a "refresh" function that will clear and reload your namespaces from scratch. This doesn't take into account things like background threads, but is generally more reliable that the :reload directive when working in a REPL.

- James


--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Cecil Westerhof

unread,
Feb 28, 2015, 12:33:48 PM2/28/15
to clo...@googlegroups.com
2015-02-28 17:26 GMT+01:00 Sam Raker <sam....@gmail.com>:
"does not always work correctly " in what context?

​One time when I did the reload my forms got an empty area around them. After an exit and a new start everything was OK again. I use it since today, so I do not know if it is a gremlin or a real problem. I just keep using it and if I get strange results I just have to remember to exit and start again. If I need to restart once every four hours, it still is a good improvement.

I just thought to mention it: if a lot of people would reply with: yes, I have the same problem, then we would know that something was broken. For the moment I think it was a gremlin and not a real problem.


On Saturday, February 28, 2015 at 9:25:56 AM UTC-5, Cecil Westerhof wrote:
I discovered:
    (require 'project.core :reload)

Very handy indeed and a big time saver. But it does not always work correctly. At a certain moment I got strange results. An exit and a new 'lein repl' solved the problems.

--
Cecil Westerhof

Akiva Schoen

unread,
Mar 3, 2015, 2:45:49 PM3/3/15
to clo...@googlegroups.com
I normally use a set utility functions to reload individual namespaces so I don't lose state. This almost always suffices for day-to-day work. But, if the REPL is still acting shady, then I'll use refresh. Anything is better than having to wait out a REPL reboot.
Reply all
Reply to author
Forward
0 new messages