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

0 votes
in tools.namespace by
edited by

If you have a deps.edn project with a git dep in it, in a project where you're also using clojure.tools.namespace.repl/refresh then by default the refresh call will load and refresh all the clojure namespaces in your git dep.

I think it does this because prior to tools.deps; essentially all library dependencies were distributed as jars, so it would assume that any directories in the classpath contain your projects source code, and would benefit from reloading via refresh.

This assumption changes in tools.deps projects as deps can now be stored as files on the filesystem in the ~/.gitlibs directory. These deps are essentially mistaken as project dependencies, and are all loaded and refreshed, even if your project does not actually require them.

Given that ~/.gitlibs are versioned and intended to be immutable, arguably it doesn't make sense to automatically require and refresh them.

It is quite easily avoided by including a call to explicitly set your projects refresh-dirs with something like: (tnsrepl/set-refresh-dirs "src" "test"), however I wonder if it would be better for tools.namespace to exclude anything under ~/.gitlibs by default, as tools.namespace's starting/default assumption no longer holds.

NOTE this is also likely related to this issue.

2 Answers

0 votes
by

I don't think it makes sense to make ~/.gitlibs special in the context of tools.namespace. It's really a specific instance of a more general problem - identifying the subset of the classpath that is considered to be your "project". I am not familiar enough with the original intent here to determine whether this is an issue with tns design, or its docs, or something additive.

0 votes
by

It is a really good idea to set-refresh-dirs in advance. Examples, production-oriented scripts, drafted code, etc - none of those tend to be safe to require blindly (which is what (refresh) does when unconfigured).

...