This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-02-07
Channels
- # aleph (4)
- # announcements (9)
- # babashka (33)
- # beginners (6)
- # cider (8)
- # clj-kondo (5)
- # clojars (10)
- # clojure (10)
- # clojure-berlin (1)
- # clojure-dev (9)
- # clojure-europe (20)
- # clojure-gamedev (1)
- # clojure-miami (2)
- # clojure-nl (1)
- # clojure-norway (21)
- # clojure-uk (5)
- # clojurescript (12)
- # conjure (1)
- # cursive (20)
- # data-science (2)
- # datahike (10)
- # etaoin (5)
- # events (3)
- # fulcro (14)
- # gratitude (2)
- # honeysql (8)
- # humbleui (1)
- # hyperfiddle (60)
- # introduce-yourself (7)
- # jobs-discuss (27)
- # juxt (2)
- # kaocha (7)
- # lsp (23)
- # malli (9)
- # missionary (2)
- # off-topic (48)
- # pathom (24)
- # releases (1)
- # shadow-cljs (256)
- # sql (46)
- # xtdb (19)
Any ideas why I get this error in a babashka nrepl-server?
clojure.lang.ExceptionInfo: Could not resolve symbol: sci.impl.records/equals.
https://github.com/babashka/sci/blob/ca675599773ade82d83ff3a1aa476c25dc644f86/src/sci/impl/records.cljc#L59
What I’d like to do is be able to call equality on two different atom refs defined by a custom Type. Any ideas are welcome. My offending code is in thread.
(deftype Link [atom-ref meta validate-with watches read-with write-with deref-with check-with id] 5 references
Object
(equals [this other]
(and (instance? Link other)
(= atom-ref (.-atom-ref other))))
clojure.lang.IDeref
(deref [this]
(let [derefer (or deref-with (fn [_ a getf]
(getf (deref a))))]
(derefer this atom-ref read-with)))
clojure.lang.IAtom
(swap [this f]
(reset! this (f (deref this))))
(swap [this f x]
(reset! this (f (deref this) x)))
(swap [this f x y]
(reset! this (f (deref this) x y)))
(swap [this f x y z]
(reset! this (apply f (deref this) x y z)))
(compareAndSet [_ old-value new-value]
(let [_ (compare-and-set! atom-ref old-value new-value)
commit? (= old-value new-value)]
(when commit?
(swap! atom-ref new-value))))
(reset [this new-value]
(if write-with
(let [validate (.-validate-with this)]
(when-not (nil? validate)
(assert (validate new-value) "Invalid Value"))
(do (swap! atom-ref write-with new-value)
new-value))
(throw (Exception. "READ ONLY ATOM: Reset unavailable.")))))
My copy and paste game is poor, there is some kondo emacs gibberish at the top of that function…
(deftype Link [atom-ref meta validate-with watches read-with write-with deref-with check-with id]
Object
(equals [this other]
(and (instance? Link other)
(= atom-ref (.-atom-ref other))))
clojure.lang.IDeref
(deref [this]
(let [derefer (or deref-with (fn [_ a getf]
(getf (deref a))))]
(derefer this atom-ref read-with)))
clojure.lang.IAtom
(swap [this f]
(reset! this (f (deref this))))
(swap [this f x]
(reset! this (f (deref this) x)))
(swap [this f x y]
(reset! this (f (deref this) x y)))
(swap [this f x y z]
(reset! this (apply f (deref this) x y z)))
(compareAndSet [_ old-value new-value]
(let [_ (compare-and-set! atom-ref old-value new-value)
commit? (= old-value new-value)]
(when commit?
(swap! atom-ref new-value))))
(reset [this new-value]
(if write-with
(let [validate (.-validate-with this)]
(when-not (nil? validate)
(assert (validate new-value) "Invalid Value"))
(do (swap! atom-ref write-with new-value)
new-value))
(throw (Exception. "READ ONLY ATOM: Reset unavailable.")))))
If I run that code locally with bb dude.clj
it works, is this only occurring in the nREPL server?
if this isn't the full repro, e.g. if you also instantiate Link
etc to see the error, please also provide that. I'll be back later today
Oh, dear, I think you just touched it. I’ve got this in my emacs. I’ve got babashka.nrepl 0.0.6-SNAPSHOT with BB 0.8.157
By chance, how does babashka get updated on nix package manager?
I don't know, I don't maintain the nix side of things myself, but @U0303ET1R2T perhaps knows
I reckon I switched to an old bb when I went from putting bb in my bin myself to using nix home manager for it. Either way. Thanks for your help. I know where I went wrong… Good news! Not my app code!
babashka on nixpkgs is updated by a group of maintainers (and automatically with a bot, if the update is seamless) https://github.com/NixOS/nixpkgs/commits/a3ed4692b7bb68563541f9886a055b07e8675c3b/pkgs/development/interpreters/babashka/default.nix
Though you'd need to use nixpkgs-unstable to get the latest babashka. The latest stable release (nixpkgs-23.11) has babashka 1.3.186 https://github.com/NixOS/nixpkgs/blob/release-23.11/pkgs/development/interpreters/babashka/default.nix#L12
Babashka is 1.3.188 on nix-unstable. There is a link in the README https://github.com/babashka/babashka?tab=readme-ov-file#installation And more info https://github.com/babashka/babashka/blob/master/doc/nix.md Everything was up to date. I wasn’t following the correct instructions and using a bad nix channel for BB. Thanks to everybody who helps me have great tooling that is so easy to use if you actually RTFM. Sorry for the confusion.
What’s the babashka/fs
for something like find my/dir -name toto.yaml
? I can’t get it to work neither with glob
nor match
😞
tada 🎉
Lifesaver, thanks!
Ok, yes both work for me.
Can I add org.babashka/fs
to my project.clj
?
I added org.babashka/http-client
fine but fs
errors with:
Retrieving org/babashka/fs/0.5.20/fs-0.5.20.pom from public-github
Retrieving org/babashka/fs/0.5.20/fs-0.5.20.jar from public-github
Could not find artifact org.babashka:fs:jar:0.5.20 in central ( )
Could not find artifact org.babashka:fs:jar:0.5.20 in clojars ( )
Could not transfer artifact org.babashka:fs:jar:0.5.20 from/to public-github (): : Authentication is required but no CredentialsProvider has been registered
Failed to read artifact descriptor for org.babashka:fs:jar:0.5.20
This could be due to a typo in :dependencies, file system permissions, or network issues.
If you are behind a proxy, try setting the 'http_proxy' environment variable.
How are you specifying the dependency? Sounds like you need to specify https://
not git:
?
hmmm. then I get
Could not find artifact org.babashka:fs:jar:0.5.20 in central ( )
Could not find artifact org.babashka:fs:jar:0.5.20 in clojars ( )
Could not find artifact org.babashka:fs:jar:0.5.20 in public-github ()
it has its own repo and releases: https://github.com/babashka/fs so I assumed you can use it as a dep
$ git diff core/project.clj
diff --git a/core/project.clj b/core/project.clj
index cc99fb8..9f230af 100644
--- a/core/project.clj
+++ b/core/project.clj
@@ -21,6 +21,8 @@
[org.clojure/data.json "2.4.0"]
[clj-commons/clj-yaml "1.0.27"]
[org.snakeyaml/snakeyaml-engine "2.7"]
+ [org.babashka/fs "0.5.20"]
+ [org.babashka/http-client "0.3.11"]
[org.babashka/sci "0.8.41"]]
:plugins
@@ -31,7 +33,7 @@
:prep-tasks [["lein2deps" "--write-file" "deps.edn" "--print" "false"]]
- :repositories [["public-github" {:url ""}]]
+ :repositories [["public-github" {:url ""}]]
:global-vars {*warn-on-reflection* true}
but the docs don't say anything about using it in deps.edn like they do for http-client
https://github.com/babashka/babashka/blob/master/deps.edn#L26 Guess it's not meant to be used outside bb?
Weird because clj-commons/fs says to use it https://github.com/clj-commons/fs/blob/master/README.markdown?plain=1#L14
https://clojars.org/babashka/fs
looks like I need to use babashka/fs
not org.babshka/fs
yep. problem solved...