A tools.namespace dependency tracker can get into an inconsistent state after attempting to load a file with a namespace declaration that does not match the file's name.
Steps to reproduce:
In a new Clojure project, create a file foo.clj on the classpath containing the namespace declaration (ns wrong-ns-declaration-for-foo)
Then at the REPL:
user=> (use 'clojure.tools.namespace.repl)
nil
user=> (refresh)
:reloading (wrong-ns-declaration-for-foo)
:error-while-loading wrong-ns-declaration-for-foo
#<FileNotFoundException java.io.FileNotFoundException: Could not locate wrong_ns_declaration_for_foo__init.class or wrong_ns_declaration_for_foo.clj on classpath: >
Edit the file foo.clj so that its namespace declaration is correct: (ns foo)
But at the REPL, refresh still doesn't work:
user=> (refresh)
:reloading (foo wrong-ns-declaration-for-foo)
:error-while-loading wrong-ns-declaration-for-foo
#<FileNotFoundException java.io.FileNotFoundException: Could not locate wrong_ns_declaration_for_foo__init.class or wrong_ns_declaration_for_foo.clj on classpath: >
Since tools.namespace 0.2.5, the workaround is to call clear:
A tools.namespace dependency tracker can get into an inconsistent state after attempting to load a file with a namespace declaration that does not match the file's name.
Steps to reproduce:
In a new Clojure project, create a file
foo.clj
on the classpath containing the namespace declaration(ns wrong-ns-declaration-for-foo)
Then at the REPL:
user=> (use 'clojure.tools.namespace.repl) nil user=> (refresh) :reloading (wrong-ns-declaration-for-foo) :error-while-loading wrong-ns-declaration-for-foo #<FileNotFoundException java.io.FileNotFoundException: Could not locate wrong_ns_declaration_for_foo__init.class or wrong_ns_declaration_for_foo.clj on classpath: >
Edit the file
foo.clj
so that its namespace declaration is correct:(ns foo)
But at the REPL,
refresh
still doesn't work:user=> (refresh) :reloading (foo wrong-ns-declaration-for-foo) :error-while-loading wrong-ns-declaration-for-foo #<FileNotFoundException java.io.FileNotFoundException: Could not locate wrong_ns_declaration_for_foo__init.class or wrong_ns_declaration_for_foo.clj on classpath: >
Since tools.namespace 0.2.5, the workaround is to call
clear
:user=> (clear) {} user=> (refresh) :reloading (foo) :ok