Fork me on GitHub

Nice to meet you. I have a question about a description of project.clj, leiningen. How do I specify the latest of master in dependencies in the project.clj file? I reported a bug, and the author fixed that in I want to use this fixed version, but I do not know how to do.


The Clojure CLI (and deps.edn) can easily use git deps but Leiningen requires a plugin. I haven't used Leiningen for six years at this point but I believe there's a lein-git-deps plugin (although it hasn't been touched for 8 years?). Maybe ask in #leiningen about git deps? Or switch your project to the CLI and deps.edn?

👀 1

Thank you for your reply! I will check them.


• clone the repo • in project.clj, change defproject sicmutils "0.19.2" to defproject sicmutils "0.19.2-SNAPSHOT" • run lein install in the repo dir • in your project, change the dependency version to “0.19.2-SNAPSHOT”


I’m trying out migratus and it’s showing me how much I don’t understand about how to manage a database connection in a clojure app. I read through and I’m still pretty confused on how I should go about managing a db connection (without using a 3rd party library.. I’ll eventually get to component/integrant/etc) The problem rn is that when I call miginit more than once in the REPL, I get a This connection has been closed . How do I keep my db connection alive and available without a third party library?


Sounds like Migratus is closing the connection? I'm not familiar with that library but I would say using atoms to handle datasources and connections seems wrong to me.


Looks like Migratus still uses java.jdbc rather than next.jdbc so your :db key should be a "db-spec", which is a hash map that describes your db -- basically :db db-config ought to do it.


You don't need any of that get-datasource / get-connection stuff, as far as I can see @U01JYKT6ENL


Hm okay. if I don’t have the get-datasource/connection fns, when/where should I create those? just in the main- fn?


And what would I use instead of an atom?


You don't need any of that for Migratus.


What is db-config? A hash map with :dbtype / :dbname etc?

yes 1

Using next.jdbc functions with Migratus won't help you since it uses the older java.jdbc library.


We can talk about using next.jdbc in a program separately from Migratus (but that discussion better belongs in #sql).

👍 1

db-config is your next.jdbc map. Migratus says it takes a db connection so I was passing the db connection retrieved from jdbc/get-connection And sounds good, thank you.


Migratus docs specifically show that it takes a db-spec hash map, albeit the old-fashioned one that even with java.jdbc has been outdated for years.


(def config {:store                :database
             :migration-dir        "migrations/"
             :init-script          "init.sql" ;script should be located in the :migration-dir path
             ;defaults to true, some databases do not support
             ;schema initialization in a transaction
             :init-in-transaction? false
             :migration-table-name "foo_bar"
             :db {:classname   "org.h2.Driver"
                  :subprotocol "h2"
                  :subname     "site.db"}})
that is just the old-fashioned form of
(def config {:store                :database
             :migration-dir        "migrations/"
             :init-script          "init.sql" ;script should be located in the :migration-dir path
             ;defaults to true, some databases do not support
             ;schema initialization in a transaction
             :init-in-transaction? false
             :migration-table-name "foo_bar"
             :db {:dbtype "h2"
                  :dbname     "site.db"}})


gotchya.. so instead of trying to reuse and pass the connection just reuse the db-spec hash map 👍


Let me know how that goes.

🙏 1

It’s working well. I can run those migrate commands multiple times from the repl without any errors now!


hello, i have a function in php like this $ret = openssl_decrypt($ret['encData'], 'aes-128-cbc', $key, OPENSSL_DONT_ZERO_PAD_KEY, $key); , how can i translate this in clojure


(fn [{:keys [name]}] (keyword name))
is there an even more terse way to say this?

Darin Douglass14:11:43

(comp keyword :name)

🎉 1

Is it possible to have a spec to validate that a value of a map arg has a relationship with another arg? It's my first foray into spec and I'm trying to see what it can do. Whenever I try to extract a value from a map in my spec, I get a NullPointerException, telling me I'm probably doing it wildly wrong or applying a wildly wrong concept:

(defn arg-test
  [test-map other-field]
  (println test-map)
(s/def ::pos-int-val (s/and int? pos?))
(s/def ::map-def (s/keys
                  :req [::pos-int-val]))
(s/fdef arg-test
  :args (s/and (s/cat :test-map ::map-def :other-field ::pos-int-val)
               #(< (get-in % [:test-map :test-val]) (:other-field %))))

(stest/check `arg-test)


in that function you are treating % as if it is a map with keys that are the sequence of arguments. You should confirm what argument is actually passed to that function


My issue was actually that the namespace of the key was incorrect. I got it working by fully qualifying, but I'll do a bit more exploring to figure out a better way. Thank you for the suggestion though. It reminded me that in the world of Clojure, I can easily query into things like the type of % 🙂


yeah. i looked at it and just instrumented the function rather than exercising it like that and made the function just print its argument and return true


repl and redefining can help out in exploration


I just did some experimenting with instrument and that actually is really useful in figuring out what's going on. Thanks again! 🙂

👍 1
Grzegorz Smajdor20:11:10

Hi folks, have an issue with starting new project on osx, with clojure and openjdk 17.0.1 2021-10-19, after creating a new project lein new figwheel kotek --reagent and then running lein figwheel inside, I get Any help appriciated


Is this on an M1 Mac? I'm just looking at the dependencies there (Figwheel / Hawk / Barbary WatchService) and it looks like the latter was originally a port to Java 6 of functionality from Java 7 and neither of those last two libraries have been updated in years).


I've never used lein-figwheel but I got the impression that it's pretty much deprecated and folks should be using Figwheel Main instead, these days?


There's are three Figwheel-related channels you could try asking in: #lein-figwheel #figwheel #figwheel-main @UNDL444G4

Grzegorz Smajdor20:11:23

right, its M1. thx will check channels!


I'm guessing the Barbary filewatch library either doesn't have an M1 native impl or it relies on a low-level library that doesn't exist on an M1 Mac... purely a guess tho'...


There should be native filewatch capability in the JDK itself but I don't know if there are updates to Figwheel/Sidecar that depend on that instead of Hawk.

Grzegorz Smajdor20:11:47

I might try to use figwheel main then, never used that before.

Grzegorz Smajdor22:11:45

hi, just experimenting with figwheel-main seems that the files are not hot-reloading on M1. Anything to fix that?

Grzegorz Smajdor22:11:55

I’ve run lein new figwheel-main test-app -- +deps --reagent


I don't use Leiningen so I can't help you. I'm not currently doing ClojureScript so I can't help you with that either. Ask in the channels I pointed you at.


(I haven't used Leiningen for six years and when I was doing ClojureScript some, earlier this year, I was using the Clojure CLI and a non-M1 Mac)


But no, you do not need to add Hawk as a dependency. I only pointed that out because it seems really outdated and it is what lein-figwheel seems to be using via Figwheel Sidecar. Which is why I pointed you at Figwheel Main since I believe that is actively being maintained.

Grzegorz Smajdor22:11:18

great, thank you. I had some projects before I’ve switched to M1 and they were working, now need to get back to them… and they are not working anymore 😉

Grzegorz Smajdor22:11:32

should not have switched to M1 - life would be much more easier


I went through two chipset changes on Mac and they usually have some speed bumps. 680x0 -> RISC and then RISC -> Intel. But I've been in the process of moving completely to Windows over the last few years -- no more Apple products for me!