This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-08-05
Channels
- # announcements (1)
- # babashka (5)
- # beginners (151)
- # calva (43)
- # clj-kondo (23)
- # cljdoc (1)
- # cljs-dev (6)
- # cljsrn (10)
- # clojure (60)
- # clojure-australia (1)
- # clojure-europe (26)
- # clojure-gamedev (14)
- # clojure-nl (1)
- # clojure-spec (10)
- # clojure-uk (80)
- # clojurescript (66)
- # clojureverse-ops (4)
- # community-development (7)
- # conjure (8)
- # datomic (15)
- # deps-new (1)
- # docker (27)
- # emacs (2)
- # fulcro (13)
- # honeysql (13)
- # java (5)
- # jobs-discuss (43)
- # lsp (121)
- # luminus (13)
- # malli (1)
- # off-topic (73)
- # pathom (12)
- # polylith (29)
- # practicalli (4)
- # re-frame (35)
- # reagent (44)
- # remote-jobs (5)
- # rewrite-clj (2)
- # sci (7)
- # shadow-cljs (125)
- # sql (4)
- # tools-deps (9)
- # xtdb (5)
In ghostwheel
's readme, there's this line about enabling it in a clojure project:
On Clojure – launch the REPL / build with the JVM system property -Dghostwheel.enabled=true
how would I have to edit my clojure cli repl command so that that's included? This doesn't work:
/run/current-system/sw/bin/clojure -Sdeps '{:deps {nrepl/nrepl {:mvn/version "0.8.3"} refactor-nrepl/refactor-nrepl {:mvn/version "2.5.1"} cider/cider-nrepl {:mvn/version "0.25.9"}} :aliases {:cider/nrepl {:main-opts ["-m" "nrepl.cmdline" "--middleware" "[cider.nrepl/cider-middleware]"]}}}' -M:cider/nrepl -Dghostwheel.enabled=true
@meditans -Dghostwheel.enabled=true
needs to be -J-Dghostwheel.enabled=true
when using the clojure
tool. or within the -Sdeps
map :jvm-opts ["-Dghostwheel.enabled=true"]
Thanks for the immediate response @U05224H0W 🙂
Neither option works for me, but maybe at this point it's because I'm trying to use a projectless approach with add-libs
. Here's my standalone file:
(use 'clojure.tools.deps.alpha.repl)
(add-libs {'gnl/ghostwheel {:mvn/version "0.3.9"}})
(ns user
#:ghostwheel.core{:check true, :num-tests 10}
(:require [ghostwheel.core :as g :refer [>defn >defn- >fdef => | <- ?]]))
(>defn addition
[a b]
[pos-int? pos-int? => int? | #(> % a) #(> % b)]
(- a b))
(g/check)
;; "Ghostwheel disabled => Start the REPL with the `-Dghostwheel.enabled=true` JVM system property to enable."
then I jack in into cider, editing the launch command as you suggested, then I eval the buffer. Is there any known reason for which this shouldn't work?
I tried:
/run/current-system/sw/bin/clojure -Sdeps '{:deps {nrepl/nrepl {:mvn/version "0.8.3"} refactor-nrepl/refactor-nrepl {:mvn/version "2.5.1"} cider/cider-nrepl {:mvn/version "0.25.9"}} :aliases {:cider/nrepl {:main-opts ["-m" "nrepl.cmdline" "--middleware" "[cider.nrepl/cider-middleware]"]}}}' -M:cider/nrepl -J-Dghostwheel.enabled=true
in fact, if I put it before -M
, the get function returns true
. But why? And how should I have known?
-M
executes clojure.main
so I think every argument coming after that is treated as an argument to clojure.main instead of the clojure script itself
the thing as a whole doesn't work yet, as I get cannot resolve user
(where user
is the namespace) when I try to issue (g/check)
but at least it's not a configuration problem
oh, but it seems that if I substitute user
with interesting.user
as the name of the namespace, all works 😮
Does anyone know the history of the convention that clojure projects organize themselves such that all identifiers in one namespace are defined in a single file whose name indicates the namespace? This is not a requirement of the language, but seems to be a convention presumed by several tools. I suspect that this convention developed at some point after the birth of the language. A bit of evidence to support my hypothesis is the file cl_format.clj
which defines the function cl-format
as well as several helper functions in its implementation. The file cl_format.clj
does not define a namespace named cl-format
but rather contains a line at the top (in-ns 'clojure.pprint)
which to me seems like the more logical way to organize projects. I.e., group definitions such as functions, data structures, and variables into files according to the purpose they serve rather than according to which namespace they happen to belong.
@jimka.issy this might help https://code.thheller.com/blog/shadow-cljs/2021/05/13/paths-paths-paths.html
although written for CLJS the same "content addressing" applies for clojure. things need to be discoverable by name so you can reference them. sure you can split them and use load tricks but that just becomes dirty after a while. IMHO, YMMV
content addressable vs ad-hoc loading are not the only options. but yes there needs to be a way to find the code given its name. but that mapping need not be the identity function.
IIRC ns
:require
was added later and wasn't part of the language at first. so the clojure.pprint
may just be a remnant of that time
if you ask me that load
style is horrible. its very very common in the JS world and re-exporting stuff all over the place. nightmare to find actual source for something sometimes. just jumping from one file to another following a trail of breadcrumbs 😛 much better to look at a name and directly know where to find it
Regarding tools.build
and current Deps support, when consuming external source (git or local) that has a build step, is there a way to parametrize that step at the level of the consumer?
Eg. Consuming from a monorepo but I only need to build and use one of the many library it contains. Something like
{:deps {io.github.foo/bar {:git/sha "xxxxx"
:exec-args [:lib/baz true]}}}
https://github.com/kwladyka/consistency-clj/blob/master/.github/workflows/clojars.yaml https://github.com/kwladyka/consistency-clj/blob/master/pom.xml Does it help?
I mean something like this, in deps.edn
:
{:deps {io.github.foo/bar {:git/sha "xxxxx" :build :some-arg}}}
So that :deps/prep-lib
in the consumed repo would forward :some-arg
to the build function.As as consumer of that repo, I would have the ability to influence the build process.
some of them https://github.com/kwladyka/consistency-clj/blob/master/deps.edn#L19-L28 but for example not version
I'll edit my question, it's in the context of tools.build
😉
Supposing something like this is already setup https://clojure.org/guides/tools_build#_parameterized_build
is there a web page URL which contains the cl-format code? there is a source link on many packages in clojure.docs but not this one?
It's on github if that's what you mean : https://github.com/clojure/clojure/blob/master/src/clj/clojure/pprint/cl_format.clj
How can i isolate clojure instances? I have dynamically loaded code that define defmethods for dispatch. However, I also want to be able to dynamically load and test code (eg. "version n+1") in a way that won't affect the previous version. Obviously I could run in a separate process, but is there something I can do short of that?
You can put the new version in a new namespace. There`s also the dark art of classloader isolation, but tbh you're better off starting a new process.
ill take a look at with-redefs, i suspect though defmethod is problematic. yeah, i looked into classloader, but wasn't finding enough info, as you say "dark art".
yes, i was going to rename the namespaces, but that alone didn't seem sufficient, again the defmethod would be problematic, and I'm not sure what else might be.
i suppose i could change the defmulti :require, so that it's effectively a different defmethod, but then it all seems fragile.
on this page, i think they mean the last line that says ;;true should be ;;false?? https://clojuredocs.org/clojure.core/*use-context-classloader*
On a related note, do you guys think it would make sense to run independent Clojure apps (servers) in an app server like Tomcat to save memory by sharing a JVM?
If the apps are truly independent it's a bad idea, as they might have incompatible Maven dependency trees If 'apps' is more like 'logical services', yes. Polylith goes in that direction :) Still one has to take care of shared resources like thread pools, singletons, locks etc. Anything that might create contention
memory is cheap, I think extra work will cost more, than pay for memory. At least I use docker everywhere.
I think Tomcat has isolated classloaders, so incompatible deps should work. I run my stuff on cheapest VPS I could find, RAM is usually the biggest constraint for me.
this is my opinion: increasing complexity is not worth. I prefer to keep infrastructure simple. I believe it gives much more benefits.
Try google cloud run
. Probably for your needs you can run instances for free. Just guess.
I noticed that core.memoize has something called RetryableDelay
and a d-lay
`https://github.com/clojure/core.memoize/blob/master/src/main/clojure/clojure/core/memoize.clj#L54
It's private now, but I'm thinking this would be pretty useful for me, to have a delay that on deref exception will throw and not cache, so on the next deref it retries.
Would it make sense to make this public?
It's not something I would want folks to rely on as part of a public API.
(I think it's nasty code but it serves a purpose)
I'd have to go revisit it to elaborate further and I'm not working on it right now.
I'll try to remember to review it in more detail and report back when I cut the next release -- because I need to bump its dependency on core.cache
to pick up the LU/LRU bug fixes in that lib's 1.0.217 release from the other day.
Ya, I think for me I was thinking it might not fit conceptually with core.memoize, I could see maybe a separate thing just having various types of delays instead. One that doesn't cache on error, one with a ttl, one that can be invalidated, etc.
Hi folks! Any idea how to fix
❯ clojure -M:serve • [master]
Execution error (UnsatisfiedLinkError) at java.lang.ClassLoader$NativeLibrary/load0 (ClassLoader.java:-2).
/private/var/folders/06/46ycckp94db7k29k022nxjp00000gn/T/jna9260967378841025822.tmp: dlopen(/private/var/folders/06/46ycckp94db7k29k022nxjp00000gn/T/jna9260967378841025822.tmp, 1): no suitable image found. Did find:
/private/var/folders/06/46ycckp94db7k29k022nxjp00000gn/T/jna9260967378841025822.tmp: code signature in (/private/var/folders/06/46ycckp94db7k29k022nxjp00000gn/T/jna9260967378841025822.tmp) not valid for use in process using Library Validation: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed.
? I have never seen this before and this worked on another machine (with a different JVM). Using openjdk 12.0.2 2019-07-16, Clojure CLI version 1.10.3.933 🙏downgrading from java 12 to 11 "fixed" it