Welcome! Please see the About page for a little more info on how this works.

0 votes
in tools.namespace by

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

`

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

`

Since tools.namespace 0.2.5, the workaround is to call {{clear}}:

user=> (clear) {} user=> (refresh) :reloading (foo) :ok

2 Answers

0 votes
by

Comment made by: jafingerhut

Such files introduce problems for all kinds of tools, not just tools.namespace. I don't know all of the consequences, but two are listed here: https://github.com/jonase/eastwood#check-consistency-of-namespace-and-file-names

I have added warnings in Eastwood whenever it finds files like this, and doesn't do any linting checks on any files until such things are corrected.

0 votes
by
Reference: https://clojure.atlassian.net/browse/TNS-24 (reported by stuart.sierra)
...