Fork me on GitHub
#clojure
<
2023-05-21
>
Dar17:05:42

Is add-libs from 1.12.0-alpha3 working for anyone? Am I using it wrong? Getting the following error(even when explicitly adding org.clojure/tools.deps as a dependency):

Clojure 1.12.0-alpha3
user=> (add-libs '{ring/ring {:mvn/version "RELEASE"}})
Namespace could not be loaded: clojure.tools.deps
Execution error at clojure.java.process/exec (process.clj:144).
Process failed with exit=1
user=> *e
#error {
 :cause "Process failed with exit=1"
 :via
 [{:type java.lang.RuntimeException
   :message "Process failed with exit=1"
   :at [clojure.java.process$exec invokeStatic "process.clj" 144]}]
 :trace
 [[clojure.java.process$exec invokeStatic "process.clj" 144]
  [clojure.java.process$exec doInvoke "process.clj" 128]
  [clojure.lang.RestFn applyTo "RestFn.java" 140]
  [clojure.core$apply invokeStatic "core.clj" 667]
  [clojure.tools.deps.interop$invoke_tool invokeStatic "interop.clj" 34]
  [clojure.tools.deps.interop$invoke_tool invoke "interop.clj" 14]
  [clojure.repl.deps$add_libs invokeStatic "deps.clj" 48]
  [clojure.repl.deps$add_libs invoke "deps.clj" 35]
  [user$eval1 invokeStatic "NO_SOURCE_FILE" 1]
  [user$eval1 invoke "NO_SOURCE_FILE" 1]
  [clojure.lang.Compiler eval "Compiler.java" 7177]
  [clojure.lang.Compiler eval "Compiler.java" 7132]
  [clojure.core$eval invokeStatic "core.clj" 3221]
  [clojure.core$eval invoke "core.clj" 3217]
  [clojure.main$repl$read_eval_print__9236$fn__9239 invoke "main.clj" 438]
  [clojure.main$repl$read_eval_print__9236 invoke "main.clj" 438]
  [clojure.main$repl$fn__9245 invoke "main.clj" 459]
  [clojure.main$repl invokeStatic "main.clj" 459]
  [clojure.main$repl_opt invokeStatic "main.clj" 523]
  [clojure.main$main invokeStatic "main.clj" 668]
  [clojure.main$main doInvoke "main.clj" 617]
  [clojure.lang.RestFn invoke "RestFn.java" 400]
  [clojure.lang.AFn applyToHelper "AFn.java" 152]
  [clojure.lang.RestFn applyTo "RestFn.java" 135]
  [clojure.lang.Var applyTo "Var.java" 707]
  [clojure.main main "main.java" 40]]}

Alex Miller (Clojure team)17:05:28

What version of Clojure CLI do you have installed?

Dar17:05:19

Yep, upgrading the clojure CLI fixed it. Thanks 🙂 (For reference, was previously on Clojure CLI version 1.10.3.986)

lvh20:05:59

Does anyone have any recommendations for a disk-persisted cache? I am calling a bunch of (expensive, metered) 3rd party API calls and I want to cache them efficiently. I am fine with this being local and on-disk (actually, that would be ideal from a latency perspective). I can reasonably write this with some combo of clojure.core.cache + hasch + nippy or whatever, but it just seems like something other people have written before and might be trickier to do than I think 🙂

lvh20:05:26

There’s https://github.com/shriphani/fort-knox which has been abandoned for a minute, but I’m sure mostly works fine

ericdallo23:05:09

I tested lots of disk cache libs, including sqlite, #datalevin, and what worked best for clojure-lsp's case was the simple https://github.com/cognitect/transit-clj which is what clj-kondo uses as well. it's fast and easy to use

lvh00:05:40

awesome, thank you! but just to make sure I understand: that library is just the serialization format, right? Meaning it’s a 1:1 replacement for nippy, but doesn’t solve any of the disk or cache parts?

ericdallo00:05:28

Hum, yes, but there are methods for read and write given a input/outputstream, so you can write to a file and read https://github.com/clojure-lsp/clojure-lsp/blob/master/lib/src/clojure_lsp/db.clj#L49-L74

Joshua Suskalo17:05:24

nippy is faster than transit I believe. There aren't any libraries that I am aware of that actively uses that to build an on-disk cache though. I would be interested in such a library though, it seems very useful.

ericdallo23:05:28

Is there a way to generate a class from a proxy with a specific name and not a random generated class name? similar to how proxy+ https://github.com/redplanetlabs/proxy-plus (I can't use it because of https://github.com/redplanetlabs/proxy-plus/issues/19 though)

ericdallo23:05:48

I need the full qualified name to point its name from a xml

ericdallo23:05:14

(I know about gen-class, but I'm trying to find a nicer way)

ericdallo23:05:41

AFAICS, the name is generated from proxy-name https://github.com/clojure/clojure/blob/master/src/clj/clojure/core_proxy.clj#L37, which generates something like:

FullSuperClassName$ff19283
I would like to generate as
MyClassName

p-himik06:05:36

I'd say that's not what proxy is for and you're better off using something else. If you don't want to use AOT then there's a number of solutions that let you write Java code (directly or via a Clojure-based DSL) and use it without AOT.