Fork me on GitHub
#clojure
<
2022-06-19
>
craftybones04:06:07

@alexmiller - how does install-latest work on clojure tools? I ended up with v0.4.9 of deps-new . The latest version is 0.4.12 .

seancorfield05:06:50

I re-posted this in #tools-deps so it doesn't get lost here. I can confirm that I see the same behavior and I'm pretty puzzled by that since that was released back in January and there have been three releases since then.

craftybones07:06:24

Very likely there's a max-key that's comparing on string.

craftybones07:06:10

Does it look up tags? I am not sure.

Alex Miller (Clojure team)13:06:56

It looks at git tags output

Alex Miller (Clojure team)13:06:41

If you can post a jira or ask Clojure that would be most helpful

craftybones05:06:49

Thanks for tracking this. Is there any way in which I can take this up to fix it?

Alex Miller (Clojure team)07:06:49

new prerelease of Clojure CLI is now available - version 1.11.1.1145 if anyone wants to try it, also adds a no-arg variant to -X:deps install-latest to install the latest of all installed tools

Alex Miller (Clojure team)07:06:02

did some cleanup on the output too

Alex Miller (Clojure team)07:06:25

or actually, you can test it even more easily by just installing the latest version of the tools tool (not really any changes to the CLI itself):

clj -Ttools install-latest :tool tools

seancorfield21:06:49

I found another non-working case (and added a comment on the ask post)

seancorfield13:06:23

Thanks for fixing that too!

Ben Sless13:06:42

Coming back to a question I brought up in the past, I want to use java reflection to emit wrappers for all grpc methods of some service I want to emit direct method handles and to not have to allocate arrays on call In grpc these methods are called on the emitted stubs from service description. Do I need to use the method handles lookup on the specific emitted stubs or are their classes enough? What's the correct code path to get there?

practicalli-john20:06:46

I am trying to understand how best to use the "Improving Startup time" article at https://clojure.org/guides/dev_startup_time I understand the part about (re)loading the user namespace, as the binding expression temporarily sets *compile-files* to true and then requires the user namespace, compiling the user namespace and any libraries or code that the user namespace includes via its ns form I am not so clear on the strategy to compile the rest of the project. Assuming the practicalli.app.service is the main entry point into the project, requiring libraries and namespaces that account for all of the project. I would only need to add (compile 'practicalli.app.service) expression to my user namespace and pretty much everything in the project would be compiled. Is that correct? I assume I only need to explicitly complie a namespace that not required by another namespace I am calling with compile (or one of its requires)

hiredman20:06:05

I would not call compile explicitly like that

hiredman20:06:41

If you load user.clj with compile-files as true, anything user loads will get aot compiled

hiredman20:06:09

So replace the call to compile with a call to require

hiredman20:06:00

But in general the whole setup looks like a recipe for problems where things are double compiled

hiredman20:06:56

If you have to do it, it seems like it would be best to have that force reload line above the ns form, as high up as possible before any code is loaded so it only loads once

hiredman20:06:12

I don't think the article is very good

hiredman20:06:52

I suspect putting a force reload require of the current namespace, as a top level effect of loading the namespace would just loop

hiredman20:06:30

If compile-files is true (which the binding sets) ever but of code loaded is aot compiled

hiredman20:06:43

So if you assume the force reload of user doesn't loop, the second load of user, with reload all, would reload app.service whatever, and aot compile it

hiredman20:06:06

I suspect the intent with that snippet of code (with the binding) is to drop it in a repl, not in a file (where it would infinitely loop reloading itself)

hiredman20:06:08

compile and require both load and run the given code

hiredman20:06:44

So not being willing to require code when you are willing to call compile doesn't make much sense

hanDerPeder22:06:15

when exactly is “compile-time”? I thought I could do this

(ns my.main
  (:require [clojure.edn :as edn])
  (:gen-class))

(defmacro read-foo []
  (quote (edn/read-string (slurp "foo.edn"))))

(def foo (read-foo))

(defn -main [& args]
  (println foo))
build an uberjar from it and that namespace would include the data read from foo.edn. What actually happens is I get a FileNotFoundException on foo.edn Is what I`m trying to do possible or would I have to read and include it as part of the build?

Jan K23:06:56

Try (def foo #=(edn/read-string (slurp "foo.edn"))

hanDerPeder00:06:25

(ns my.main
  (:require [clojure.edn :as edn])
  (:gen-class))

(defmacro read-foo []
  `(def foo '~(edn/read-string (slurp "foo.edn")))

(read-foo)

(defn -main [& args]
  (println foo))
This seems to do what i want :thumbsup:

Jan K00:06:32

#=(...) evaluates the form at read-time but I guess it's not documented

hanDerPeder00:06:31

indeed. I see my issue is doing some stupid stuff with integrant. the file with the macro isn’t actually being compiled. thanks jan!

phronmophobic00:06:53

An alternative is:

(defmacro read-foo []
  (list 'quote (edn/read-string (slurp "foo.edn"))))

(def foo (read-foo))

👍 1
phronmophobic00:06:25

#=(...) is very discouraged. Fortunately, you don't need it here.

teodorlu12:06:39

if you want to defer the reading of that file, an option is using resources on the classpath. See example here: https://clojuredocs.org/clojure.java.io/resource Note - if you're using deps.edn , resources will not automatically be on the classpath, and you'll need something like this in your deps.edn:

{:paths ["src" "resources"]
 :deps {,,,}}

👍 1
didibus18:06:21

Resources is the way to go