2024 Clojure调查中分享您的想法!

欢迎!有关本网站如何工作的更多信息,请参阅关于页面。

0
tools.namespace
编辑

嗨,

我认为我找到了clojure.tools.namespace中TNS-6的解决方案。我有一个一致的复现,以及形如一行补丁的解决方案(更多详细信息请见补丁)。所有的测试都通过了,尽管我不确定它们是否涵盖了所有更改。我还在一组本地依赖库中测试了该解决方案,并且它解决了这个问题。

然而,我不是Clojure的贡献者,所以我无法发表评论或提交补丁或对相关的Jira工单发表评论。

From b5a62f894e049a09d5fcf099ac7b4d6591fb4f18 Mon Sep 17 00:00:00 2001
From: zalky <[email protected]>
Date: Mon, 24 May 2021 13:08:30 -0400
Subject: [PATCH] Fix TNS-6: fully remove ns from deps graph

The clojure.tools.namespace.dependency/remove-node fn removes a
namespace's :dependencies set from the graph (outgoing edges), but
does not remove that namespace from the :dependents set of other
namespaces (ingoing edges). If a namespace is removed and one of its
dependencies is changed at the same time, as commonly occurs when
switching branches, then the removed namespace is still in the
:dependents of the changed namespace when it is reloaded. As all the
of the dependents of a changed namespace are also reloaded, this
throws a missing namespace error.

The resolution is to use clojure.tools.namespace.depedency/remove-all
to remove both outgoing (:dependencies) and ingoing (:dependents)
edges in the dependency graph.

However, care must be taken when choosing the point of change, because
clojure.tools.namespace.track/add relies on the partial removal
behaviour of clojure.tools.namespace.track/remove-deps. It uses
remove-deps to wipe the dependencies of a node, and cannot know how to
re-insert dependents if lost. Therefore the point of change should be
in clojure.tools.namespace.track/remove.
---
 src/main/clojure/clojure/tools/namespace/track.cljc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/main/clojure/clojure/tools/namespace/track.cljc b/src/main/clojure/clojure/tools/namespace/track.cljc
index 683c35d..ce666d5 100644
--- a/src/main/clojure/clojure/tools/namespace/track.cljc
+++ b/src/main/clojure/clojure/tools/namespace/track.cljc
@@ -96,7 +96,7 @@
          :or {load (), unload (), deps (dep/graph)}} tracker
         known (set (dep/nodes deps))
         removed-names (filter known names)
-        new-deps (remove-deps deps removed-names)
+        new-deps (reduce dep/remove-all deps removed-names)
         changed (affected-namespaces deps removed-names)]
     (assoc tracker
       ::deps new-deps
-- 
2.30.1 (Apple Git-130)

[补丁更新后进一步测试]

1 个答案

0

被选中
 
最佳答案

您是否有兴趣成为贡献者并提交补丁?如果是,请签署贡献者协议,并按以下链接提交支持请求以获取jira账户:[https://clojure.org/dev/dev#_becoming_a_contributor](https://clojure.org/dev/dev#_becoming_a_contributor)

如果不是,那么我实际上无法查看您的补丁,但您可能可以描述问题和解决方案,然后贡献者可以编写干净的补丁。

感谢Alex的回答和贡献者协议的链接。我将在验证解决方案后稍作更多时间,然后跟进。
...