Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Babashka support #21

Open
borkdude opened this issue Feb 3, 2023 · 7 comments
Open

Babashka support #21

borkdude opened this issue Feb 3, 2023 · 7 comments

Comments

@borkdude
Copy link

borkdude commented Feb 3, 2023

I'm currently working on better reader tag support in babashka. In the next release tags in data_readers.clj(c) will be automatically picked up, whereas before you had to set them manually by manipulating *data-readers*.

I tested that new feature using this library: https://twitter.com/borkdude/status/1621594481605615618

The output for babashka in this lib currently isn't great yet (it prints an implementation namespace of bb), but I think we could make it just output the namespace and line info:

user=> #p [1 2 3]
#p[script:12] [1 2 3]

Requesting a stacktrace at the point of execution isn't well supported in SCI / bb yet (this may come in the future, but that's going to take a while), but there's other ways of getting the above simplified output.

If there's any interest, I can look into improving this output.

@borkdude
Copy link
Author

borkdude commented Feb 5, 2023

The data_reader.clj(c) support has been released now.

@filipesilva
Copy link

Was trying to use it in bb today, and I don't think it works anymore? This is what I see:

filipesilva@m4 ~/r/personal > bb -Sdeps "{:deps {hashp/hashp {:mvn/version \"0.2.2\"}}}"
Babashka v1.12.195 REPL.
Use :repl/quit or :repl/exit to quit the REPL.
Clojure rocks, Bash reaches.

user=> (require 'hashp.core)
clojure.lang.ExceptionInfo: Could not resolve symbol: clojure.instant/thread-local-utc-timestamp-format [at fipp/ednize/instant.clj:11:26]

I have a longer stack trace from trying to use it in a script

----- Error --------------------------------------------------------------------
Type:     clojure.lang.ExceptionInfo
Message:  Could not resolve symbol: clojure.instant/thread-local-utc-timestamp-format
Data:     {:type :sci/error, :line 8, :column 1, :file "fipp/ednize/instant.clj", :phase "analysis"}
Location: fipp/ednize/instant.clj:11:26
Phase:    analysis

----- Context ------------------------------------------------------------------
 7:
 8: (extend-protocol IEdn
 9:   Timestamp
10:   (-edn [x]
11:     (let [s (format-hack #'clojure.instant/thread-local-utc-timestamp-format x)]
                             ^--- Could not resolve symbol: clojure.instant/thread-local-utc-timestamp-format
12:       (tagged-literal 'inst s)))
13:
14:   Date
15:   (-edn [x]
16:     (let [s (format-hack #'clojure.instant/thread-local-utc-date-format x)]

----- Stack trace --------------------------------------------------------------
fipp.ednize.instant                       - fipp/ednize/instant.clj:11:26
fipp.ednize/format-hack                   - fipp/ednize.clj:27:1
fipp.ednize.instant/let                   - fipp/ednize/instant.clj:11:13
fipp.ednize.instant                       - fipp/ednize/instant.clj:11:5
clojure.core/let                          - <built-in>
... (run with --debug to see elided elements)
fipp.visit                                - fipp/visit.cljc:3:3
puget.printer                             - puget/printer.clj:94:3
hashp.core                                - hashp/core.clj:2:3
braid.cli                                 - /Users/filipesilva/repos/personal/braid/src/braid/cli.clj:2:3
exec-a6ba1463-e50f-4566-bd44-2cd8f7c2e8c9 - <expr>:4:1

@borkdude
Copy link
Author

@filipesilva We could add this var here:

https://github.com/babashka/babashka/blob/master/src/babashka/impl/clojure/instant.clj

I'll check and see if there's other stuff I'll run into

@borkdude
Copy link
Author

I checked and this var is in clojure.instant is actually private and no longer needed. See this contribution to fipp that I made some time ago to fix it: https://github.com/brandonbloom/fipp/blob/master/src/fipp/ednize/instant.clj

So it might just be a matter of upgrading fipp.

@filipesilva
Copy link

Can confirm that forcing a recent version of fipp works:

filipesilva@m4 ~/r/personal> bb -Sdeps "{:deps {hashp/hashp {:mvn/version \"0.2.2\"} fipp/fipp {:mvn/version \"0.6.27\"}}}"
Babashka v1.12.195 REPL.
Use :repl/quit or :repl/exit to quit the REPL.
Clojure rocks, Bash reaches.

user=> (require 'hashp.core)
nil

Updating the dep in hashp actually means updating it in https://github.com/greglook/puget though, so I expect this to be a bit more involved.

@filipesilva
Copy link

Actually it's enough to just update Puget version. It uses a fipp dep that includes your fix.

filipesilva added a commit to filipesilva/hashp that referenced this issue Feb 16, 2025
Fix weavejester#21 (comment)

This does not fix weavejester#21 proper though, it just allows it to run in Babashka.
@filipesilva
Copy link

#25

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants