-
Notifications
You must be signed in to change notification settings - Fork 69
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
tools.namespace's tracker doesn't handle namespaces of same name across dialects #127
Comments
this is basically toolsnamespace 0.3.0-alpha1 complaining I don't think it is mranderson specific. we rather need to poke around the
thx for the report @magnars |
I'm not sure if this is problem with our usage or an actual bug in the implementation of tools.namespace. I'm reading TNS-35 to mean that clojurescript support isn't working correctly yet. Is that correct, @stuartsierra? |
tools.namespace supports .cljs and .cljc as of 0.3.0-alpha1. TNS-35 should have been closed with that release — I just closed it. But tools.namespace can't handle the case of two files defining the same namespace. I added TNS-38 to track this issue. This might be difficult to fix in the near-term, since tools.namespace assumes a one-to-one correspondence between namespaces and files. |
Even with a fix for TNS-38, there may be other complications here. refactor-nrepl.ns.tracker uses Since there may be multiple files for the same namespace with different extensions, there is no way to know which one will be stored in An even more complicated, though unlikely, scenario: Since refactor-nrepl.ns.tracker merges the dependency graphs of Clojure and ClojureScript sources, it could potentially find cyclic dependencies between Clojure and ClojureScript code which do not exist in either language separately. Mixed Clojure/ClojureScript projects open up all kinds of complications for tooling. I'm just starting to discover them for tools.namespace; I expect there will be more. |
In Clojure (.clj) code, a namespace depending on itself makes no sense. But it is perfectly reasonable for a ClojureScript (.cljs) file to depend on a Clojure (.clj) file for macro definitions in the same namespace, via :require-macros. More generally, this means that a "namespace" is logically defined in multiple files, which tools.namespace does not yet handle. This causes spurious circular-dependency error in tools. See, for example, clojure-emacs/refactor-nrepl#127 It is easy to work around the specific case of self-dependency via :require-macros, which has no meaning anywhere else. As a consequence, tools.namespace will no longer throw an exception if an ordinary Clojure namespace tries to :require itself.
@stuartsierra We use the tracker, among other things, in It would be great if this could be made to work reliably. For now, I'll limit the scope of the tracker we're building to only |
I've fixed TNS-38 which resolves the specific case of |
@stuartsierra thanks, will give a try to |
@stuartsierra we use TNS to find dependent files, e.g. when one file is moved we need to update the ns forms of dependent files to require the right thing and fix up fully-qualified references. With this change, we'll now report success to the user, but fail to update one of the affected files when the user performs a rename-file refactoring. To me this is a regression, as I'd much rather have the op blow up than perform a partial refactoring and report success. |
Yes, I think it's better to fail in this edge-case than perform a partial refactoring and tell the user all is OK. |
This reverts commit 6a745ee. due to #127 (comment)
Well, that's why -alpha releases are useful. :) I will reconsider This discussion is leading me to think that deps-from-ns-decl should Regardless of how tools.namespace ends up handling add-files on two different files with the same namespace is It might be possible to deal with this problem using separate trackers I have some vague ideas for a redesigned tools.namespace which might |
@expez care to pop into the gitter room wrt this issue? |
Rum is also affected by this: tonsky/rum#54 |
what about going with the temporary fix @expez? |
I still don't think that's a good idea. I'll have time to write our own tracker early next year, unless this is solved upstream by then. |
okay. does this blocks 2.0 tho? |
No, I don't think that's warranted. Fixing this won't create any API incompatibilities. Moving from the tools.namespace tracker to our own tracker is just an internal change. |
fair point wrt API change. on the other hand it completely blocks users to use refactor-nrepl if they use certain deps in their project. but I appreciate that you don't wanna go with the temporary fix. |
will try to have a look on the TNS issue |
It blocks most of my usage, as one example. On Mon, Dec 14, 2015 at 2:40 PM Benedek Fazekas [email protected]
|
any ways we could perhaps enhance the temporary fix? (crazy things like warn when |
First priority now is getting 2.0.0 out the door so people don't have to depend on snapshots anymore. Once that is done I'll tackle this. That means any temporary fix will only have a lifetime of around 2-3 weeks. Furthermore, the lifetime of the temp-fix overlaps with the holiday when people are doing less refactoring than usual. There's also the issue of teaching people about the tempfix (double prefix means force? new setting?). Most likely a permanent solution is out by the time people have 1) decided to upgrade 2) learned about the workaround. Since people haven't been bumping this thread with "+1" at all, I'm also thinking this doesn't affect a lot of users, yet. |
+1 It affects anyone using Om I believe. I'm using 2.0.0-SNAPSHOT
|
@stuartsierra Any plans on solving this in the immediate future (say in the next 2-3 weeks)? I started working on a file-based tracker (instead of a namespace based one), but I'd obviously love to offload this work to TNS :) |
@expez: @stuartsierra just pushed a fix for TNS-38 along the lines of his previous comment. Are you happy with go with this (at least temporarily) as soon as an alpha is released? |
The fix for TNS-38 looks good to me at least. And I'd be thrilled to use clj-refactor again too. |
Just released tools.namespace 0.3.0-alpha3. This contains the TNS-38 fix described above, |
@benedekfazekas Thanks! 😄 Would that be |
the snapshot
|
@benedekfazekas That solved the issue for me. It was nice seeing the find-usages window again. 😎 |
Nice one! :)
|
Time to close this? |
yup, I think. there is a branch by @expez with a more ambitious solution with a new tracker in the works so that won't go forgotten. |
Here's a new one for me:
Full stack: https://gist.github.com/magnars/43702192d9d8108f98eb
The namespace for
quiescent.core
in clj is simply:The namespace for
quiescent.core
in cljs is:The text was updated successfully, but these errors were encountered: