Fork me on GitHub
#babashka
<
2023-08-14
>
pesterhazy13:08:25

Howdy! Maybe a bit of an odd question. I'd like to cache files in ~/.deps.clj, but not sure what's the best way to get bb to download clojure-tools. Here's my best shot:

bb -Sdeps '{:deps {org.jetbrains/dummy {:mvn/version "0.1.2"}}}' print-deps
This triggers bb to download clojure-tools as a side-effect (which is needed for maven deps). The downside is that it downloads that particular dependency – if that's not available, there's another opportunity for flakiness. Is there a way around this?

pesterhazy13:08:32

Why do I want to do this? A while back there was a day where the server hosting clojure-tools was very flaky, and we added a stanza to our circleci config to cache the file.

# Temprorary hack to unblock CI
  clojure-deps-install:
    steps:
      - restore_cache:
          key: ~/.deps.clj/1.11.1.1347/ClojureTools/tools.zip-{{ arch }}
      - run:
          name: 'Install clojure tools'
          command: |
            if [ ! -f ~/.deps.clj/1.11.1.1347/ClojureTools/tools.zip ]; then
                curl  --retry 5 --create-dirs --output ~/.deps.clj/1.11.1.1347/ClojureTools/tools.zip
            else
                echo "File found. Skipping download of clojure tools"
            fi
      - save_cache:
          key: ~/.deps.clj/1.11.1.1347/ClojureTools/tools.zip-{{ arch }}
          paths:
            - ~/.deps.clj/1.11.1.1347/ClojureTools/tools.zip

borkdude13:08:02

just bb clojure -Spath maybe?

pesterhazy13:08:40

works!

bb clojure -Spath
Clojure tools not yet in expected location: /Users/user/.deps.clj/1.11.1.1347/ClojureTools/clojure-tools-1.11.1.1347.jar
Downloading  to /Users/user/.deps.clj/1.11.1.1347/ClojureTools/tools.zip
Unzipping /Users/user/.deps.clj/1.11.1.1347/ClojureTools/tools.zip ...
Successfully installed clojure tools!
src:/Users/user/.m2/repository/org/clojure/clojure/1.11.1/clojure-1.11.1.jar:/Users/user/.m2/repository/org/clojure/core.specs.alpha/0.2.62/core.specs.alpha-0.2.62.jar:/Users/user/.m2/repository/org/clojure/spec.alpha/0.3.218/spec.alpha-0.3.218.jar

borkdude13:08:18

I'm updating deps.clj as we speak to the new download location on Github

borkdude13:08:28

but this will take a bit to end up in a new bb

pesterhazy13:08:38

I didn't know about bb clojure. Now I'm wondering about what else can be done with that command :thinking_face:

borkdude13:08:07

bb clojure is the same as the clojure function in .bb.edn, all backed by deps.clj

borkdude13:08:44

I started a new channel called #C05ND742UAC to discuss deps.clj specific questions :)

🎉 8