-
-
Notifications
You must be signed in to change notification settings - Fork 649
CIDER repl doesn't work with clojure.tools.namespace.repl/refresh classpath #2686
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
Comments
Hmm, seems we've messed something up. @jeffvalk Can you take a look in this? |
@bbatsov I can't dig too deeply into this right now, but from a quick look, it seems @jumarko is correct that
Under JDK 9+, this function won't return the actual classpath, only the value of the system property. Obviously, that's not very helpful. The best solution to this situation would be a version of
|
This seems to be fixed in version 0.3.1 https://github.com/clojure/tools.namespace/blob/master/CHANGES.md |
I don't think so. |
I can reproduce this issue, although I have not identified the root cause. tools.namespace needs to know what directories are on the classpath. It uses java.classpath to get the classpath. The problem is the return value of
This is only when launching Java from CIDER, as with In this test, I am using org.clojure/java.classpath 0.3.0. Background: There are so many different ways of running Java it's hard to find a universal way to "get the classpath." The current behavior was implemented in CLASSPATH-8 as a workaround for Java 9+. The old behavior in CLASSPATH-1 and CLASSPATH-2 was adapted for application containers. |
Thanks for looking into this! I'll link here to the bit of code that adds the JDK source to the classpath as I guess that's where things go sideways https://github.com/clojure-emacs/orchard/blob/106cfcd4720bfbd19d04a735316a63084f5a65d3/src/orchard/java.clj#L50 We can always remove the dynamic classpath manipulation, but this will mean that people won't be able to jump into JDK sources. |
CIDER dynamically adds The issue seems to be that under Java 9+, The union of these sets gives the expected behavior. This is what CIDER does for namepace/classpath search (see here). |
The current clojure.java.classpath behavior is the result of many compromises and attempted workarounds. At times in the past, it has behaved more like orchard.classpath. I've opened this up as a new question on ask.clojure.org to solicit feedback: Should java.classpath combine classpath sources? |
@stuartsierra Thanks. Classpaths can be messy. It would be great to get consensus around what expected behavior is. @bbatsov In the meanwhile, I would not call this a bug in CIDER. The functionality in question works as designed. |
@jeffvalk Yeah, I get this. My point was mostly that we might need to come up with some workaround for the code reloading, while we figure out how this problem can be properly tackled in ctn/ Anyways, I'm grateful that the two of you are looking into this! |
As a workaround for projects using tools.namespace, set-refresh-dirs overrides the set of directories tools.namespace scans for source files. For example, in the Reloaded template it sets the refresh directories to "dev" "src" and "test". This is deliberate, to prevent scanning non-source directories, such as For this to work on Java 9+, one still has to manually load the |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contribution and understanding! |
This issues been automatically closed due to lack of activity. Feel free to re-open it if you ever come back to it. |
….namespace. - Works with tools.namespace >= 0.3. - The function now uses `scan-dirs` instead of deprecated `scan`, whenever it can. - Properly accounts for reloading if `refresh-dirs` is set with `clojure.tools.namespace.repl/set-refresh-dirs` function. - Note that with newer versions of tools.namespace, setting `refresh-dirs` is mandatory in some cases like this: clojure-emacs/cider#2686
This is the problem with the classpath as returned by
(clojure.java.classpath/classpath)
which is used by tools.namespace in combination with JDK 9+.See also here for additional info: https://ask.clojure.org/index.php/8288/java-11-and-tools-namespace?show=8379#c8379
When I run pure
lein repl
everything works!Expected behavior
Running
clojure.tools.namespace.repl/refresh
after the REPL is started should reload all the project namespaces like this:Actual behavior
refresh
won't find any directories on the classpath and won't reload anything:The problem is that the following function returns only JDK's src.zip directory nothing else.
(Normally, it's expected to return everything on the classpath):
This happens because the
clojure/java.classpath
contains a special case to support JDK 9+ and doesn't count with anything to be returned via(classpath (clojure.lang.RT/baseLoader))
; rather the classpath is expected to be retrieved via(system-classpath)
(see the source).The src.zip artifact seems to be added by
orchard
.Steps to reproduce the problem
git clone [email protected]:jumarko/lein-sample.git
cider-jack-in
(do (require '[clojure.tools.namespace.repl :as nr :refer [refresh]]) (refresh))
Environment & Version information
CIDER version information
Lein/Boot version
Emacs version
25.3.1
Using Spacemacs
Operating system
Mac OS X 10.14.5
The text was updated successfully, but these errors were encountered: