<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Clojure Q&amp;A - Recent questions tagged compile</title>
<link>https://ask.clojure.org/index.php/tag/compile</link>
<description></description>
<item>
<title>Executable 'java' not found on system path.</title>
<link>https://ask.clojure.org/index.php/13592/executable-java-not-found-on-system-path</link>
<description>&lt;p&gt;Hi guys I,m basically trying to run a clojure script app using a shadow file, to be honest i don't really know too much about clojure since this is a project that i downloaded, but i need it to make it run locally on windows 11 and i'm receiving the following error&lt;/p&gt;
&lt;p&gt;shadow-cljs - config: C:\Appsmiths\i\src\winglue\webglue\shadow-cljs.edn&lt;br&gt;
===== ERROR =================&lt;/p&gt;
&lt;h2&gt;Executable 'java' not found on system path.&lt;/h2&gt;
&lt;p&gt;I have java on my system of course and my environment variables are well configured, so i think it could be something inside of the shadow file, but i cannot identify what it is, if you can help me out with this it would be really helpful&lt;/p&gt;
&lt;p&gt;this is basically all the shadow config:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;;; shadow-cljs configuration
{:dependencies [
                [akiroz.re-frame/storage &quot;0.1.3&quot;]
                [bidi &quot;2.1.5&quot;]
                [com.cemerick/url &quot;0.1.1&quot;]
                [binaryage/devtools &quot;1.0.2&quot;]
                [binaryage/oops &quot;0.7.1&quot;]
                [com.cognitect/transit-cljs &quot;0.8.256&quot;]
                [com.rpl/specter &quot;1.1.3&quot;]
                [com.taoensso/timbre &quot;4.10.0&quot;]
                [cljs-http &quot;0.1.46&quot;]
                [day8.re-frame/async-flow-fx &quot;0.1.0&quot;]
                [day8.re-frame/http-fx &quot;0.1.6&quot;]
                [day8.re-frame/re-frame-10x &quot;1.5.0&quot;]
                [day8.re-frame/tracing &quot;0.5.1&quot;]
                [day8.re-frame/undo &quot;0.3.2&quot;]
                [district0x/graphql-query &quot;1.0.6&quot;]
                [district0x/re-frame-interval-fx &quot;1.0.2&quot;]
                [expound &quot;0.8.5&quot;]
                [funcool/cuerdas &quot;2021.05.29-0&quot;]
                [funcool/promesa &quot;2.0.1&quot;]
                [juji/editscript &quot;0.4.6&quot;]
                [maximgb/re-state &quot;1.5.0&quot;]
                [medley &quot;1.2.0&quot;]
                [metosin/spec-tools &quot;0.10.4&quot;]
                [org.clojure/data.json &quot;0.2.6&quot;]
                [org.clojure/spec.alpha &quot;0.2.187&quot;]
                [pez/clerk &quot;1.0.0&quot;]
                [prismatic/schema &quot;1.1.12&quot;]
                [re-frame &quot;1.3.0&quot;]
                [re-graph &quot;0.1.15&quot; :exclusions [cljs-http]]
                [com.andrewmcveigh/cljs-time &quot;0.5.2&quot;]
                [reagent &quot;1.1.1&quot;]
                [spyscope &quot;0.1.6&quot;]
                [venantius/accountant &quot;0.2.5&quot;]
                [lambdaisland/regal &quot;0.0.143&quot;]
                [cheshire &quot;5.11.0&quot;]
                [camel-snake-kebab &quot;0.4.3&quot;]
                [garden/garden-units &quot;1.0.0-RC2&quot;]
                [cljs-bean &quot;1.8.0&quot;]]

 :source-paths [&quot;lib&quot; &quot;graphql&quot; &quot;src&quot; &quot;C:/Appsmiths/i/src/winglue-artifact/webglue&quot; &quot;test&quot;]
 :nrepl {:port 41002}
 :open-file-command [&quot;idea &quot; :pwd &quot; --line &quot; :line :file]
 ;; webglue artifact are in /i/src/winglue-artifact/webglue/js
 :builds {:app {:output-dir &quot;C:/Appsmiths/i/src/winglue-artifact/webglue/js&quot;
                :asset-path &quot;/js&quot;
                :compiler-options
                {:optimizations :none
                 ;; use es2018 for recat-markdown-editor
                 :output-feature-set :es2018
                 :main webglue.core
                 :closure-warnings {:global-this :off}
                 :closure-defines {re-frame.trace/trace-enabled? true
                                   day8.re-frame-10x.debug?             true
                                   day8.re-frame.tracing.trace-enabled? true}
                 :external-config {:devtools/config {:features-to-install    [:formatters :hints]
                                                     :fn-symbol              &quot;Fn&quot;
                                                     :print-config-overrides true}}}
                :target :browser
                :js-options {:ignore-asset-requires true}
                :module-loader true
                :modules {:webglue
                          {:entries [webglue.core]}
                          :ag-grid
                          {:entries [webglue.components.ag-grid]
                           :depends-on #{:webglue}}
                          :dev
                          {:entries [webglue.pages.component-show-case webglue.pages.dev]
                           :depends-on #{:webglue}}
                          :plot
                          {:entries [webglue.component-generator.graph
                                     webglue.component-generator.ivsp-plot
                                     webglue.component-generator.pie-chart
                                     webglue.component-generator.bar-chart
                                     webglue.component-generator.bubble-chart]
                           :depends-on #{:webglue}}}
                :devtools {:repl-pprint true
                           :after-load webglue.core/reload!
                           :loader-mode :eval
                           :http-root &quot;C:/Appsmiths/i/src/winglue-artifact/webglue&quot;
                           :http-port 3333
                           :http-handler shadow.http.push-state/handle
                           :preloads [devtools.preload
                                      ; use only for debug re-frame, this option wil take 300 ms to reload and 330 file to watch
                                      ; run by uncomment next line, and save. shadow-cljs will do the rest
                                      day8.re-frame-10x.preload]}}
          :win-app {:output-dir &quot;C:/Appsmiths/i/src/winglue-artifact/webglue&quot;
                    :asset-path &quot;/js&quot;
                    :compiler-options
                    {:optimizations :none
                     :output-feature-set :es2018
                     :main webglue.core
                     :closure-warnings {:global-this :off}
                     :closure-defines {re-frame.trace/trace-enabled? true
                                       day8.re-frame-10x.debug?             true
                                       day8.re-frame.tracing.trace-enabled? true}
                     :external-config {:devtools/config {:features-to-install    [:formatters :hints]
                                                         :fn-symbol              &quot;Fn&quot;
                                                         :print-config-overrides true}}}
                    :target :browser
                    :js-options {:ignore-asset-requires true}
                    :modules {:webglue {:entries [webglue.core]}}
                    :devtools {:http-port 3434
                               :http-root &quot;C:/Appsmiths/i/src/winglue-artifact/webglue&quot;
                               :http-handler shadow.http.push-state/handle
                               :after-load webglue.core/reload!
                               :loader-mode :eval
                               :preloads [devtools.preload
                                          day8.re-frame-10x.preload]}}
          :test {:target :browser-test
                 :test-dir &quot;test-assets&quot;
                 :devtools {:http-port 9100
                            :http-root &quot;test-assets&quot;}
                 :runner-ns main-test-initial
                 :js-options {:ignore-asset-requires true}
                 :ns-regexp &quot;-test$&quot;}

          :app-release {:target :browser
                        :modules {:webglue
                                  {:entries [webglue.core]}}
                        :js-options {:ignore-asset-requires true}
                        :compiler-options {:source-map false
                                           :output-feature-set :es2018
                                           :main  webglue.core
                                           :closure-defines {}}
                        :release  {:output-dir &quot;C:/Appsmiths/i/src/winglue-artifact/webglue/js&quot;}}

          :tao2py-release {:target :browser
                           :js-options {:ignore-asset-requires true}
                           :compiler-options
                           {:source-map false
                            :output-feature-set :es2018
                            :main  webglue.core
                            :closure-defines {webglue.config/tao2py-release true
                                              ;; landing page is page key in webglue.route_pages
                                              webglue.config/landing-page &quot;field-overview&quot;}}
                           :release  {:output-dir &quot;C:/Appsmiths/i/src/winglue-artifact/webglue/js&quot;
                                      :asset-path &quot;/js&quot;}
                           :module-loader true
                           :modules {:webglue
                                     {:entries [webglue.core]}
                                     :ag-grid
                                     {:entries [webglue.components.ag-grid]
                                      :depends-on #{:webglue}}
                                     :dev
                                     {:entries [webglue.pages.component-show-case webglue.pages.dev]
                                      :depends-on #{:webglue}}
                                     :plot
                                     {:entries [webglue.component-generator.graph
                                                webglue.component-generator.ivsp-plot
                                                webglue.component-generator.pie-chart
                                                webglue.component-generator.bar-chart
                                                webglue.component-generator.bubble-chart]
                                      :depends-on #{:webglue}}}}

          :tao2py-testing {:target :browser
                           :modules {:webglue
                                     {:entries [webglue.core]}}
                           :js-options {:ignore-asset-requires true}
                           :compiler-options {:source-map false
                                              :output-feature-set :es2018
                                              :main  webglue.core
                                              :closure-defines {}}
                           :release  {:output-dir &quot;C:/Appsmiths/i/src/winglue-artifact/webglue/js&quot;}}

          :budger-release {:target :browser
                           :modules {:webglue {:entries [webglue.core]}}
                           :release {:output-dir &quot;release/js&quot;}
                           :js-options {:ignore-asset-requires true}
                           :compiler-options {:source-map false
                                              :output-feature-set :es2018
                                              :main       webglue.core
                                              :closure-defines {}}}}}
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>Compiler</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/13592/executable-java-not-found-on-system-path</guid>
<pubDate>Wed, 03 Jan 2024 19:38:51 +0000</pubDate>
</item>
<item>
<title>cljs compile warning: JavaScript file found on classpath for library `...`, but does not contain a corresponding...</title>
<link>https://ask.clojure.org/index.php/12946/compile-warning-javascript-classpath-library-corresponding</link>
<description>&lt;p&gt;First, thanks for cljs, it's the best way to do frontends and it's one of the lifebloods of our business. We are super-grateful.&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;I am running some older code in a new project that has an updated cljs dependency and I am now getting an interesting compile warning:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;WARNING: JavaScript file found on classpath for library `goog.net.cookies`, but does not contain a corresponding `goog.provide` declaration: jar:file:/home/harold/.m2/repository/org/clojure/google-closure-library/0.0-20211011-0726fdeb/google-closure-library-0.0-20211011-0726fdeb.jar!/goog/net/cookies.js
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Everything seems to be working fine, but I am still interested in cleaning up this output.&lt;/p&gt;
&lt;p&gt;I built a simple (two tiny file) project that reproduces the problem:&lt;br&gt;
 - &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/harold/cookie-repro&quot;&gt;https://github.com/harold/cookie-repro&lt;/a&gt;&lt;br&gt;
 - You can clone that and then do:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;lein cljsprod
&lt;/code&gt;&lt;/pre&gt;
&lt;hr&gt;
&lt;p&gt;I did a 'bisect'-ish operation on the cljs deps in maven and found that the warning started to appear with version &lt;code&gt;1.10.891&lt;/code&gt;: &lt;br&gt;
 - &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/clojure/clojurescript/blob/master/changes.md#110891&quot;&gt;https://github.com/clojure/clojurescript/blob/master/changes.md#110891&lt;/a&gt;&lt;br&gt;
 - Before that version, the warning is not seen&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;Wondering if others have seen this warning, or similar, and what, if any, steps would be good to take.&lt;/p&gt;
&lt;p&gt;Thanks again for your time and consideration!&lt;/p&gt;
</description>
<category>ClojureScript</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/12946/compile-warning-javascript-classpath-library-corresponding</guid>
<pubDate>Wed, 17 May 2023 17:23:07 +0000</pubDate>
</item>
<item>
<title>relative directories in classpath-roots</title>
<link>https://ask.clojure.org/index.php/11982/relative-directories-in-classpath-roots</link>
<description>&lt;p&gt;In the context of a monorepo containing several modules I have noticed an issue with &lt;code&gt;clojure.tools.build.api/compile-clj&lt;/code&gt; which is making difficult to compile files when the basis project root is not in the current directory.&lt;/p&gt;
&lt;p&gt;Here is a minimal scenario demonstrating the problem.&lt;/p&gt;
&lt;p&gt;I have a top-level monorepo &lt;code&gt;deps.edn&lt;/code&gt; using tools.build to prepare/package its modules&lt;/p&gt;
&lt;pre&gt;&lt;code&gt; {:deps {monorepo/module-a {:local/root &quot;modules/a&quot;}}
 :aliases {:build {:deps {io.github.clojure/tools.build {:git/tag &quot;v0.8.2&quot;
                                                         :git/sha &quot;ba1a2bf&quot;}}
                   :ns-default build}}}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Module A contains some clojure source files. Here is &lt;code&gt;modules/a/deps.edn&lt;/code&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;{:paths [&quot;src&quot;]}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Those files require a compilation step. Here is the top-level &lt;code&gt;build.clj&lt;/code&gt; file expected to proccess those files.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(ns build
  (:require [clojure.tools.build.api :as b]))

(def module-a (binding [b/*project-root* &quot;modules/a&quot;]
                (b/create-basis {:project &quot;deps.edn&quot;})))

(defn compile-a [_]
  (b/compile-clj
   {:basis module-a
    :src-dirs [&quot;modules/a/src&quot;]
    :class-dir &quot;target/module-a/classes&quot;}))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;However when invoking &lt;code&gt;clojure -T:build compile-a&lt;/code&gt; from top-level directory I encounter the following error &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Execution error (FileNotFoundException) at user/eval136$fn (compile.clj:5).
Could not locate monorepo/module/a__init.class, monorepo/module/a.clj or monorepo/module/a.cljc on classpath.
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The problem is that the  &quot;src&quot; relative directory is not expanded in the &lt;code&gt;:classpath-roots&lt;/code&gt; which lead &lt;code&gt;compile-clj&lt;/code&gt; to search source files in the wrong location. It is possible to work around the issue by  binding the &lt;code&gt;*project-root*&lt;/code&gt; again and adapting &lt;code&gt;:src-dirs&lt;/code&gt; and &lt;code&gt;class-dir&lt;/code&gt; relative to module A root directory like this&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(defn compile-a [_]
  (binding [b/*project-root* &quot;modules/a&quot;]
    (b/compile-clj
     {:basis module-a
      :src-dirs [&quot;src&quot;]
      :class-dir &quot;../../target/module-a/classes&quot;})))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;However IMO it would be better if the computed classpath in the basis was fully expanded by transforming relative paths into absolute ones to avoid this extra ceremony.&lt;/p&gt;
&lt;p&gt;What do you think?&lt;br&gt;
Is there a reason why relative source path directories are currently kept relative ?&lt;/p&gt;
</description>
<category>tools.build</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/11982/relative-directories-in-classpath-roots</guid>
<pubDate>Sun, 19 Jun 2022 16:50:53 +0000</pubDate>
</item>
<item>
<title>How to require a symbol from within a function?</title>
<link>https://ask.clojure.org/index.php/11922/how-to-require-a-symbol-from-within-a-function</link>
<description>&lt;p&gt;Why can't I use require in a function like so?&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(comment
  (-&amp;gt;&amp;gt; [1 2]
       (reduce (fn [acc v]
                 (require '[clojure.set :as c-set])
                 (c-set/union acc #{v}))
               #{})) ;=&amp;gt; Syntax error compiling at (lab/sandbox_playground.clj:31:18).
                     ;   No such namespace: c-set
  )
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;At first I was thinking it was that require needs to go top-level. However: This does work:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(comment
  (do
    (require '[clojure.set :as c-set])
    (c-set/union #{1} #{2})) ;=&amp;gt; #{1 2}
  )
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>Compiler</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/11922/how-to-require-a-symbol-from-within-a-function</guid>
<pubDate>Wed, 01 Jun 2022 10:59:51 +0000</pubDate>
</item>
<item>
<title>Is it possible to set a var during compilation in tools.build?</title>
<link>https://ask.clojure.org/index.php/11610/is-it-possible-to-set-a-var-during-compilation-in-tools-build</link>
<description>&lt;p&gt;Specifically I'd like to set &lt;code&gt;clojure.test/*load-tests*&lt;/code&gt; to false, so that test code is excluded by the &lt;code&gt;clojure.test/deftest&lt;/code&gt;,&lt;code&gt;with-test&lt;/code&gt; etc. macro's. Lein provided injections as an escape hatch, tools.build doesn't seem to have an equivalent.&lt;/p&gt;
&lt;p&gt;Looking at the code, tools.build seems to compile code from a separate generated script in a temp file, which seems to make injections or wrappers impossible. Also couldn't find options to pass other than compiler options.&lt;/p&gt;
&lt;p&gt;A more in-depth description of this use case can be found on clojureverse: &lt;a rel=&quot;nofollow&quot; href=&quot;https://clojureverse.org/t/require-import-inside-deftest/8644/3&quot;&gt;https://clojureverse.org/t/require-import-inside-deftest/8644/3&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Is there a solution or suggested workaround available?&lt;/p&gt;
</description>
<category>tools.build</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/11610/is-it-possible-to-set-a-var-during-compilation-in-tools-build</guid>
<pubDate>Mon, 28 Feb 2022 20:50:43 +0000</pubDate>
</item>
</channel>
</rss>