Fork me on GitHub
#clojure
<
2020-03-11
>
dmarjenburgh08:03:13

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

dharrigan08:03:24

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

p-himik08:03:07

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.

dharrigan08:03:14

Installation on Linux may help šŸ™‚

spasov09:03:41

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

delaguardo13:03:51

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

delaguardo13:03:51

My patch to make linux-install cross-platform is here - https://clojure.atlassian.net/browse/TDEPS-36

šŸ‘ 8
orestis13:03:25

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 https://github.com/vlacs/saml20-clj of which the kirasystems one seems to be the most up-to-date ā€” but metabase also has a somewhat active fork.

jeroenvandijk13:03:23

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

mkvlr13:03:56

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

orestis15:03:23

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.

orestis15:03:57

Our very own @U07QKGF9P suggests in https://news.ycombinator.com/item?id=22496736 to ā€œoutsource that infrastructure to a vendorā€, mentioning Cognito, but Iā€™m not sure this is a solution for everyone.

orestis15:03:16

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 šŸ˜„

orestis15:03:06

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.

jeroenvandijk15:03:36

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

orestis15:03:19

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.

mpenet13:03:30

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

pinkfrog13:03:11

possible to stop repl from some busy function.

pinkfrog13:03:34

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

delaguardo14:03:07

you could configure the repl to not realize entire sequence by configuring https://clojuredocs.org/clojure.core/*print-length*

andy.fingerhut18:03:57

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.

andy.fingerhut18:03:48

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

sogaiu22:03:54

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: https://github.com/sogaiu/alc.start-repl

zalky15:03:03

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
zalky16:03:48

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: https://github.com/juxt/pack.alpha#onej Highlighting

$ clj -A:pack mach.pack.alpha.one-jar 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 https://clojure.org/guides/deps_and_cli#aot_compilation 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.

hiredman16:03:15

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

hiredman16:03:27

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

hiredman16:03:59

https://github.com/clojure/clojure-site/blob/22ae089533d3ee443dfbe1d0654b956036fd66e7/content/guides/running_a_clojure_program.adoc might be helpful, it doesn't deal with pack.alpha specifically but generally discusses the issues around running a clojure program

hiredman16:03:19

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

hiredman16:03:09

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

hiredman16:03:43

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

hiredman16:03:02

you might want to consider something with fewer bells and whistles like https://github.com/seancorfield/depstar

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?

hiredman16:03:26

more or less

hiredman16:03:37

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

Brian17:03:39

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

bfabry17:03:50

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

Alex Miller (Clojure team)17:03:49

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

borkdude17:03:20

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])
  (:gen-class))

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

bfabry17:03:31

pretty sure not at least on the class

bfabry17:03:38

you need to specify it in :methods

borkdude17:03:01

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

borkdude17:03:22

I'm asking because I keep getting:

src-java-native/borkdude/sci/SciNativeLib.java:18: error: cannot find symbol
        sci.impl.native_lib.evalString(expr);
but not for -main

borkdude17:03:38

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

borkdude18:03:29

Thanks, that worked.

borkdude19:03:14

guilty as charged šŸ˜‰

denis_krivosheev18:03:25

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

denis_krivosheev18:03:16

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

hiredman18:03:11

you can only use nil in place of reference types

hiredman18:03:22

int-array creates an array of primitive integers

denis_krivosheev18:03:38

Oh I see! Thank you!

denis_krivosheev18:03:54

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

bfabry18:03:54

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

hiredman18:03:59

what do you mean?

denis_krivosheev18:03:22

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

hiredman18:03:41

an int array on the jvm can only contain primitive integers

bfabry19:03:16

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

denis_krivosheev19:03:01

letā€™s say I want to write function with this semantic:

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

hiredman19:03:13

you don't need one

hiredman19:03:45

clojure boxes and unboxes as needed

hiredman19:03:57

but you cannot put a boxed integer in an int array

ghadi19:03:55

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

denis_krivosheev19:03:47

yes, looks like itā€™s the simpliest solution

hindol19:03:44

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

ghadi19:03:18

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

denis_krivosheev19:03:18

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

hiredman19:03:44

an integer array is not a generic datastructure

hiredman19:03:50

int-array creates an int[]

denis_krivosheev19:03:24

yes, I want to have Stack<T>

hiredman19:03:34

then you cannot use an int-array

hiredman19:03:43

use an object-array

andy.fingerhut19:03:47

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

andy.fingerhut19:03:54

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

hindol19:03:37

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

denis_krivosheev19:03:10

Oh great! thank you!

bfabry19:03:44

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).
9
user=> (aset my-longs 1 (Long. 9))
9

hindol19:03:27

What happens when you use aset-long?

bfabry19:03:13

error. it's an object array

hindol19:03:17

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

hindol19:03:45

Ah, typed the question without reading your answer.

hindol19:03:42

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

bfabry19:03:16

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

šŸ‘ 4
hindol19:03:11

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

bfabry19:03:44

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

joshkh21:03:10

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?

lukasz22:03:48

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

seancorfield22:03:59

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

šŸ‘ 4
grounded_sage23:03:20

How do I find the ns of a keyword?

noisesmith23:03:56

user=> (namespace :foo/bar)
"foo"

grounded_sage23:03:11

I should have known this haha

noisesmith23:03:33

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

noisesmith23:03:21

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

grounded_sage23:03:45

Haha. Interesting with apropos. So much to learn šŸ˜›

noisesmith23:03:41

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

grounded_sage23:03:51

@joshkh I used Hylia (https://hylia.website/) but found the Netlify CMS to be buggy. So I just do it with markdown.

joshkh23:03:45

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

grounded_sage23:03:35

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

joshkh23:03:41

i'll check it out. thanks for the recommendation. šŸ™‚

colinkahn23:03:49

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?

bfabry23:03:49

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

colinkahn23:03:27

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

colinkahn23:03:06

in this case though Iā€™m more interested in interacting with it via the command line

bfabry23:03:09

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

bfabry23:03:15

tubular is a cli socket repl client https://github.com/mfikes/tubular

andy.fingerhut23:03:24

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

noisesmith23:03:01

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

andy.fingerhut23:03:04

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

noisesmith23:03:23

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

noisesmith23:03:32

which is all I need much of the time

noisesmith23:03:59

there's also a vim plugin for socket repl

colinkahn23:03:25

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

noisesmith23:03:00

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

noisesmith23:03:16

https://github.com/jebberjeb/clojure-socketrepl.nvim the vim socket repl plugin is only for neovim I guess

colinkahn23:03:38

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

colinkahn23:03:43

or will it never give me output?

noisesmith23:03:47

on stdout, yes

colinkahn23:03:55

hmmm, alright Iā€™ll give it another shot

bfabry23:03:02

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

bfabry23:03:51

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

colinkahn23:03:41

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

noisesmith23:03:43

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

noisesmith23:03:01

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

colinkahn23:03:29

when using an nrepl I use fireplace#platform().Query(ā€¦) a bunch, I was hoping for a socket repl cli equivalent of that I suppose šŸ˜„

noisesmith23:03:13

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(?)

noisesmith23:03:49

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

colinkahn23:03:21

I think nc might work for what Iā€™m trying. Thanks for the advice!

didibus05:03:41

You can use unravel

dominicm08:03:11

Unravel is beautiful