Is there a way to get prn and its ilk to print meta definitions? eg. how to get the following to include the meta data in its output?
> (prn-str '(def ^{:dynamic true} *foo* 10))
"(def *foo* 10)\n"
There’s a dynamic var for this. (apropos “meta”) should reveal it
user=> (binding [*print-meta* true] (prn (with-meta {:a 1} {:b 2})))
^{:b 2} {:a 1}
Thanks. I’m on mobile so didn’t know the exact var. also I think apropos and find-doc are criminally under discussed so like to mention them
(I didn't know about that until you mentioned it!)
And, yes, I used (apropos "meta")
to find it.
A queryable runtime is very close to a hard requirement for all future programming languages I use
Any standard way to run leiningen in the background yet? Or otherwise to watch clj and cljs builds in the same shell?
lein doesn't support backgrounding and I don't think it ever will, as a compromise you could try tmux for switching between sessions in one terminal window
@alexmiller @hiredman Getting closer to the weird offset issue with GraalVM: https://github.com/oracle/graal/issues/1613#issuecomment-850806194 Direct linking seems to affect it in that particular case.
The problematic function that trips up native-image with direct linked Clojure compilation is defined here: https://github.com/dm3/clojure.java-time/blob/351fb243359635f4d1939e8112c3046d5edb7af1/src/java_time/amount.clj#L73-L84 Perhaps this non-standard way is causing issues
Perhaps the eval
is called again during native image compilation yielding a different copies of those functions wheres with defmacro
you don't have this problem?
Per request of @borkdude I've tried to patch the library to use macro. Issue no longer exists: https://github.com/dm3/clojure.java-time/pull/72/commits/08a700a2583ada0908066dbc8d6684e3a032ce96
(require '[clojure.template])
(macroexpand '(clojure.template/do-template [] (def a b) x 1))
I guess the 💥 result is to be expected:
> values are automatically partitioned by the number of arguments in argv
(partition 0 [1])
will explode in just the same way.
Hey all, got a question - I am trying to flatten maps, so that map that looks like {:a {:b 2 :d 3}}
would become:
((:a :b 2)(:a :d 3))
hello, any idea how to fix the following error Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch proc file - > web: java -cp phs.jar clojure.main -m phs.system
Ok, I think I can work this out... something like that:
(defn flatten-data2 [m key]
(if (map? m)
(for [[k v] m] (flatten-data2 v (conj key k)))
(conj key m)))
That sounds like a #heroku question @spamails29?
yes @seancorfield
Sounds like your app is just taking too long to start up. How exactly are you building phs.jar
? Maybe AOT will make it start up faster…
thanks.updated the cli, build error resolved. heroku not launching the app. will try with aws
thanks for the help, looks like their was issue with the system file
On Heroku, you can increase boot time out to 180 seconds. Had to do it - too many issues with AOT that were way too hard to solve. YMMV of course.
Jason has gone to DM with me about it, but for Heroku details, I’m recommending he ask in #heroku (since I don’t use Heroku at all).
increased it to 180 same error
I would try profiling the start-up time and see if there's something suspicious going on apart from just the compilation.
same error with aot. added extra line to the existing edn file :depstar {:extra-deps {seancorfield/depstar {:mvn/version "1.0.94"}}}
since it is giving error while deploying
Adding an old version of depstar
is not the solution to your problem — the repo is already using the more recent version. What is the error you are seeing during deployment?
remote: Running: bin/build remote: Error building classpath. Specified aliases are undeclared: [:depstar]
bin/build file #!/usr/bin/env bash clojure -A:depstar -m hf.depstar.uberjar pingcrm.jar
I said to use clojure -X:uberjar
— that’s what the deps.edn
in that project is expecting.
Again, using the alias you added and just that command you added will not AOT the JAR file.
The command I suggested — and the alias that is already in the project will AOT the JAR file.
What’s the fun of using add-tap and tap>? Can someone give an example use case?
One use case is to replace println
in development. Instead of strings in the console, you get data and you can extend how tapped values are handled depending on the context
I use Reveal https://github.com/vlaaad/reveal/ as a tap>
“client” to display every tap>
’d value, either as a table, or in some other useful form. And as Adrian says, you can add tap>
calls wherever you want for debugging (and leave them in the code if you want — since they do “nothing” if there are no clients added). You can have multiple clients attached via add-tap
so you can have one client showing plain text output and another client showing graphs for vectors of numbers, for example. You can remove-tap
to take a client away once you’re done with it.
Tools like Cognitect’s REBL, Reveal (linked above), and Portal from @djblue are great additions to a REPL-based development workflow and all act as tap>
clients.
tried looks like heroku is rejecting it
remote: Exception in thread "main" java.io.FileNotFoundException: -X:uberjar (No such file or directory)
Any great writing or videos besides the documentation on how to really utilize IntelliJ + Cursive? I feel like I’m using 2% of its capabilities
The version of clojure
is too old on Heroku I guess?
You can tell it to use a more recent version according to this: https://devcenter.heroku.com/articles/clojure-support#setting-clojure-cli-version
You would need to use https://clojure.org/releases/tools#v1.10.1.697 at the very oldest but preferably whatever is the latest version Heroku supports.
If you don’t want to try overriding the CLI version per that link and you want to continue to try to use depstar
1.0.94, you should read the docs for that version so you can see how to AOT the JAR:
clojure -A:depstar -m hf.depstar.uberjar pingcrm.jar -C -m pingcrm.system
from https://github.com/seancorfield/depstar/tree/v1.0.94 (the older version of the readme)
That should produce a pingcrm.jar
that can be run with just java -jar
— although I suspect that old version might still require a pom.xml
file for building an uberjar (which isn’t needed with the newer version).There is a #cursive channel where the target audience might be more likely to know an answer to this.