<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Clojure Q&amp;A - Recent questions tagged error-messages</title>
<link>https://ask.clojure.org/index.php/tag/error-messages</link>
<description></description>
<item>
<title>require yields confusing &quot;namespace ... not found after loading ...&quot; error if masked by empty test file</title>
<link>https://ask.clojure.org/index.php/15173/require-yields-confusing-namespace-found-after-loading-masked</link>
<description>&lt;p&gt;My home.clj was requring chess.llm, neither file had compilation issues, so I found this error below very strange and I couldn't figure it out. &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;user=&amp;gt; (require 'chess.routes.home :reload)                                                                    
2026-07-10 22:09:37,296 [nREPL-session-cedf8a12-a034-475d-a72c-7683c52bca15]
Syntax error compiling at (chess/routes/home.clj:1:1).
namespace 'chess.llm' not found after loading '/chess/llm' 
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I even tried asking AI for help with troubleshooting but it went down the wrong paths looking for circular dependencies. It wasn't until I copied llm.clj to a different file named caca.clj while only updating the ns declaration &quot;chess.llm =&amp;gt; chess.caca&quot; and corresponding requires in my home.clj, that everything loaded correctly.&lt;/p&gt;
&lt;p&gt;It turns out that I had an empty test file test/chess/llm.clj that was somehow messing up the compilation, and removing this empty test file file, or adding a proper ns declaration, solved the issue.&lt;/p&gt;
&lt;p&gt;I'm reporting this because it would help the next Clojure developer if the error message were more indicative of the bad test file, perhaps by including the full file path.&lt;/p&gt;
&lt;p&gt;Here's the AI-generated explanation of this report:&lt;/p&gt;
&lt;h4&gt;Title&lt;/h4&gt;
&lt;p&gt;&lt;code&gt;require&lt;/code&gt; yields confusing &quot;namespace not found after loading&quot; error if masked by empty file earlier in classpath&lt;/p&gt;
&lt;h4&gt;Environment&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Clojure Version:&lt;/strong&gt; 1.11+ / 1.12&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Build Tool:&lt;/strong&gt; Leiningen / Clojure CLI&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;Description&lt;/h4&gt;
&lt;p&gt;When attempting to &lt;code&gt;require&lt;/code&gt; a valid Clojure namespace, if a completely empty &lt;code&gt;.clj&lt;/code&gt; file with the exact same relative file path exists earlier in the classpath sequence (for example, in &lt;code&gt;test/&lt;/code&gt; when &lt;code&gt;test/&lt;/code&gt; precedes &lt;code&gt;src/&lt;/code&gt; in the active profile), Clojure throws a misleading error. &lt;/p&gt;
&lt;p&gt;The compiler successfully locates and loads the empty file, but because the file lacks an &lt;code&gt;(ns ...)&lt;/code&gt; declaration, it fails to find the registered namespace in memory. This effectively masks the actual, working source file further down the classpath, resulting in an error message that mistakenly implies the namespace naming is incorrect, rather than indicating a classpath prioritization issue.&lt;/p&gt;
&lt;h4&gt;Steps to Reproduce&lt;/h4&gt;
&lt;ol&gt;
&lt;li&gt;Create a project layout where &lt;code&gt;test/&lt;/code&gt; takes priority over &lt;code&gt;src/&lt;/code&gt; on the classpath.&lt;/li&gt;
&lt;li&gt;Create a valid file at &lt;code&gt;src/chess/llm.clj&lt;/code&gt; containing:&lt;br&gt;
&lt;code&gt;`&lt;/code&gt;clojure&lt;br&gt;
(ns chess.llm)&lt;br&gt;
(defn call-llm [] :ok)&lt;br&gt;
&lt;code&gt;`&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Create an empty file at &lt;code&gt;test/chess/llm.clj&lt;/code&gt; (size 0 bytes, absolutely no content).&lt;/li&gt;
&lt;li&gt;Launch a REPL and evaluate: &lt;code&gt;(require 'chess.llm)&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;h4&gt;Expected Behavior&lt;/h4&gt;
&lt;p&gt;The compiler should either:&lt;br&gt;
1. Skip empty files on the classpath and continue searching subsequent paths for a matching file containing a valid &lt;code&gt;ns&lt;/code&gt; form.&lt;br&gt;
2. Throw a more descriptive lifecycle error indicating &lt;em&gt;which exact file path&lt;/em&gt; was targeted (e.g., &lt;code&gt;namespace 'chess.llm' not found after loading empty file: test/chess/llm.clj&lt;/code&gt;).&lt;/p&gt;
&lt;h4&gt;Actual Behavior&lt;/h4&gt;
&lt;p&gt;The execution fails completely with a vague stack trace:&lt;br&gt;
&lt;code&gt;`&lt;/code&gt;clojure&lt;br&gt;
Caused by: java.lang.Exception: namespace 'chess.llm' not found after loading '/chess/llm'&lt;br&gt;
&lt;code&gt;`&lt;/code&gt;&lt;/p&gt;
</description>
<category>Clojure</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/15173/require-yields-confusing-namespace-found-after-loading-masked</guid>
<pubDate>Sat, 11 Jul 2026 02:54:34 +0000</pubDate>
</item>
<item>
<title>Changing type tags can lead to cryptic errors</title>
<link>https://ask.clojure.org/index.php/15124/changing-type-tags-can-lead-to-cryptic-errors</link>
<description>&lt;p&gt;Reporting this as an example of a particularly cryptic error message. Admittedly not the most common thing, but when doing REPL-driven dev with code that uses primitive type tags it can happen.&lt;/p&gt;
&lt;p&gt;The issue here as I understand it is that &lt;code&gt;IFn&lt;/code&gt; contains a few hundred interfaces with some permutation of primitive input and output types, with names like &lt;code&gt;LLO&lt;/code&gt; and &lt;code&gt;ODOL&lt;/code&gt;. Functions that call this are compiled to call the primitive interface to avoid boxing,rather than the generic IFn. If the function is then redefined without or with different primitive tags, then the compiled calling code is no longer calling the right interface.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(defn foo ^long [^long x]
  x)

(defn bar []
  (+ (foo 3) (foo 4)))

(bar)

(defn foo [x] x)

(bar) ;;=&amp;gt; throws: class my.ns$foo cannot be cast to class  clojure.lang.IFn$LL
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>Compiler</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/15124/changing-type-tags-can-lead-to-cryptic-errors</guid>
<pubDate>Fri, 05 Jun 2026 08:03:00 +0000</pubDate>
</item>
<item>
<title>`doseq` and `for` expands body twice</title>
<link>https://ask.clojure.org/index.php/14433/doseq-and-for-expands-body-twice</link>
<description>&lt;p&gt;The bodies of &lt;code&gt;doseq&lt;/code&gt; and &lt;code&gt;for&lt;/code&gt; seem to be duplicated in their expansions.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ clojure
user=&amp;gt; (defmacro a [] (prn :expand))
#'user/a
user=&amp;gt; (doseq [_ nil] (a))
:expand
:expand
nil
user=&amp;gt; (for [_ nil] (a))
:expand
:expand
()
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I found the same problem in ClojureScript. I could not find an existing discussion about this so I'm not sure if this is by design, apologies if so. I'm aware that these macros have a large code footprint and that &lt;code&gt;doseq&lt;/code&gt; cannot use closures (the usual way to prevent exponential expansion), but I missed this detail.&lt;/p&gt;
&lt;p&gt;This leads to exponential code blowup if these forms are nested. Artificial demonstration:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ clojure
Clojure 1.12.0
user=&amp;gt; (def counter (atom -1))
#'user/counter
user=&amp;gt; (defmacro a [] (prn :expand (swap! counter inc)))
#'user/a
user=&amp;gt; #(doseq [_ 1] (doseq [_ 2] (doseq [_ 3] (doseq [_ 4] (a)))))
:expand 0
:expand 1
:expand 2
:expand 3
:expand 4
:expand 5
:expand 6
:expand 7
:expand 8
:expand 9
:expand 10
:expand 11
:expand 12
:expand 13
:expand 14
:expand 15
#object[user$eval926$fn__927 0x76563d26 &quot;user$eval926$fn__927@76563d26&quot;]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This might be especially relevant to core.async, where placing &lt;code&gt;go&lt;/code&gt; under &lt;code&gt;doseq&lt;/code&gt; is idiomatic, since &lt;code&gt;go&lt;/code&gt; is expensive in both expansion time and code size.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;user=&amp;gt; (time (eval '(doseq [_ nil] (a/go (doseq [_ nil] (a/go (doseq [_ nil] (a/go))))))))
&quot;Elapsed time: 837.230917 msecs&quot;
nil
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It also leads to duplicated reflection warnings from the fully expanded forms, which is how I found this problem.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;user=&amp;gt; (doseq [_ nil] (Thread/sleep (identity 1)))
Reflection warning, NO_SOURCE_PATH:1:16 - call to static method sleep on java.lang.Thread can't be resolved (argument types: unknown).
Reflection warning, NO_SOURCE_PATH:1:16 - call to static method sleep on java.lang.Thread can't be resolved (argument types: unknown).
nil
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I believe the exponential expansion for &lt;code&gt;doseq&lt;/code&gt; was introduced in Clojure 1.1.0 with support for chunked seqs with &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/clojure/clojure/commit/1abb7a56de1678321054af7fce183184f06974dd&quot;&gt;this commit&lt;/a&gt;.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ clojure -Sdeps '{:deps {org.clojure/clojure {:mvn/version &quot;1.0.0&quot;}}}' 
Downloading: org/clojure/clojure/1.0.0/clojure-1.0.0.pom from central
Downloading: org/clojure/clojure/1.0.0/clojure-1.0.0.jar from central
Clojure 1.0.0-
user=&amp;gt; (defmacro a [] (prn :expand))
#'user/a
user=&amp;gt; (doseq [_ nil] (a))
:expand
nil
user=&amp;gt; ^D
$ clojure -Sdeps '{:deps {org.clojure/clojure {:mvn/version &quot;1.1.0&quot;}}}'
Downloading: org/clojure/clojure/1.1.0/clojure-1.1.0.pom from central
Downloading: org/clojure/clojure/1.1.0/clojure-1.1.0.jar from central
Clojure 1.1.0
user=&amp;gt; (defmacro a [] (prn :expand))
#'user/a
user=&amp;gt; (doseq [_ nil] (a))
:expand
:expand
nil
user=&amp;gt; 
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;At first I wasn't sure if this was hopeless, but I think &lt;code&gt;doseq&lt;/code&gt; is fixable fusing the chunked and non-chunked cases like so:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(defmacro doseq
  &quot;Repeatedly executes body (presumably for side-effects) with
  bindings and filtering as provided by \&quot;for\&quot;.  Does not retain
  the head of the sequence. Returns nil.
  
  Unlike clojure.core/doseq, does not cause exponential macro expansion
  of expressions in bindings or body.&quot;
  [seq-exprs &amp;amp; body]
  (#'clojure.core/assert-args
     (vector? seq-exprs) &quot;a vector for its binding&quot;
     (even? (count seq-exprs)) &quot;an even number of forms in binding vector&quot;)
  (let [step (fn step [recform exprs]
               (if-not exprs
                 [true `(do ~@body)]
                 (let [k (first exprs)
                       v (second exprs)]
                   (if (keyword? k)
                     (let [steppair (step recform (nnext exprs))
                           needrec (steppair 0)
                           subform (steppair 1)]
                       (cond
                         (= k :let) [needrec `(let ~v ~subform)]
                         (= k :while) [false `(when ~v
                                                ~subform
                                                ~@(when needrec [recform]))]
                         (= k :when) [false `(if ~v
                                               (do
                                                 ~subform
                                                 ~@(when needrec [recform]))
                                               ~recform)]))
                     (let [seq- (gensym &quot;seq_&quot;)
                           chunk- (with-meta (gensym &quot;chunk_&quot;)
                                             {:tag 'clojure.lang.IChunk})
                           count- (gensym &quot;count_&quot;)
                           i- (gensym &quot;i_&quot;)
                           in-chunk- (gensym &quot;in-chunk_&quot;)
                           recform `(if ~in-chunk-
                                      (recur ~seq- ~chunk- ~count- (unchecked-inc ~i-))
                                      (recur (next ~seq-) nil 0 0))
                           steppair (step recform (nnext exprs))
                           needrec (steppair 0)
                           subform (steppair 1)]
                       [true
                        `(loop [~seq- (seq ~v), ~chunk- nil,
                                ~count- 0, ~i- 0]
                           (let [~in-chunk- (&amp;lt; ~i- ~count-)
                                 ~seq- (if ~in-chunk- ~seq- (seq ~seq-))]
                             (when (if ~in-chunk- true ~seq-)
                               (let [chunked?# (if ~in-chunk- false (chunked-seq? ~seq-))
                                     ~k (if ~in-chunk-
                                          (.nth ~chunk- ~i-)
                                          (if chunked?# nil (first ~seq-)))]
                                 (if (if ~in-chunk- false chunked?#)
                                   (let [c# (chunk-first ~seq-)]
                                     (recur (chunk-rest ~seq-) c#
                                            (int (count c#)) (int 0)))
                                   (do ~subform
                                       ~@(when needrec [recform])))))))])))))]
    (nth (step nil (seq seq-exprs)) 1)))
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>Macros</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14433/doseq-and-for-expands-body-twice</guid>
<pubDate>Wed, 26 Feb 2025 23:15:06 +0000</pubDate>
</item>
<item>
<title>No path in loop recur arg warning</title>
<link>https://ask.clojure.org/index.php/14126/no-path-in-loop-recur-arg-warning</link>
<description>&lt;p&gt;Reflection warnings, such as for reflective method calls, are printed with the full source path (&lt;code&gt;Compiler/SOURCE_PATH&lt;/code&gt;). This is different in case of the warning about &lt;code&gt;loop&lt;/code&gt; recur args,  printed with the source filename only (&lt;code&gt;Compiler/SOURCE&lt;/code&gt;):&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(set! *warn-on-reflection* true)

(defn reflective-method-call [] (.substring (try &quot;&quot;) 0))

(defn boxed-recur-arg [] (loop [i 0] (recur (try i))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;...which prints:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Reflection warning, /home/pawel/dev/project/src/core.clj:22:33 - call to method substring can't be resolved (target class is unknown).
core.clj:24 recur arg for primitive local: i is not matching primitive, had: Object, needed: long
Auto-boxing loop arg: i
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;IMHO, the path is useful, especially if the filename is generic and inside a dependency.&lt;/p&gt;
</description>
<category>Clojure</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14126/no-path-in-loop-recur-arg-warning</guid>
<pubDate>Sat, 21 Sep 2024 13:12:31 +0000</pubDate>
</item>
<item>
<title>Method Values and Syntax Errors</title>
<link>https://ask.clojure.org/index.php/13710/method-values-and-syntax-errors</link>
<description>&lt;p&gt;Copied from this &lt;a rel=&quot;nofollow&quot; href=&quot;https://old.reddit.com/r/Clojure/comments/1apdx2d/method_values_inside_clojure/kq6iy82/&quot;&gt;reddit comment&lt;/a&gt;:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;So if an ambiguous method is a syntax error (syntax, really?), does that mean that when I update a Java lib that provides a new overload, it will break my code? Even worse, if I have a Clojure lib on the classpath that uses a Java lib, and then update the Java lib and it now provides another overload, the Clojure lib breaks. This would be bad and could result in all kinds of update hell.&lt;/p&gt;
&lt;p&gt;Adding an overload is a very common backwards compatible change in Java code that should be expected. Please don't make it create &quot;syntax&quot; errors in Clojure wrappers.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;My own words:&lt;/p&gt;
&lt;p&gt;One of Clojure's strengths is the resiliency of code, that something written years ago still works today. This has historically applied to libraries that provide idiomatic wrappers around Java libraries as well. However, the use of syntax errors instead of falling back to reflection means that such libraries (if they use the new method values syntax) will be more brittle than other interop code, limiting its usefulness in long-lived code.&lt;/p&gt;
&lt;p&gt;I understand the reasons for using hard errors (performance, clarity, simplicity), but I agree that it's a strange choice given Clojure's otherwise incredible flexibility and willingness to support a variety of usages.&lt;/p&gt;
&lt;p&gt;What is lost or degraded by falling back to reflection (and a reflection warning) in ambiguous cases?&lt;/p&gt;
</description>
<category>Clojure</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/13710/method-values-and-syntax-errors</guid>
<pubDate>Tue, 13 Feb 2024 14:16:48 +0000</pubDate>
</item>
<item>
<title>Should 'method value' error messages (wrong arity) special case for constructors?</title>
<link>https://ask.clojure.org/index.php/13707/should-method-value-error-messages-wrong-special-constructors</link>
<description>&lt;p&gt;If I call a method with the wrong number of arguments, I get a concise, descriptive error message:&lt;br&gt;
&lt;code&gt;(^[] String/toUpperCase &quot;foo&quot; 2)
Syntax error...
Invocation of method toUpperCase in class java.lang.String expected 0 arguments, but received 1&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;If I call a constructor with the wrong number of arguments, I get a very similar message:&lt;br&gt;
&lt;code&gt;(^[String] String/new &quot;foo&quot; 2)
Syntax error...
Invocation of method java.lang.String in class java.lang.String expected 1 arguments, but received 2&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;This message refers to the class name as the method, which feels like what you might get for a constructor.&lt;/p&gt;
&lt;p&gt;I noticed that if my param-tags are incorrect on a constructor, the wording of the message is slightly different (&quot;Expected to find 1 matching signature for &lt;em&gt;constructor&lt;/em&gt;&quot; as opposed to &quot;for &lt;em&gt;method&lt;/em&gt;&quot;), so I just want to pose the question while these messages are somewhat fresh: Should the wording for the arity message mention 'constructor' or 'String/new' or something along those lines?&lt;/p&gt;
</description>
<category>Errors</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/13707/should-method-value-error-messages-wrong-special-constructors</guid>
<pubDate>Mon, 12 Feb 2024 23:36:52 +0000</pubDate>
</item>
<item>
<title>How can tools better detect errors coming from non-existing methods/fields?</title>
<link>https://ask.clojure.org/index.php/13339/tools-better-detect-errors-coming-existing-methods-fields</link>
<description>&lt;p&gt;&lt;code&gt;(.a &quot;&quot;)&lt;/code&gt;, rightfully, throws an IllegalArgumentException without a &lt;a rel=&quot;nofollow&quot; href=&quot;https://clojure.org/reference/repl_and_main#_at_repl&quot;&gt;:phase&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;One can consider, however, that this IllegalArgumentException is &quot;compiler-like&quot;, while it doesn't seem primarily distinguishable of other IllegalArgumentExceptions that may be thrown in more &quot;runtime-like&quot; situations.&lt;/p&gt;
&lt;p&gt;My problem is that, as a tool maker, without such a distinction, all IllegalArgumentExceptions will be given the same treatment, while users would want a more concise treatment (e.g. no stacktraces shown) for compiler-like ones.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Is there a recommended way to inspect runtime exceptions for determining if they represent something that, from the user point of view, represents &quot;code that is invalid to begin with&quot;?&lt;ul&gt;
&lt;li&gt;(this is an informal term to describe runtime exceptions that are compiler-like)&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Has it been considered to make this easier by e.g. attaching a &lt;code&gt;:cause&lt;/code&gt; (or &lt;code&gt;:phase&lt;/code&gt;, &lt;code&gt;:ex-data&lt;/code&gt;, something) when the Clojure compiler/runtime can reliably do so?&lt;/li&gt;
&lt;/ul&gt;
</description>
<category>Errors</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/13339/tools-better-detect-errors-coming-existing-methods-fields</guid>
<pubDate>Thu, 28 Sep 2023 09:43:19 +0000</pubDate>
</item>
<item>
<title>exceptions from a macro compilation do not contain at all &quot;my source code&quot;</title>
<link>https://ask.clojure.org/index.php/13058/exceptions-from-macro-compilation-not-contain-source-code</link>
<description>&lt;p&gt;When a exception is thrown at macro compilation time,&lt;br&gt;
the stack trace does not contain the &quot;originating line&quot;, at least in my case.&lt;/p&gt;
&lt;p&gt;So when I want to look &quot;where&quot; in &lt;strong&gt;my code&lt;/strong&gt; the issue starts, the stack trace does not help.&lt;/p&gt;
&lt;p&gt;Specially for a Clojure beginner (from a Java background), it might not be obvious that macro compilation is existing and was the reason that a stack trace does not contain &quot;my starting line&quot;.&lt;/p&gt;
&lt;p&gt;Quite some libraries use &quot;macros&quot; for &quot;normal operations&quot;.&lt;/p&gt;
</description>
<category>Clojure</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/13058/exceptions-from-macro-compilation-not-contain-source-code</guid>
<pubDate>Mon, 03 Jul 2023 18:38:52 +0000</pubDate>
</item>
<item>
<title>Poor Errors when deref'ing a non-IDeref/non-Future</title>
<link>https://ask.clojure.org/index.php/13056/poor-errors-when-derefing-a-non-ideref-non-future</link>
<description>&lt;h2&gt;Problem Statement&lt;/h2&gt;
&lt;p&gt;The function &lt;code&gt;clojure.core/deref&lt;/code&gt; throws a hard-to-decipher &lt;code&gt;ClassCastException&lt;/code&gt; when given an object that's not an instance of &lt;code&gt;clojure.lang.IDeref&lt;/code&gt; or &lt;code&gt;java.util.concurrent.Future&lt;/code&gt;. In my experience on-boarding new Clojure users (at my job and in my open source projects), this comes up and can be quite confusing as it doesn't point to anything obvious in the code. Even with the stack trace, it just points to &lt;code&gt;deref-future&lt;/code&gt;'s definition (instead of a specific line within the function body), which further confuses.&lt;/p&gt;
&lt;h2&gt;Discussion&lt;/h2&gt;
&lt;p&gt;On Slack, I proposed changing the implementation of &lt;code&gt;deref&lt;/code&gt; to be something like &lt;code&gt;(cond (instance? clojure.lang.IDeref ref) ... (instance? java.util.concurrent.Future ref) ... :else (throw (IllegalArgumentException (str ref &quot; cannot be deref'd as it is of type &quot; (class ref) &quot;.&quot;))&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Sean Corfield brought up that such a fix would cost performance for all non-IDeref uses of &lt;code&gt;deref&lt;/code&gt;, which I acknowledged but find acceptable.&lt;/p&gt;
&lt;h2&gt;Repro:&lt;/h2&gt;
&lt;pre&gt;&lt;code&gt;user=&amp;gt; (def a {})
#'user/a

user=&amp;gt; @a
Execution error (ClassCastException) at user/eval22861 (REPL:0).
class clojure.lang.PersistentArrayMap cannot be cast to class java.util.concurrent.Future (clojure.lang.PersistentArrayMap is in unnamed module of loader 'app'; java.util.concurrent.Future is in module java.base of loader 'bootstrap')

user=&amp;gt; (pst)
ClassCastException class clojure.lang.PersistentArrayMap cannot be cast to class java.util.concurrent.Future (clojure.lang.PersistentArrayMap is in unnamed module of loader 'app'; java.util.concurrent.Future is in module java.base of loader 'bootstrap')
    clojure.core/deref-future (core.clj:2315)
    clojure.core/deref-future (core.clj:2315)
    clojure.core/deref (core.clj:2338)
    clojure.core/deref (core.clj:2323)
    user/eval22863 (NO_SOURCE_FILE:0)
    user/eval22863 (NO_SOURCE_FILE:-1)
    clojure.lang.Compiler.eval (Compiler.java:7194)
    clojure.lang.Compiler.eval (Compiler.java:7149)
    clojure.core/eval (core.clj:3215)
    clojure.core/eval (core.clj:3211)
    clojure.main/repl/read-eval-print--9206/fn--9209 (main.clj:437)
    clojure.main/repl/read-eval-print--9206 (main.clj:437)
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>Errors</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/13056/poor-errors-when-derefing-a-non-ideref-non-future</guid>
<pubDate>Mon, 03 Jul 2023 18:08:19 +0000</pubDate>
</item>
<item>
<title>Interest in beginner-friendly variant of (pst)?</title>
<link>https://ask.clojure.org/index.php/13044/interest-in-beginner-friendly-variant-of-pst</link>
<description>&lt;p&gt;Another State of Clojure survey and &quot;error messages&quot; is still the number one priority for improvement.&lt;/p&gt;
&lt;p&gt;A discussion on Slack led to a number of specific pain points for beginners around exceptions and error messages. The one I'd like to focus on here is to provide a beginner-friendly alternative to &lt;code&gt;(pst)&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Currently, &lt;code&gt;(pst)&lt;/code&gt; makes a reasonable attempt at demunging names, eliminating &quot;noise&quot;, and shrinking the stack trace some -- but it still leaves a lot to be desired for &lt;em&gt;beginners&lt;/em&gt; who struggle to understand certain exceptions and have difficulty navigating (Java-style) stack traces, especially compared to some other languages that make a big effort to provide user-friendly error messages and stack traces.&lt;/p&gt;
&lt;p&gt;An example from Slack was:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(defn f [i]
  (fn [j]
    (/ j i)))

(run! #(% 1) (map f (range 3)))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The exception printed in the REPL is fine but &lt;code&gt;(pst)&lt;/code&gt; shows:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;user=&amp;gt; (pst)
ArithmeticException Divide by zero
        clojure.lang.Numbers.divide (Numbers.java:190)
        user/f/fn--16571 (NO_SOURCE_FILE:3)
        user/eval16576/fn--16577 (NO_SOURCE_FILE:1)
        clojure.core/run!/fn--8906 (core.clj:7849)
...
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The elided part mentions &lt;code&gt;clojure.lang.ArrayChunk.reduce&lt;/code&gt; and then has multiple references to &lt;code&gt;clojure.core.protocols&lt;/code&gt; stuff (and doesn't go deep enough by default to show the original call to &lt;code&gt;clojure.core/run!&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;I think there's an opportunity here for a new &lt;code&gt;clojure.repl/explain&lt;/code&gt; function, taking the same arguments as &lt;code&gt;pst&lt;/code&gt;, that provides both a more detailed explanation of the failure and further reduces the noise in the stack trace that &lt;code&gt;pst&lt;/code&gt; currently displays.&lt;/p&gt;
&lt;p&gt;Ideally, this could be implemented with some basic cleanup in core but with some dynamic hooks that allow other tooling to &quot;install&quot; additional expansion and/or cleanup so that the community can provide libraries and functionality that further improve this aspect of the beginner experience.&lt;/p&gt;
&lt;p&gt;A dynamic hook into &lt;code&gt;ex-str&lt;/code&gt;, for example, would allow community-provided tooling to massage the exception message shown (both for the original REPL input and for both &lt;code&gt;pst&lt;/code&gt; and &lt;code&gt;explain&lt;/code&gt;) so that messages that beginners struggle with, such as &lt;code&gt;class &amp;lt;whatever&amp;gt; cannot be cast to clojure.lang.IFn...&lt;/code&gt; could be rewritten into beginner-friendly language (&lt;code&gt;Expected a function - found a &amp;lt;whatever&amp;gt;&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;Similar dynamic hooks to filter stack frames, and to &quot;print&quot; them to strings, would allow much more friendly output for beginners.&lt;/p&gt;
</description>
<category>Errors</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/13044/interest-in-beginner-friendly-variant-of-pst</guid>
<pubDate>Sat, 01 Jul 2023 19:19:33 +0000</pubDate>
</item>
<item>
<title>improve syntax errors on tagged-literals</title>
<link>https://ask.clojure.org/index.php/12256/improve-syntax-errors-on-tagged-literals</link>
<description>&lt;p&gt;When we write a symbol in the UUID literal, the reported error message is wrong&lt;/p&gt;
&lt;p&gt;(as of 1.11.1)&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;clojure -M -e '#uuid id'
Execution error (AssertionError) at clojure.main/main (main.java:40).
Assert failed: (string? form)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It is wrong because&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;It is not an execution error. Should be read or syntax error.&lt;/li&gt;
&lt;li&gt;It does not include any ex-data: &lt;a rel=&quot;nofollow&quot; href=&quot;https://clojure.org/reference/repl_and_main#_error_printing&quot;&gt;https://clojure.org/reference/repl_and_main#_error_printing&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;It should be something like this&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Reader error (AssertionError) at clojure.uuid/default-uuid-reader (uuid.clj:12).
Assert failed: (string? form)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;A second step improvement could be add spec support to data-literals, as macros do.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Syntax error reading #uuid id at (REPL:1)
id - failed: string? at: [:form]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;From #clojure-dev slack channel&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;Alex: You don’t need anything special there - just an instrumented spec on the data reader fn&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;After run&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(s/fdef clojure.uuid/default-uuid-reader :args (s/cat :form string?))
(clojure.spec.test.alpha/instrument `clojure.uuid/default-uuid-reader)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The message turns into&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Syntax error reading source at (REPL:2:1).
Call to #'clojure.uuid/default-uuid-reader did not conform to spec.
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This is a way better message.&lt;/p&gt;
&lt;p&gt;Also, it includes a &lt;code&gt;#:clojure.error{:phase :read-source}&lt;/code&gt; in ex-data.&lt;br&gt;
So the fix could be just add a spec to &lt;code&gt;clojure.uuid/default-uuid-reader&lt;/code&gt;&lt;/p&gt;
</description>
<category>Syntax and reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/12256/improve-syntax-errors-on-tagged-literals</guid>
<pubDate>Wed, 28 Sep 2022 13:24:40 +0000</pubDate>
</item>
<item>
<title>Can: &quot;Alias already exists in namespace&quot; be fixed?</title>
<link>https://ask.clojure.org/index.php/12235/can-alias-already-exists-in-namespace-be-fixed</link>
<description>&lt;p&gt;When defining a namespace alias in an &lt;code&gt;ns&lt;/code&gt; form, and then later changing the namespace that alias refers to, you get an error:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(ns foo.bar
  (:require [my.xxx :as xxx]))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I evaluate this in my REPL. Later I change it to:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(ns foo.bar
  (:require [other.xxx :as xxx]))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And I get this exception&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;java.lang.IllegalStateException
Alias xxx already exists in namespace foo.bar, aliasing my.xxx
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;That's a pretty gnarly sharp edge. Many people won't find a better solution than restarting their REPLs. Experienced Clojure developers will tell you to do&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(ns-unalias *ns* 'xxx)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;and re-evaluate the ns form, but that's a pretty silly workaround. The right thing to do would be to drop the old alias and pick up the new one.&lt;/p&gt;
&lt;p&gt;You'd (I supposed) still have to re-evaluate the code that uses the alias before it gets picked up, but that's fairly consistent with Clojure's mental model IMO.&lt;/p&gt;
&lt;p&gt;We can redefine vars, why can't we redefine namespace aliases?&lt;/p&gt;
</description>
<category>Clojure</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/12235/can-alias-already-exists-in-namespace-be-fixed</guid>
<pubDate>Mon, 26 Sep 2022 13:51:27 +0000</pubDate>
</item>
<item>
<title>Can the &quot;Key must be integer&quot; error message be improved?</title>
<link>https://ask.clojure.org/index.php/11907/can-the-key-must-be-integer-error-message-be-improved</link>
<description>&lt;p&gt;The &lt;code&gt;Key must be integer&lt;/code&gt; error message often catches me off guard and I forget what it meant.&lt;/p&gt;
&lt;p&gt;Could this message be improved so that it is a little more self-describing?&lt;/p&gt;
&lt;p&gt;e.g. &lt;code&gt;Tried to assoc a non-integer key to a vector&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Thanks - V&lt;/p&gt;
</description>
<category>Errors</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/11907/can-the-key-must-be-integer-error-message-be-improved</guid>
<pubDate>Wed, 25 May 2022 05:54:04 +0000</pubDate>
</item>
<item>
<title>Can the error message be cleaned up for &lt;, &gt;, etc. ?</title>
<link>https://ask.clojure.org/index.php/11785/can-the-error-message-be-cleaned-up-for-etc</link>
<description>&lt;p&gt;&lt;code&gt;(&amp;lt; nil 3)&lt;/code&gt; produces the error &lt;code&gt;Cannot invoke &quot;Object.getClass()&quot; because &quot;x&quot; is null&lt;/code&gt;. Is there any room for improvement here?&lt;/p&gt;
&lt;p&gt;My gut tells me that this hasn't been done due to performance reasons, but another user made the observation in Slack that it's in the &lt;code&gt;static public Boolean lt(Object x, Object y) {&lt;/code&gt; branch of &lt;code&gt;Numbers.java&lt;/code&gt;, so it might not be terrible to add the null checks to improve the error message.&lt;/p&gt;
&lt;p&gt;Thanks,&lt;br&gt;
Devin&lt;/p&gt;
</description>
<category>Clojure</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/11785/can-the-error-message-be-cleaned-up-for-etc</guid>
<pubDate>Tue, 19 Apr 2022 23:10:14 +0000</pubDate>
</item>
<item>
<title>clojure.test deftest exception reporting lists many useless stack frames</title>
<link>https://ask.clojure.org/index.php/10744/clojure-deftest-exception-reporting-lists-useless-frames</link>
<description>&lt;p&gt;If an exception occurs during a clojure.test deftest, the error goes to clojure.test/report with :error key which will (by default) print the entire stack trace. The stack includes the test framework itself and (if invoked via an external test runner like lein test, clojure.main etc), yielding a stack depth of ~60 stack frames which is all incidental noise that is irrelevant.&lt;/p&gt;
&lt;p&gt;There is a dyn var clojure.test/&lt;em&gt;stack-trace-depth&lt;/em&gt; that defaults to nil (all). This dynvar can be bound around calls to the clojure.test runner to see less stack trace when an exception occurs during a test, but this is both difficult to set for external test runners and error prone.&lt;/p&gt;
&lt;p&gt;It would be most useful to filter the framework noise from the bottom of the stack and present only the relevant frames.&lt;/p&gt;
&lt;p&gt;Given a test like:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(ns foo.core-test
  (:require [clojure.test :refer :all]))

(deftest a-test
  (testing &quot;FIXME, I fail.&quot;
    (throw (ex-info &quot;I suck&quot; {:a 1}))
    (is (= 0 1))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;the reported error (here from lein test, but any external runner is similar), only the top 2 lines are relevant, the rest is incidental noise:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;ERROR in (a-test) (core_test.clj:13)
Uncaught exception, not in assertion.
expected: nil
  actual: clojure.lang.ExceptionInfo: I suck
{:a 1}
 at foo.core_test$fn__364.invokeStatic (core_test.clj:13)
    foo.core_test/fn (core_test.clj:11)
    clojure.test$test_var$fn__9737.invoke (test.clj:717)        ;; noise from here down
    clojure.test$test_var.invokeStatic (test.clj:717)
    clojure.test$test_var.invoke (test.clj:708)
    clojure.test$test_vars$fn__9763$fn__9768.invoke (test.clj:735)
    clojure.test$default_fixture.invokeStatic (test.clj:687)
    clojure.test$default_fixture.invoke (test.clj:683)
    clojure.test$test_vars$fn__9763.invoke (test.clj:735)
    clojure.test$default_fixture.invokeStatic (test.clj:687)
    clojure.test$default_fixture.invoke (test.clj:683)
    clojure.test$test_vars.invokeStatic (test.clj:731)
    clojure.test$test_all_vars.invokeStatic (test.clj:737)
    clojure.test$test_ns.invokeStatic (test.clj:758)
    clojure.test$test_ns.invoke (test.clj:743)
    user$eval224$fn__287.invoke (form-init4292042596091073068.clj:1)
    clojure.lang.AFn.applyToHelper (AFn.java:156)
    clojure.lang.AFn.applyTo (AFn.java:144)
    clojure.core$apply.invokeStatic (core.clj:667)
    clojure.core$apply.invoke (core.clj:660)
    leiningen.core.injected$compose_hooks$fn__154.doInvoke (form-init4292042596091073068.clj:1)
    clojure.lang.RestFn.applyTo (RestFn.java:137)
    clojure.core$apply.invokeStatic (core.clj:665)
    clojure.core$apply.invoke (core.clj:660)
    leiningen.core.injected$run_hooks.invokeStatic (form-init4292042596091073068.clj:1)
    leiningen.core.injected$run_hooks.invoke (form-init4292042596091073068.clj:1)
    leiningen.core.injected$prepare_for_hooks$fn__159$fn__160.doInvoke (form-init4292042596091073068.clj:1)
    clojure.lang.RestFn.applyTo (RestFn.java:137)
    clojure.lang.AFunction$1.doInvoke (AFunction.java:31)
    clojure.lang.RestFn.invoke (RestFn.java:408)
    clojure.core$map$fn__5866.invoke (core.clj:2755)
    clojure.lang.LazySeq.sval (LazySeq.java:42)
    clojure.lang.LazySeq.seq (LazySeq.java:51)
    clojure.lang.Cons.next (Cons.java:39)
    clojure.lang.RT.boundedLength (RT.java:1792)
    clojure.lang.RestFn.applyTo (RestFn.java:130)
    clojure.core$apply.invokeStatic (core.clj:667)
    clojure.test$run_tests.invokeStatic (test.clj:768)
    clojure.test$run_tests.doInvoke (test.clj:768)
    clojure.lang.RestFn.applyTo (RestFn.java:137)
    clojure.core$apply.invokeStatic (core.clj:665)
    clojure.core$apply.invoke (core.clj:660)
    user$eval224$fn__299$fn__332.invoke (form-init4292042596091073068.clj:1)
    user$eval224$fn__299$fn__300.invoke (form-init4292042596091073068.clj:1)
    user$eval224$fn__299.invoke (form-init4292042596091073068.clj:1)
    user$eval224.invokeStatic (form-init4292042596091073068.clj:1)
    user$eval224.invoke (form-init4292042596091073068.clj:1)
    clojure.lang.Compiler.eval (Compiler.java:7177)
    clojure.lang.Compiler.eval (Compiler.java:7167)
    clojure.lang.Compiler.load (Compiler.java:7636)
    clojure.lang.Compiler.loadFile (Compiler.java:7574)
    clojure.main$load_script.invokeStatic (main.clj:475)
    clojure.main$init_opt.invokeStatic (main.clj:477)
    clojure.main$init_opt.invoke (main.clj:477)
    clojure.main$initialize.invokeStatic (main.clj:508)
    clojure.main$null_opt.invokeStatic (main.clj:542)
    clojure.main$null_opt.invoke (main.clj:539)
    clojure.main$main.invokeStatic (main.clj:664)
    clojure.main$main.doInvoke (main.clj:616)
    clojure.lang.RestFn.applyTo (RestFn.java:137)
    clojure.lang.Var.applyTo (Var.java:705)
    clojure.main.main (main.java:40)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We are doing things elsewhere to filter frames and I don't think it would be that hard to filter this to improve the default experience (could still be a dyn var to not filter if needed).&lt;/p&gt;
</description>
<category>Test</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/10744/clojure-deftest-exception-reporting-lists-useless-frames</guid>
<pubDate>Wed, 30 Jun 2021 07:10:59 +0000</pubDate>
</item>
<item>
<title>Clojure CLI: --report incompatible with -X ?</title>
<link>https://ask.clojure.org/index.php/10692/clojure-cli-report-incompatible-with-x</link>
<description>&lt;p&gt;&lt;strong&gt;Background:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;My build runs in a container where I have no access to temporary files (they get thrown away as soon as the build completes, whether successfully or not).  As a result I add &lt;code&gt;--report stderr&lt;/code&gt; option to all invocations of the clojure command.&lt;/li&gt;
&lt;li&gt;My build constructs an uberjar, using &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/seancorfield/depstar&quot;&gt;Depstar&lt;/a&gt;, which requires the use of the &lt;code&gt;-X:...&lt;/code&gt; option.&lt;/li&gt;
&lt;li&gt;I also use the &lt;code&gt;-Srepro&lt;/code&gt; option.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;strong&gt;Problem:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;When a clojure command line includes the &lt;code&gt;-X&lt;/code&gt; option, it doesn't appear that there's any way to also include &lt;code&gt;--report stderr&lt;/code&gt; option.  Here's some sample output:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ clojure --report stderr -Srepro -X:uberjar
WARNING: Use of -A with clojure.main is deprecated, use -M instead
{:clojure.main/message
 &quot;Execution error (FileNotFoundException) at java.io.FileInputStream/open0 (FileInputStream.java:-2).\n-Srepro (No such file or directory)\n&quot;,
 :clojure.main/triage
 {:clojure.error/class java.io.FileNotFoundException,
  :clojure.error/line -2,
  :clojure.error/cause &quot;-Srepro (No such file or directory)&quot;,
  :clojure.error/symbol java.io.FileInputStream/open0,
  :clojure.error/source &quot;FileInputStream.java&quot;,
  :clojure.error/phase :execution},
 :clojure.main/trace
 {:via
  [{:type java.io.FileNotFoundException,
    :message &quot;-Srepro (No such file or directory)&quot;,
    :at [java.io.FileInputStream open0 &quot;FileInputStream.java&quot; -2]}],
  :trace
  [[java.io.FileInputStream open0 &quot;FileInputStream.java&quot; -2]
   [java.io.FileInputStream open &quot;FileInputStream.java&quot; 219]
   [java.io.FileInputStream &amp;lt;init&amp;gt; &quot;FileInputStream.java&quot; 157]
   [java.io.FileInputStream &amp;lt;init&amp;gt; &quot;FileInputStream.java&quot; 112]
   [clojure.lang.Compiler loadFile &quot;Compiler.java&quot; 7575]
   [clojure.main$load_script invokeStatic &quot;main.clj&quot; 475]
   [clojure.main$script_opt invokeStatic &quot;main.clj&quot; 535]
   [clojure.main$script_opt invoke &quot;main.clj&quot; 530]
   [clojure.main$main invokeStatic &quot;main.clj&quot; 664]
   [clojure.main$main doInvoke &quot;main.clj&quot; 616]
   [clojure.lang.RestFn applyTo &quot;RestFn.java&quot; 137]
   [clojure.lang.Var applyTo &quot;Var.java&quot; 705]
   [clojure.main main &quot;main.java&quot; 40]],
  :cause &quot;-Srepro (No such file or directory)&quot;}}

Execution error (FileNotFoundException) at java.io.FileInputStream/open0 (FileInputStream.java:-2).
-Srepro (No such file or directory)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;With the first two options swapped:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ clojure -Srepro --report stderr -X:uberjar
WARNING: Use of -A with clojure.main is deprecated, use -M instead
{:clojure.main/message
 &quot;Execution error (FileNotFoundException) at java.io.FileInputStream/open0 (FileInputStream.java:-2).\n-X:uberjar (No such file or directory)\n&quot;,
 :clojure.main/triage
 {:clojure.error/class java.io.FileNotFoundException,
  :clojure.error/line -2,
  :clojure.error/cause &quot;-X:uberjar (No such file or directory)&quot;,
  :clojure.error/symbol java.io.FileInputStream/open0,
  :clojure.error/source &quot;FileInputStream.java&quot;,
  :clojure.error/phase :execution},
 :clojure.main/trace
 {:via
  [{:type java.io.FileNotFoundException,
    :message &quot;-X:uberjar (No such file or directory)&quot;,
    :at [java.io.FileInputStream open0 &quot;FileInputStream.java&quot; -2]}],
  :trace
  [[java.io.FileInputStream open0 &quot;FileInputStream.java&quot; -2]
   [java.io.FileInputStream open &quot;FileInputStream.java&quot; 219]
   [java.io.FileInputStream &amp;lt;init&amp;gt; &quot;FileInputStream.java&quot; 157]
   [java.io.FileInputStream &amp;lt;init&amp;gt; &quot;FileInputStream.java&quot; 112]
   [clojure.lang.Compiler loadFile &quot;Compiler.java&quot; 7575]
   [clojure.main$load_script invokeStatic &quot;main.clj&quot; 475]
   [clojure.main$script_opt invokeStatic &quot;main.clj&quot; 535]
   [clojure.main$script_opt invoke &quot;main.clj&quot; 530]
   [clojure.main$main invokeStatic &quot;main.clj&quot; 664]
   [clojure.main$main doInvoke &quot;main.clj&quot; 616]
   [clojure.lang.RestFn applyTo &quot;RestFn.java&quot; 137]
   [clojure.lang.Var applyTo &quot;Var.java&quot; 705]
   [clojure.main main &quot;main.java&quot; 40]],
  :cause &quot;-X:uberjar (No such file or directory)&quot;}}

Execution error (FileNotFoundException) at java.io.FileInputStream/open0 (FileInputStream.java:-2).
-X:uberjar (No such file or directory)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Finally, the version of the CLI tools I'm using:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ clojure --version
Clojure CLI version 1.10.3.855
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;So the question is: how can I ensure any uncaught exceptions thrown out of a &lt;code&gt;-X&lt;/code&gt; function (in this case Depstar, but it could be anything) are written to stdout or stderr, rather than a temporary file that I can't access?  Does &lt;code&gt;-X&lt;/code&gt; bypass that (irritating) default behaviour of writing exception details to a temporary file, perhaps?&lt;/p&gt;
</description>
<category>Tools</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/10692/clojure-cli-report-incompatible-with-x</guid>
<pubDate>Tue, 15 Jun 2021 19:29:34 +0000</pubDate>
</item>
<item>
<title>Missing error on silly destructuring mistake</title>
<link>https://ask.clojure.org/index.php/9590/missing-error-on-silly-destructuring-mistake</link>
<description>&lt;p&gt;I happened to define a function like this&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(defn foo [{:keys [bar :as lol]}] lol)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Obviously the destructuring is wrong, it should have been&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(defn foo [{:keys [bar] :as lol}] lol)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;My question is then, should this destructuring error be caught by the specs for destructuring?&lt;/p&gt;
</description>
<category>Syntax and reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/9590/missing-error-on-silly-destructuring-mistake</guid>
<pubDate>Wed, 09 Sep 2020 07:32:08 +0000</pubDate>
</item>
<item>
<title>Unmatched paren in Reitit example</title>
<link>https://ask.clojure.org/index.php/8875/unmatched-paren-in-reitit-example</link>
<description>&lt;p&gt;Hey! I'm getting an unmatched paren error on this function I got from reitit's example http-swagger project.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(def app
  (http/ring-handler
   (http/router
     [[&quot;/swagger.json&quot;
        {:get {:no-doc true
         :swagger {:info {:title &quot;my-api&quot;
                          :description &quot;with reitit-http&quot;}}
         :handler (swagger/create-swagger-handler)}}]

 [&quot;/files&quot;
  {:swagger {:tags [&quot;files&quot;]}}

  [&quot;/upload&quot;
   {:post {:summary &quot;upload a file&quot;
           :parameters {:multipart {:file multipart/temp-file-part}}
           :responses {200 {:body {:name string?, :size int?}}}
           :handler (fn [{{{:keys [file]} :multipart} :parameters}]
                      {:status 200
                       :body {:name (:filename file)
                              :size (:size file)}})}}]

 [&quot;/async&quot;
  {:get {:swagger {:tags [&quot;async&quot;]}
         :summary &quot;fetches random users asynchronously over the internet&quot;
         :parameters {:query (s/keys :req-un [::results] :opt-un [::seed])}
         :responses {200 {:body any?}}
         :handler (fn [{{{:keys [seed results]} :query} :parameters}]
                    (d/chain
                     (aleph/get
                      &quot;https://randomuser.me/api/&quot;
                      {:query-params {:seed seed, :results results}})
                     :body
                     (partial m/decode &quot;application/json&quot;)
                     :results
                     (fn [results]
                       {:status 200
                        :body results})))}}]

 [&quot;/math&quot;
  {:swagger {:tags [&quot;math&quot;]}}

  [&quot;/plus&quot;
   {:get {:summary &quot;plus with data-spec query parameters&quot;
          :parameters {:query {:x int?, :y int?}}
          :responses {200 {:body {:total pos-int?}}}
          :handler (fn [{{{:keys [x y]} :query} :parameters}]
                     {:status 200
                      :body {:total (+ x y)}})}
    :post {:summary &quot;plus with data-spec body parameters&quot;
           :parameters {:body {:x int?, :y int?}}
           :responses {200 {:body {:total int?}}}
           :handler (fn [{{{:keys [x y]} :body} :parameters}]
                      {:status 200
                       :body {:total (+ x y)}})}}]

  [&quot;/minus&quot;
   {:get {:summary &quot;minus with clojure.spec query parameters&quot;
          :parameters {:query (s/keys :req-un [::x ::y])}
          :responses {200 {:body (s/keys :req-un [::total])}}
          :handler (fn [{{{:keys [x y]} :query} :parameters}]
                     {:status 200
                      :body {:total (- x y)}})}
    :post {:summary &quot;minus with clojure.spec body parameters&quot;
           :parameters {:body (s/keys :req-un [::x ::y])}
           :responses {200 {:body (s/keys :req-un [::total])}}
           :handler (fn [{{{:keys [x y]} :body} :parameters}]
                      {:status 200
                       :body {:total (- x y)}})}}]]]

{:reitit.interceptor/transform dev/print-context-diffs ;; pretty context diffs
 :validate spec/validate ;; enable spec validation for route data
 :reitit.spec/wrap spell/closed ;; strict top-level validation
 :exception pretty/exception
 :data {:coercion reitit.coercion.spec/coercion
        :muuntaja m/instance
        :interceptors [;; swagger feature
                       swagger/swagger-feature
                       ;; query-params &amp;amp; form-params
                       (parameters/parameters-interceptor)
                       ;; content-negotiation
                       (muuntaja/format-negotiate-interceptor)
                       ;; encoding response body
                       (muuntaja/format-response-interceptor)
                       ;; exception handling
                       (exception/exception-interceptor)
                       ;; decoding request body
                       (muuntaja/format-request-interceptor)
                       ;; coercing response bodys
                       (coercion/coerce-response-interceptor)
                       ;; coercing request parameters
                       (coercion/coerce-request-interceptor)
                       ;; multipart
                       (multipart/multipart-interceptor)]}})
 (ring/routes
(swagger-ui/create-swagger-ui-handler
 {:path &quot;/&quot;
  :config {:validatorUrl nil
           :operationsSorter &quot;alpha&quot;}})
(ring/create-default-handler))
 {:executor sieppari/executor}))
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>Libs</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/8875/unmatched-paren-in-reitit-example</guid>
<pubDate>Fri, 22 Nov 2019 01:46:08 +0000</pubDate>
</item>
<item>
<title>Namespace.java: addAlias exception could be more informative</title>
<link>https://ask.clojure.org/index.php/8705/namespace-java-addalias-exception-could-more-informative</link>
<description>&lt;p&gt;In &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/clojure/clojure/blob/653b8465845a78ef7543e0a250078eea2d56b659/src/jvm/clojure/lang/Namespace.java#L224-L225&quot;&gt;https://github.com/clojure/clojure/blob/653b8465845a78ef7543e0a250078eea2d56b659/src/jvm/clojure/lang/Namespace.java#L224-L225&lt;/a&gt;, the &lt;code&gt;ns&lt;/code&gt; argument is not included in the exception message.&lt;/p&gt;
&lt;p&gt;This hinders debuggabiliity, especially when the &lt;code&gt;.addAlias&lt;/code&gt; call didn't originate from intentful aliasing, but rather, as a result of re-evaluating a namespace (which is the AST-building strategy that tools such as &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/jonase/eastwood&quot;&gt;https://github.com/jonase/eastwood&lt;/a&gt; use).&lt;/p&gt;
&lt;p&gt;Have you considered improving the message?&lt;/p&gt;
</description>
<category>Errors</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/8705/namespace-java-addalias-exception-could-more-informative</guid>
<pubDate>Thu, 10 Oct 2019 15:55:01 +0000</pubDate>
</item>
</channel>
</rss>