From 17ebedd6b8485b326604f25403874b0a7174860d Mon Sep 17 00:00:00 2001 From: Icaro Motta Date: Sat, 18 Nov 2023 08:50:11 -0300 Subject: [PATCH] Fix: resolve our Clojure source dependencies first in the classpath (#17919) In PR https://github.com/status-im/status-mobile/pull/17867 we have a namespace named schema.core, but this namespace is taken by library prismatic/schema already (see https://github.com/plumatic/schema/tree/master/src/cljc/schema), a library used by our direct dependency on bidi 2.1.6. This leads to a broken build where the ClojureScript compiler reports undeclared vars (https://clojurescript.org/reference/compiler-options#warnings). We change the order Java resolves dependencies via the classpath mechanism. We now first resolve our own Clojure sources, and then project dependencies. --- nix/mobile/jsbundle/default.nix | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/nix/mobile/jsbundle/default.nix b/nix/mobile/jsbundle/default.nix index 8b6bb025f1..666dfb8300 100644 --- a/nix/mobile/jsbundle/default.nix +++ b/nix/mobile/jsbundle/default.nix @@ -67,9 +67,12 @@ stdenv.mkDerivation { ''; buildPhase = '' # Assemble CLASSPATH from available clojure dependencies. - # We append 'src' so it can find the local sources. - export CLASS_PATH="$(find ${deps.clojure} \ - -iname '*.jar' | tr '\n' ':')src" + # We prepend 'src' so it can find the local sources and prioritize + # our own namespaces over dependencies, given that indirect dependencies + # can also cause naming conflicts (e.g. prismatic/schema already uses + # namespace schema.core). + export CLASS_PATH="src:$(find ${deps.clojure} \ + -iname '*.jar' | tr '\n' ':')" # target must be one of the builds defined in shadow-cljs.edn java -cp "$CLASS_PATH" clojure.main \