This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-11-29
Channels
- # adventofcode (9)
- # announcements (2)
- # aws (78)
- # babashka (55)
- # beginners (97)
- # biff (9)
- # calva (11)
- # cherry (2)
- # cider (8)
- # clerk (7)
- # clj-kondo (6)
- # clj-on-windows (4)
- # clojure (213)
- # clojure-austin (6)
- # clojure-europe (63)
- # clojure-nl (1)
- # clojure-norway (5)
- # clojure-spec (10)
- # clojure-uk (1)
- # clojurescript (14)
- # clr (2)
- # community-development (3)
- # conjure (14)
- # datomic (2)
- # deps-new (5)
- # dev-tooling (10)
- # editors (3)
- # emacs (3)
- # etaoin (19)
- # events (4)
- # fulcro (71)
- # holy-lambda (20)
- # java (3)
- # jobs (2)
- # leiningen (4)
- # lsp (24)
- # malli (15)
- # membrane (107)
- # music (1)
- # off-topic (29)
- # pedestal (4)
- # polylith (1)
- # portal (2)
- # rdf (5)
- # releases (7)
- # scittle (5)
- # shadow-cljs (8)
- # tools-build (15)
- # tools-deps (6)
- # xtdb (13)
Is there a good "REPL story" for babashka?
I mean something like rebel-readline to get auto-completion, etc. https://github.com/bhauman/rebel-readline/issues/214
Right now the best I could get is rlwrap bb
The nREPL story is good, the console REPL is similarly basic as Clojure. Maybe one day we should have something better
Do you use cider inspector? The connected REPL looks fine except I'm getting "Inspector error" for the results I'm trying to inspect.
Hmm that’s one thing that is Cider specific and not yet in bb. You can use portal with bb though, that’s a one liner on the command line and then you can browse your data too
You could make a bash alias if it’s too long to remember. I can look up the invocation when I’m at the kbd
@U06BE1L6T Something like this:
echo '[1 2 3]' | bb -Sdeps '{:deps {djblue/portal {:mvn/version "0.34.2"}}}' -e "(require '[portal.api :as p]) (def p (p/open)) (add-tap #'p/submit) (tap> *input*) @(promise)"
https://twitter.com/borkdude/status/1597505695800516609:
cat deps.edn |
bb -Sdeps '{:deps {djblue/portal {:mvn/version "0.34.2"}}}' \
-e "(require '[portal.api :as p]) (def p (p/open))
(add-tap #'p/submit) (tap> *input*) @(promise)"
Seems super handy! But (on 1.0.166) I just get:
----- Error --------------------------------------------------------------------
Type: java.lang.Exception
Message: Could not find namespace: portal.api.
Location: <expr>:1:1
----- Context ------------------------------------------------------------------
1: (require '[portal.api :as p]) (def p (p/open))
^--- Could not find namespace: portal.api.
2: (add-tap #'p/submit) (tap> *input*) @(promise)
----- Stack trace --------------------------------------------------------------
user - <expr>:1:1
Apparently I am missing something obvious...
(it seems to have been necessary before to build the classpath explicitly and following that approach I got it to work.)borkdude@m1 ~/dev/joyride (master) $ rm -rf ~/.m2/repository/djblue
borkdude@m1 ~/dev/joyride (master) $ cat deps.edn |
bb -Sdeps '{:deps {djblue/portal {:mvn/version "0.34.2"}}}' \
-e "(require '[portal.api :as p]) (def p (p/open))
(add-tap #'p/submit) (tap> *input*) @(promise)"
Downloading: djblue/portal/0.34.2/portal-0.34.2.pom from clojars
Downloading: djblue/portal/0.34.2/portal-0.34.2.jar from clojars
worked...Thanks! Still some environmental difference?! :thinking_face:
$ rm -rf ~/.m2/repository/djblue
$ cat deps.edn |
bb -Sdeps '{:deps {djblue/portal {:mvn/version "0.34.2"}}}' \
-e "(require '[portal.api :as p]) (def p (p/open))
(add-tap #'p/submit) (tap> *input*) @(promise)"
----- Error --------------------------------------------------------------------
Type: java.lang.Exception
Message: Could not find namespace: portal.api.
Location: <expr>:1:1
----- Context ------------------------------------------------------------------
1: (require '[portal.api :as p]) (def p (p/open))
^--- Could not find namespace: portal.api.
2: (add-tap #'p/submit) (tap> *input*) @(promise)
----- Stack trace --------------------------------------------------------------
user - <expr>:1:1
Ubuntu
I will create a reminder for myself to figure this out on ubuntu. Not sure why this happens
Thank you! Have a good day!
Yes, I thought of add-deps
too. It wil probably also work. But I was just wondering why the code of your tweet wouldn't work right away. Removing that cache doesn't help unfortunately.
Thanks anyway! Nothing urgent or that I can't work around.
On WSL2 + ubuntu it "just works" for me, so I'm afraid I can't repro it. If you can repro it at some point, let me know.
Does it help if you add this dep?
org.babashka/spec.alpha {:git/url ""
:git/sha "1a841c4cc1d4f6dab7505a98ed2d532dd9d56b78"}
Yes! That works!
Totally beyond my understanding why, but I'm sure you know exactly what's going on. 🙂
I did see a warning about clojure.spec, but it didn't affect the behavior of portal for me
Oh, oops, I'm sorry. I was now running it from file with the -cp
option (and clj -Spath ...
) still in it (which already worked before).
Removing that, it still does not work.
So this is to let you know that spec.alpha was not the issue after all.
Thanks anyway!
I will switch my attention to more urgent stuff now...
Ouch, found that I had a, long forgotten, explicit BABASHKA_CLASSPATH set in my .bashrc
.
Without that, the original snippet works fine (obviously).
Sorry for wasting your time.
Hello! I have a question around bootleg and the convert-to function, which I am using in a babashka script. Apologize if this is the wrong channel, but it seemed random enough that y’all might know: I am trying to convert two pages from a website into hickory data maps. The page structure should be identical for both, since they are coming from the same server-rendered site, it is just their content that’s different. The first url returns a proper hickory data map, but the second url only returns “\n”. Has anyone else encountered this? My example bb script:
(ns bb.example
(:require [babashka.pods :as pods]
[babashka.curl :as curl]))
(pods/load-pod "bootleg")
(require '[pod.retrogradeorbit.bootleg.utils :refer [convert-to]])
(defn url->hickory
[url]
(-> url curl/get :body (convert-to :hickory)))
(let [working-url ""
broke-url ""]
(println (str "result: " (keys (url->hickory working-url))))
(println (str "result: " (url->hickory broke-url))))
Thank you! (and apologies again if this is not the proper channel!)(and further note: when i view the source for either site, there doesn’t seem to be anything crazy different around it…though it’s a LOT of code so i coudln’t just visually tell. There at least isn’t a missing html tag in the broken one)
Ah, that’s smart. I’ll test by slurping instead of curling. Thank you, have a good night!
A small update: Had the same issue with the files on disk.
(spit "working.html" (:body (curl/get "")))
(spit "broken.html" (:body (curl/get "")))
(convert-to (slurp "broken.html") :hickory) ;=> "\n"
(convert-to (slurp "working.html") :hickory) ;=> big ol' hickory map
Ah, I think I figured it out! There was a /newline at the end of the broken.html file (and in that url). It seems like this was causing convert-to
to act unexpectedly.
You can see the behaviour with some other urls, too.
will not convert to hickory,
will.
If I change the fn to:
(-> url
curl/get :body
clojure.string/trim-newline
(convert-to :hickory))
It works!Judging from the note in <https://github.com/retrogradeorbit/bootleg#data-conversion>, this appears to be sort of a "lossy" conversion. It seems like the HTML gets 'closed', and then the newline starts the next 'form'. This can be demonstrated by converting to a hickory-seq:
(utils/convert-to "<p>1</p>\n" :hickory)
;; => "\n"
(utils/convert-to "<p>1</p>\n" :hickory-seq)
;; => ({:type :element, :attrs nil, :tag :p, :content ["1"]} "\n")
I guess whether that'd be considered a bug or not (in that it's just a newline) is open to interpretation.