Fork me on GitHub

Is there an easy way I can make a separate lib that gets built as part of a consumer project? Right now I just stuck it in its own namespace but still in the same project


Or is that a more complex build system question


@anisoptera What do you mean by "lib that gets built"?


Clojure can consume projects in source form so what "build" are you asking about?


Hmm okay so if I just make a symlink to another project src dir or use a sub module


I’m just thinking of like, a shared lib between two projects


Yes that's easy to do


Are you using lein or deps?


Ok, with lein it's a bit harder, but still doable


Ahhh thanks!


With deps it's much easier though, because you can just define another folder as a dependency directly using: Where you can just define the dependency as: {:deps {time-lib/time-lib {:local/root "../time-lib"}}}


I'm not sure what you're asking. Can you provide a bit more background?


I have project A, “drone”, and it references project B, “web3”, and can import things from the web3 namespace


And I currently just have project b in project a’s src folder with its own namespace directories


With lein, you could do lein install and refer to it as a dependency. Or you could use lein checkouts perhaps.


But at some point I want to move it out of project A so a different project can share the code


Cool, that gives me some places to start :)


(and as @didibus noted in the thread -- this is much easier with the Clojure CLI and deps.edn but it is possible with lein and various plugins)


@anisoptera check out it’s sort of like Maven multi module projects, and does enable to do stuff like you described.


Deeply amusing because I was working with technomancy on a clojure codebase that was built using a maven multi module build while he was writing lein, and then came into work one day to find our boss had ripped out all of the maven multi module bits and turned it into one single lein build in a single commit because the multi module stuff was such a pain


It’s almost as if trying to circumvent artifact publishing process to eg. private Artifactory instance would be difficult on purpose… 🙂


has anyone deployed a jar inside nginx in docker? How does one do it?


you mean the same container? nginx + your application?


[docker-container [nginx [ jar-app]]]


so you want nginx to run your application?


nginx is a proxy server, not sure I ever saw it used as an application server


Yeah, that is not nginx’s task.


It depends more on your full deployment environment how you want to orchestrate/load balance/reverse proxy things.


We use nginx to serve some static content but other requests are just routed to a standalone jar running an embedded http server


(jetty is a solid choice for that)


Yeah, whatever your httpring server of choice uses will be fine. Jetty, Netty, Undertow, something's underneath, just lean on that.


Yeah I’m using aleph which I believe is built on netty


there is a version of nginx that can host clojure inside it, but outside of weird performance optimization (that you probably don't need) it's just a curiousity


i used nginx clojure in production to stream and cache files from a private s3 bucket with custom authorization checks and auditing implemented in clojure 😆

Jim Newton09:07:40

question about clojure.test, during my test there is a failure outside of an assertion. How do I get a debuggable/clickable stack trace? what I see is a stack trace printed into the repl. I'm calling the test using (clojure.test/test-vars [#'clojure-rte.rte-test/t-circular-dfa-rte-flow])


> debuggable You'd have to attach a debugger first and use a breakpoint - either at a specific location if you know it, or triggered by a specific exception. > clickable That depends on your development environment. E.g. in Cursive stack traces printed with .printStackTrace are clickable.

Jim Newton09:07:41

the stack trace printed by doesn't seem to be clickable in cider

Jim Newton10:07:25

I think it would be if clojure.test would re-throw the error (depending on some configuration variable of course)


cider instruments clojure.test to make it "clickable"

Jim Newton10:07:36

what do I have to do to make it clickable in cider? I'm calling the test function simply from the cider repl


(ns integration.test-test
  (:require [clojure.test :refer [deftest]]))

(deftest something
  (throw (Exception. "test")))
for me, that lets me navigate into the exception


I think that it just needs to get thrown back up to cider's test runner


how are you running the tests?

Jim Newton10:07:46

I'm calling it directly from the repl inside cider

Jim Newton10:07:03

I just found a menu item Cider Interactions -> Test -> Run Test

Jim Newton10:07:13

which will run 1 test, and let me navigate the failure.


yeah ... I tend to hit C-c C-t C-n to run all the tests in a namespace


but there are a bunch of shortcuts to get cider to run your tests, which will use cider's test reporting mechanism

✔️ 2
Jim Newton09:07:04

When I look at the code in clojure.test I see this.

(defn test-var
  "If v has a function in its :test metadata, calls that function,
  with *testing-vars* bound to (conj *testing-vars* v)."
  {:dynamic true, :added "1.1"}
  (when-let [t (:test (meta v))]
    (binding [*testing-vars* (conj *testing-vars* v)]
      (do-report {:type :begin-test-var, :var v})
      (inc-report-counter :test)
      (try (t)
           (catch Throwable e
             (do-report {:type :error, :message "Uncaught exception, not in assertion."
                      :expected nil, :actual e})))
      (do-report {:type :end-test-var, :var v}))))
Which looks like the test is always run within a try/catch, with no facility for re-throwing the exception.

Jim Newton13:07:31

question about clojure.test. I don't see in the doctoring of the is macro whether the msg argument is promised to NOT BE evaluated in case the test passes.

Jim Newton13:07:02

oops, that wan't a question: sorry. is the msg argument guaranteed to not be evaluated if the test passes?


Judging by the implementation, there are cases where msg is evaluated if the test passes.

Jim Newton14:07:04

is there a clever way to evoke a side effect only if the test fails?

Kyle Ferriter14:07:30

is returns a boolean and if-not only evaluates its branches when needed

Kyle Ferriter14:07:44

you could create a macro wrapper around these replicating is but ensuring the msg arg isn't evaluated unless the test fails


if you only need one branch, I think or is clearer: (or (is ....) (some side effect))


I think the or above is pretty clean. If you need some more firepower you can make your own do-report that does something on failures. Since collecting these failures is a side effect of the actual testing suite


oh right, clojure.test has that tooling

Alex Miller (Clojure team)13:07:56

if you don't see a guarantee then you probably shouldn't assume a guarantee

😭 2

is has a return value to indicate success, putting side effects in the place of the message string is just weird

☝️ 2

funny discovery today: if I put a future in a hash map and that future has failed, pprint omits the key/value pair entirely, and prints the message of the exception, then the rest of the map afterward


oh - printing the rest was accidental, it seems there's some threading race with the printing


full output in a thread here to avoid spamming


what pprint does:

org.noisesmith.expecting=> (def bad-calculations {:a (future (/ 1 0)) :b (future (+ "hello" "world")) :c 42})
org.noisesmith.expecting=> (pprint bad-calculations)
Execution error (ArithmeticException) at org.noisesmith.expecting/fn (a2ad38d8de6e530d571a2f0e206a3214c8d6fac1c305fe67d8ab4bf380e724df-init.clj:1).
Divide by zero


the raw value:

org.noisesmith.expecting=> bad-calculations
{:a #object[clojure.core$future_call$reify__8454 0x447aea69 {:status :failed, :val #error {
 :cause "Divide by zero"
 [{:type java.util.concurrent.ExecutionException
   :message "java.lang.ArithmeticException: Divide by zero"
   :at [java.util.concurrent.FutureTask report "" 122]}
  {:type java.lang.ArithmeticException
   :message "Divide by zero"
   :at [clojure.lang.Numbers divide "" 188]}]
 [[clojure.lang.Numbers divide "" 188]
  [clojure.lang.Numbers divide "" 3901]
  [org.noisesmith.expecting$fn__1769 invokeStatic "a2ad38d8de6e530d571a2f0e206a3214c8d6fac1c305fe67d8ab4bf380e724df-init.clj" 1]
  [org.noisesmith.expecting$fn__1769 invoke "a2ad38d8de6e530d571a2f0e206a3214c8d6fac1c305fe67d8ab4bf380e724df-init.clj" 1]
  [clojure.core$binding_conveyor_fn$fn__5754 invoke "core.clj" 2030]
  [clojure.lang.AFn call "" 18]
  [java.util.concurrent.FutureTask run "" 264]
  [java.util.concurrent.ThreadPoolExecutor runWorker "" 1128]
  [java.util.concurrent.ThreadPoolExecutor$Worker run "" 628]
  [java.lang.Thread run "" 829]]}}], :b #object[clojure.core$future_call$reify__8454 0x43d12484 {:status :failed, :val #error {
 :cause "class java.lang.String cannot be cast to class java.lang.Number (java.lang.String and java.lang.Number are in module java.base of loader 'bootstrap')"
 [{:type java.util.concurrent.ExecutionException
   :message "java.lang.ClassCastException: class java.lang.String cannot be cast to class java.lang.Number (java.lang.String and java.lang.Number are in module java.base of loader 'bootstrap')"
   :at [java.util.concurrent.FutureTask report "" 122]}
  {:type java.lang.ClassCastException
   :message "class java.lang.String cannot be cast to class java.lang.Number (java.lang.String and java.lang.Number are in module java.base of loader 'bootstrap')"
   :at [clojure.lang.Numbers add "" 153]}]
 [[clojure.lang.Numbers add "" 153]
  [org.noisesmith.expecting$fn__1771 invokeStatic "a2ad38d8de6e530d571a2f0e206a3214c8d6fac1c305fe67d8ab4bf380e724df-init.clj" 1]
  [org.noisesmith.expecting$fn__1771 invoke "a2ad38d8de6e530d571a2f0e206a3214c8d6fac1c305fe67d8ab4bf380e724df-init.clj" 1]
  [clojure.core$binding_conveyor_fn$fn__5754 invoke "core.clj" 2030]
  [clojure.lang.AFn call "" 18]
  [java.util.concurrent.FutureTask run "" 264]
  [java.util.concurrent.ThreadPoolExecutor runWorker "" 1128]
  [java.util.concurrent.ThreadPoolExecutor$Worker run "" 628]
  [java.lang.Thread run "" 829]]}}], :c 42}


note that it's all data, pprint is being "helpful" in a way that obscures data now that we have good exception printing in core


though the newlines in the exception printer act slightly odd when inline inside a map


anyway, the behavior of pprint hides data in this case


would customizing or fixing this be a question of adding / changing a print-dup implementation?


pprint doesn't always fliush


yeah that output definitely looks like failure to flush (for starters)


yeah, even when a future is not in a failed state the pprint output is worse than the default IMHO


Hi, I have a question regarding java interop. I'm trying to see how to use imgui from Clojure using, and I am really not sure how to reproduce the super.initImGui in Clojure, or how to call a class Should there be some intermediate java work to make writing bindings for it more palatable?


@UGH9KH1DF, just curious why you're trying ImGui over some of the other options like seesaw, cljfx, skija, and quil. I've been working on my own desktop UI clojure lib and am interested in knowing what potential users are looking for.


Well, it looks very complete (e.g. I need to do lots of graphs & tables and it's all built in) and friends told me about it, but I haven't done lots of comparison with what's available I admit

👍 2

isn't quil mostly for procedural art?


that's quil's most popular use case, but it can be used for other stuff. I wasn't sure what you were building


ImGui is pretty neat


it looks like it, and I hope I'll manage to write bindings for it, but I'm not off to a good start 😄


nb. this shouldn't be an issue for a GUI lib (they don't usually thread their UI code) but proxy-super is not thread safe


not ideal. There is another java bindings to imgui, maybe I'll have best luck with it


I tried but am unable to connect two repls simultaneously in atom chlorine. Is there no way around this?


Hi, Chlorine author here. Indeed, there's no way. What you may be able to do is have a script to disconnect from one REPL, and connect to the other.


The only trouble I see is that you won't explicitly have a command to disconnect the REPL, but you also can handle something with:

// Disconnect if something exists
atom.commands.dispatch(atom.views.getView(atom.workspace.getActiveTextEditor()), 'chlorine:disconnect')
setTimeout(() => {
  //connect to a new REPL
}, 200) // a time to allow REPL disconnection


and what’s the best way to have a cljs + clj repl workflow on vscode?


just need to run two separate instances of atom


@ps There's a #chlorine-clover channel where the author might be able to help you.


I’m using Tailwind CSS for a project using only server-side rendering i.e. only clojure, no clojurescript nor JS. Setting the reasons to do this aside, I’m thinking about the best way to add classes programatically in this scenario. Example let’s say we have this function that returns some hiccup

(defn cool-element
  [ {:id "cool-element"}
    [:h1 "I'm an element."]])
How would you change this fn to accept & classes and add them to :div ? Maybe this is not the best notation for this use case? :thinking_face: I thought about simply manipulating strings, concatenating and turning into keyword


@UFPEDL1LY Hiccup accepts any properties that HTML accepts. So you can do [:div {:id "cool-element, :class "bg-yellow-500"}] . The whole dot-separated, keyword class thing is just a shorthand.


@U05476190 is this particular to reagent? It doesn’t work for me with pure hiccup. I am not using clojurescript at all.


I didn't realize this was reagent specific. [0] I guess you'd have to write a helper function to do something similar:

[:div {:class (classes ["a-class" (when active? "active") "b-class"])}]