Fork me on GitHub

Is there a standalone way to install clojure deps/cli without homebrew?


You can download the latest via wget or curl, extract out the archive.


Maybe the Linux sh script would also just work on Mac. No idea though - it might be a good idea to read through the script before you actually run it with sudo.


Installation on Linux may help 🙂


You might have trouble unarchiving the archive though, as the OS sees it as something different than a plain old archive. Just unarchive it however you can and follow the instructions after that.

Alex Miller (Clojure team)13:03:22

the linux script should also work on mac


No, it won’t install and sed will complain about given arguments. On mac coreutils and gnu-sed packages are required to run linux-install script or to use original install and sed arguments should be changed like that: for the install -D should be replaced with -d for the sed -e -> -E


My patch to make linux-install cross-platform is here -

👍 8

People who have used one of the many saml20-clj libraries to add SAML support to your projects, which one did you use? There’s 23 forks of of which the kirasystems one seems to be the most up-to-date — but metabase also has a somewhat active fork.


I’ve used org.opensaml/opensaml-saml-impl {:mvn/version "3.3.0"} before, but I don’t know why exactly. I think I copied it from another project. It was only to parse the saml response


I’m also interested in this, gave up last time I wanted to choose a library


So opensaml 2 was EOL’ed back in 2016, all the clojure wrappers are based on that. Opensaml 3 is mildly incompatible so it’s probably not a small feat to migrate.


Our very own @U07QKGF9P suggests in to “outsource that infrastructure to a vendor”, mentioning Cognito, but I’m not sure this is a solution for everyone.


From the same thread: “My best advice for safely using SAML is: use a library that everyone uses and that is well tested. This is a place where I might stand up a separate service in a different language to get a popular SAML library rather than the shady one that is most convenient for your preferred platform.” — but stopping short from actually endorsing a language or library 😄


My research so far brings up OpenSAML, CAS, PAC4J, OneLogin — all Java-based libraries that deal with this, no Clojure wrappers that I could find, all require quite a lot of effort to build something, and it’s still not clear if you open yourself up to security issues if you try to use them any way.


How would you like to use Saml? Can you use AWS Cognito for instance?


We have all our login/signup/SAML infrastructure already setup. But, the overhead of keeping it up-to-date regarding security, plus the constant stream of requests like MFA and other modern measures makes me want to look elsewhere. Cognito is a possibility since we are on AWS already.


anyone has a config they are happy with for zprint? preferably something not too disruptive and that matches cljfmt, emacs indentation?


possible to stop repl from some busy function.


for example, if I accidentally typed: (range 10000000000). Hitting C-c to stop the repl does no good.


you could configure the repl to not realize entire sequence by configuring*print-length*


The behavior of different ways of starting the REPL is different here, I am pretty sure. If I start a REPL from macOS Terminal using clj and type an expression like that, and press C-c, it quits the whole JVM, so also quits the REPL.


Clojure itself does not (and I think can not) control how different REPL environments handle this.


on a side note, if you want to get back in when things are stuck (e.g. to see some value), you can try this:


Hi all, wondering if anyone has answer why sometimes derive throws an error if child already has an ancestor, and sometimes it doesn't:

(-> (make-hierarchy)
    (derive :a :b)
    (derive :a :b)
=> fine

(-> (make-hierarchy)
    (derive :a :b)
    (derive :b :c)
    (derive :a :c))
=> error 
Is there some ambiguity involving transitive relationships that this is trying to protect against?

Alex Miller (Clojure team)16:03:12

I don't actually know the answer to your question off the top of my head

Alex Miller (Clojure team)16:03:02

I'm assuming the first case is basically treated as a no op but the second triggers a check for multiple inheritance paths

👍 4

Just checked out the source, and the first case is indeed a no-op. The error condition does not seem like it would guard against ambiguities like diamond inheritance, but this was still very helpful for me. Thanks!

Drew Verlee16:03:49

Trying to understand the functionality here: Highlighting

$ clj -A:pack output.jar
$ java -jar output.jar
I imagine this outputs a jar and then we run the jar using "java -jar output.jar". so the options list:
-m, --main STRING        clojure.main  Override the default main of clojure.main. You MUST use AOT compilation with this.
Which then i assume mean the default is clojure.main. So were going to run clojure.main and not necessarily execute anything in the specific jar? So then if you do want to specify a default main you have to use AOT. Finding a link on AOT Those docs might assume some background i dont have. Is it suggesting that you have to call gen-class on every function? I'm not sure in general how to full fill the contract purposed by the option above of using AOT compliation.


clojure.main being the default means you can use clojure.main to launch your clojure code without aot compiling


java -jar output.jar -m your.main.namespace

hiredman16:03:59 might be helpful, it doesn't deal with pack.alpha specifically but generally discusses the issues around running a clojure program


it does look like pack.alpha specifically does some extra stuff so it can be given a clojure namespace to start without aot compiling it


ah, it depends on which uberjar method you use, the Capsule one says aot is not required, the OneJAR one says it is

Drew Verlee16:03:19

i interperated it to say that if you didn't specify a main namespace then it used clojure.main. Then when you run the java command you need to pass that namespace like you said here: java -jar output.jar -m your.main.namespace


correct, but if you look at the docs for Capsule it says you don't need a gen-class in the main namespace (which is equivalent to saying it doesn't need to be aot compiled) while as you noted, the OneJAR options say the main namespace must be aot compiled


you might want to consider something with fewer bells and whistles like

Drew Verlee16:03:50

yea, maybe. The role of clojure.main here is that it reads your clojure files at run time right? The alternative is that you compile the clojure ahead of time so that the above step isn't necessary?


more or less


but clojure.main isn't special, it is just a class file, and the jvm understands class files not clojure, so you can generate your own class file in an number of different ways, use that instead, but then also have that load clojure code


Is there a way to suppress warnings? Specifically WARNING: name already refers to: #'clojure.core/name in namespace: r.manufacturer, being replaced by: #'r.manufacturer/name . I understand the warning but in my case it's not a problem and I don't want to see the warning


you should exclude clojure.core/name from being referred in that namespace

Alex Miller (Clojure team)17:03:49

^^ (ns ... (:refer-clojure :exclude [name]))


if I use gen-class like this, will the method evalString be available from Java?

(ns sci.impl.native-lib
  (:require [sci.core :as sci])

(defn -evalString [s]
  (sci/eval-string s))


pretty sure not at least on the class


you need to specify it in :methods


why is this different from -main?

Alex Miller (Clojure team)17:03:13

I think it will actually - using in ns takes a bunch of defaults


I'm asking because I keep getting:

src-java-native/borkdude/sci/ error: cannot find symbol
but not for -main


evalString vs main I mean

Alex Miller (Clojure team)17:03:16

Why don’t you just use javap to look at what the class has?

Alex Miller (Clojure team)18:03:47

I will change my answer to no based on reading the gen-class docstring :)

Alex Miller (Clojure team)18:03:09

main is special and defaults to true if used in ns

Alex Miller (Clojure team)18:03:35

You need to annotate the method with ^:static


Thanks, that worked.


guilty as charged 😉


Hello everyone. How can I set Java array item to nil? I tried (aset (int-array 3) 0 nil) but it throws an error > Execution error (IllegalArgumentException) at chapter1.stack.extended-stack/eval17432 (REPL:59). > No matching method aset found taking 3 args


Also is there a way to initialize an array with nils, not with some monodic values (like 0 for int for example)


you can only use nil in place of reference types


int-array creates an array of primitive integers


Oh I see! Thank you!


Is there a way to do auto-wrapping for primitive types in Clojure?


auto-boxing happens for most things... maybe not so much arrays


what do you mean?


just trying to implement stack with extandable array. To create an array I need to use some type, but to avoid loitering I need to assoc unused elements to nil… Which make a restriction to which types can be used. I’d like to do autoboxing here, like if you create stack with Integer/TYPE as a type, use Integer actually


an int array on the jvm can only contain primitive integers


you can create an array of type Integer, which will allow nulls


let’s say I want to write function with this semantic:

(box Integer) ;; Integer
(box Integer/TYPE) ;; still Integer


you don't need one


clojure boxes and unboxes as needed


but you cannot put a boxed integer in an int array


if you are still playing with datastructure implementation, I would highly recommend just ignoring primitives and getting it running the easy/dumb/slow way with ordinary boxed vectors


yes, looks like it’s the simpliest solution


Specially if you want your data structure to be persistent, it makes sense to base it off existing persistent things.


lots to explore, then you can optimize and replace with primitives


Yes, but if I want to have a generick stack, if I use primitive types with java they will be autoboxed… just want to reproduce the same behaviour


an integer array is not a generic datastructure


int-array creates an int[]


yes, I want to have Stack<T>


then you cannot use an int-array


use an object-array


Create a stack of Object , then put only T into it.


That's what Java does. (if I understand correctly)


That is correct. The compiler also ensures you only ever put T. But at runtime, it's all objects.


Oh great! thank you!


not that I would ever run into it, but this kinda surprises me

user=> (aset my-longs 1 9)
Reflection warning, NO_SOURCE_PATH:1:1 - call to static method aset on clojure.lang.RT can't be resolved (argument types: [Ljava.lang.Object;, int, long).
user=> (aset my-longs 1 (Long. 9))


What happens when you use aset-long?


error. it's an object array


And is this long array or Object array with type hint Long?


Ah, typed the question without reading your answer.


This must be a special situation then. It does not autobox when setting to Java array.


yeah that's what I meant was surprising 🙂 well actually it does autobox, but it has to reflect first

👍 4

I am on my phone but I am curious now. Did you peek at the source?


briefly but both autoboxing and reflection mechanisms are unfamiliar territory for me


this isn't really a Clojure specific question, but for those of you out there who write Clojure related blog posts, what's your platform of choice? is there a good alternative to Medium?


I gave up hosting my own and just pay for Squarespace :-)


@joshkh I use Octopress for generation and host on GitHub under my org name. With my original domain pointing to it.

👍 4

How do I find the ns of a keyword?


user=> (namespace :foo/bar)


I should have known this haha


if this were linked from (doc keyword) I would have given more of an RTFM answer, but honestly there's no straightforward way to ask clojure itself about that particular task


(apropos "namespace") would have helped if you'd thought to try it though :D


Haha. Interesting with apropos. So much to learn 😛


similarly, there's find-doc for searching not only function names but also doc strings by regex


@joshkh I used Hylia ( but found the Netlify CMS to be buggy. So I just do it with markdown.


cool, markdown seems the way to go. and i like @U04V70XH6’s github pages solution. sounds like a good solution to use both.


Netlify itself is great tbh. I would always use Netlify.. haven’t seen anything better. I just mean their open source CMS which Hylia comes pre-configured with. You could easily remove it


i'll check it out. thanks for the recommendation. 🙂


besides telnet are there other ways to interact with a socket repl? Is it possible to send code to a socket repl and get the response back via some command line tool?


most clojure repl clients can connect to a socket repl if that's what you mean?


I was under the impression that most connected to nREPL, I use vim-fireplace which I believe only works with nREPLs


in this case though I’m more interested in interacting with it via the command line


I shouldn't have said most I guess. cursive does which is what I'm used to


tubular is a cli socket repl client


Atom + Chlorine can connect to Socket REPL, as can Emacs + inf-clojure. Probably something in VScode + Calva, too, but I haven't checked.


I use nc, but that is basically a more scriptable telnet


If you really want to invoke a command from the terminal and interact with a socket REPL, those are not in that category.


in vim I can do :w !nc localhost 5555 and that sends my current buffer to my socket repl


which is all I need much of the time


there's also a vim plugin for socket repl


@U051SS2EU I did see`nc` when I was searching, I tried running it and it gave me nothing though


nc host port - point it at the host and port of your repl

noisesmith23:03:16 the vim socket repl plugin is only for neovim I guess


if I did echo '(+ 1 1)' | nc host port would that give me 2?


or will it never give me output?


on stdout, yes


hmmm, alright I’ll give it another shot


this seems pretty nice ~/C/clj-scratch $ clj -A:tubular -m tubular.core -p 5555 16:39:40


if you want to do anything interactive and happen to be limited to cli AND can't do ssh port forwarding. rather specific 😅


@U051SS2EU got it, thanks, bit weird to get the user prompt I suppose


@U0CLLU3QT so as you can see from the screenshot it doesn't just return 2 - it also prints prompts, but 2 is in there


yeah - it's really oriented to be an interactive tool


when using an nrepl I use fireplace#platform().Query(…) a bunch, I was hoping for a socket repl cli equivalent of that I suppose 😄


it's possible to run something other than clojure.core.server/repl - might be straightforward to make a minimal server function that's identical except it doesn't offer a prompt(?)


sounds like the jebberjeb clojure-socketrepl :EvalForm command might be closer to what you want if you are OK with using neovim


I think nc might work for what I’m trying. Thanks for the advice!


You can use unravel


Unravel is beautiful