Fork me on GitHub
#beginners
<
2019-05-22
>
zlrth04:05:40

dumb sente/ring question: the chsk/handshake messaged received on the server from the client has a :uid i asked for. i’d like :uid to be in my handler map for all my POSTS, but it’s not there. have i misconfigured something? or do i not understand something about sente and ring?

Preston Thornton16:05:22

Hello, I am newly working with the official docker image of "clojure" on docker hub. I have selected the following tag, "https://github.com/Quantisan/docker-clojure/blob/f4257cfa677af38c2f8a9cd0455747c9bee835ca/target/openjdk-8/debian/tools-deps/Dockerfile"

Preston Thornton16:05:24

which is maintained by Kirill Chernyshov. I have successfully built the image, but when I try to run the image with a "-it", I am getting the following error,

delaguardo17:05:41

I’m no longer maintainer of this image. And we had long discussion with original author of image about necessity to have rlwrap in alpine-based version here - https://github.com/Quantisan/docker-clojure/issues/55 .

delaguardo17:05:25

So far I’m using this Dockerfile as a base image for our projects:

FROM openjdk:13-alpine
LABEL maintainer="Kirill Chernyshov <[email protected]>"

ENV CLOJURE_VERSION=1.10.0.442

WORKDIR /tmp

RUN apk add --update --no-cache bash curl

RUN wget  \
    && chmod +x linux-install-$CLOJURE_VERSION.sh \
    && ./linux-install-$CLOJURE_VERSION.sh

RUN clojure -e "(clojure-version)"

CMD ["clojure"]

delaguardo17:05:27

This is the smallest image that I manage to build

hiredman16:05:45

official in the sense that it is blessed by docker, not official in the sense that is blessed by clojure core I think

Preston Thornton16:05:01

Yes, that is a fair assumption.

ghadi16:05:33

which error are you getting?

ghadi16:05:12

(no need to build the image yourself, you can pull it and run)

Preston Thornton16:05:19

$ docker run -it 29e7f11ab2ae Please install rlwrap for command editing or use "clojure" instead. $

ghadi16:05:40

It's unclear what you have in 29e7f11ab2ae

ghadi16:05:15

docker run -it clojure:openjdk-8-tools-deps

Preston Thornton16:05:42

Okay, one moment . .

Preston Thornton16:05:45

OOOOh! I am a little new, sorry.

Preston Thornton16:05:37

@ghadi One last question. Is there truly an issue with installing "rlwrap" within this image? As seen below:

noisesmith17:05:46

yeah, the alpine package for rlwrap got hosed at some point, I know my team found a workaround but I forget how it worked

noisesmith17:05:55

RUN apk del bash readline && \
  apk add bash readline --no-cache --repository  && \
    apk add rlwrap --no-cache --repository 

ghadi17:05:14

@pthornton apk doesn't exist in that docker image I linked -- it's a debian image

ghadi17:05:30

there's a separate alpine image, but we haven't been talking about that one

noisesmith17:05:15

@ghadi oh- I overfit my problem onto his

ghadi17:05:20

unless you're using those containers as command line repls, I kind of dispute having rlwrap in them

ghadi17:05:48

if you're using containers I'd connect remotely to them over socket or nREPL

ghadi17:05:48

cmdline rlwrap is a pretty anemic interface, but sufficient for getting your feet wet with clojure

eskemojoe00718:05:08

Quick dumb qustion, I have this line that works great (assoc-in @game [:players 0 :hand] []) It replaces the existing hand with an empty vector. But when I try to do it with a swap! it fails: (swap! game assoc-in [:players 0 :hand] []) saying wrong number of args to assoc-in.

eskemojoe00718:05:25

My guess is that its due some sort of apply

eskemojoe00718:05:43

Sorry. game is an atom.

dpsutton18:05:56

(def game (atom {:players []}))
(swap! game assoc-in [:plays 0 :hand] [])
@game

dpsutton18:05:58

works for me?

eskemojoe00718:05:07

Hmmm...Simplified ones work here too.

eskemojoe00718:05:15

But the more complex game doesn't.

eskemojoe00718:05:54

Hmmm...it seems as though my watch function doesn't like that.

eskemojoe00718:05:12

Hah...Turns out it I had a bug in a watch function, that also had a assoc-in and the error was from there. My bad all.

Marco Nicolodi18:05:47

Hey guys, I've started with clojure a few weeks ago, and you helped me alot with it. I wrote an getting started article, to contribute to this community and spread the world. There's a shotout to Clojurians there 😄 https://medium.com/qualyteam-engineering/getting-started-with-clojure-acaa45d1039a

👍 4
rich 4
Preston Thornton19:05:32

@ghadi Oh, you are right! I am begin moving across different images. Thanks for the clarity. You rock!

bigos21:05:31

Where can I find a tutorial that explains in simple terms adding a clojars library to my project and incorporating it into existing code?

noisesmith21:05:57

your dependency management tool should cover that in the very beginning of the documentation, it's covered in the top of the README for leiningen, boot, and deps-edn

seancorfield21:05:01

@ruby.object The Clojure tools that read dependencies and build the classpath in order to run code (`clj`, lein, boot) all look for libraries on both Maven Central and Clojars, so they just need to know the "coordinates", e.g., seancorfield/next.jdbc for the group/artifact ID of the library and then a version number as a string.

seancorfield21:05:44

Pretty much all the books (and I would expect most of the Clojure tutorials online) should have an example of adding dependencies to a project. Mostly lein-based I expect.

seancorfield21:05:54

What books/tutorials have you looked at so far?

bigos21:05:11

for example, how I would use this library ?

seancorfield21:05:09

Under "Usage" it shows the coordinate that you'd use with Leiningen or Boot.

seancorfield21:05:20

[pegasus "0.7.0"]

bigos21:05:34

It makes no sense to me 😞

seancorfield21:05:50

You have an existing project? Is it using Leiningen or Boot, or the clj / deps.edn tools?

bigos21:05:13

I have added it to dependencies in project.clj, but proceeding further is a mystery to me

seancorfield21:05:55

OK, so once it is in your dependencies in project.clj, the next time you start a REPL in that directory or run your project code, the library will be automatically fetched and cached locally.

seancorfield21:05:14

Then you can require it in your code, as the example shows.

bigos21:05:48

I have tried Cloje over a year ago but everything looks somewhat different

seancorfield21:05:54

The namespace is pegasus.core, not pegasus.

seancorfield21:05:05

Per the Usage example

(ns pegasus.foo
  (:require [pegasus.core :refer [crawl]]
            [pegasus.dsl :refer :all])
  (:import ( StringReader)))

bigos21:05:43

thats what I do not understand

bigos21:05:57

and a bit more to that

seancorfield21:05:34

The library coordinates are pegasus/pegasus and a version number "0.7.0". The library contains a number of namespaces, pegasus.core, pegasus.dsl, etc.

bigos21:05:45

why this is wrong? why the library author has written a different example?

dpsutton21:05:22

(ns easy-crawler.core
  (:require [pegasus.core :refer [crawl]]
            [pegasus.dsl :refer :all])
  (:import ( StringReader)))

dpsutton21:05:56

your namespace is easy-crawler.core their example is the (ns pegasus.foo form in the #Usage section

dpsutton21:05:37

you declare your namespace easy-crawler.core and then the other namespaces that you will depend on.

dpsutton21:05:16

(and a stylistic note :refer :all is considered very bad form these days.)

bigos21:05:28

@dpsutton I tried your example and I get this error

dpsutton21:05:10

can you paste what you tried?

seancorfield21:05:20

I suspect CIDER is hiding the real problem here.

seancorfield21:05:23

user=> (require 'pegasus.core)
Syntax error macroexpanding clojure.core/refer-clojure at (async.clj:9:1).
:as - failed: #{:exclude} at: [:exclude :op :quoted-spec :spec]
:as - failed: #{:only} at: [:only :op :quoted-spec :spec]
:as - failed: #{:rename} at: [:rename :op :quoted-spec :spec]
(quote :as) - failed: #{:exclude} at: [:exclude :op :spec]
(quote :as) - failed: #{:only} at: [:only :op :spec]
(quote :as) - failed: #{:rename} at: [:rename :op :spec]

seancorfield21:05:59

Pegasus is relying on outdated versions of libraries that are not compatible with Clojure 1.9/1.10 with the stricter syntax for ns.

bigos21:05:44

arrrrrrrgh!!! 3 days wasted i am crying and laughing at the same time

bigos21:05:55

:rolling_on_the_floor_laughing:

bigos21:05:30

how do I filter out old non strict libraries from my seach?

seancorfield21:05:59

Add the following dependency: [org.clojure/core.async "0.4.490"]

bigos21:05:00

do I need to downgrade clojure in my :dependencies to fix it?

seancorfield21:05:52

(! 677)-> clj -Sdeps '{:deps {pegasus {:mvn/version "0.7.0"} org.clojure/core.async {:mvn/version "RELEASE"}}}'
Clojure 1.10.0
user=> (require 'pegasus.core)
WARNING: pos-int? already refers to: #'clojure.core/pos-int? in namespace: taoensso.encore, being replaced by: #'taoensso.encore/pos-int?
WARNING: bytes? already refers to: #'clojure.core/bytes? in namespace: taoensso.encore, being replaced by: #'taoensso.encore/bytes?
WARNING: Inst already refers to: #'clojure.core/Inst in namespace: schema.core, being replaced by: #'schema.core/Inst
nil
user=> 
So Pegasus 0.7.0 should work with the latest core.async (which is 0.4.490 -- I was just being lazy with RELEASE)

seancorfield21:05:39

You may need to explicitly add up-to-date versions of other things Pegasus relies on, but that should get you moving forward.

bigos21:05:08

could it be simpler just to give up on pegasus and try other library that works with contemporary clojure?

seancorfield21:05:32

Maybe. I see a number of open, unanswered issues in the Pegasus repo that are three years old which suggests the maintainer stopped working on it -- so it hasn't been updated to the latest versions of Clojure or other libraries.

bigos21:05:51

is the fact that pegasus is tagged in red on github page a warning sign

seancorfield21:05:58

That builds on CircleCI are failing? Yes. It looks like it is still using CircleCI's 1.0 config and that's outdated (builds seem to be failing due to HTTPS protocol issues).

bigos21:05:07

does clojars attempt to indicate which libraries are not working and should be deprecated?

seancorfield21:05:17

Clojars is "just" a repository -- it doesn't know much about its contents.

seancorfield21:05:43

And old versions never get removed -- because if someone is depending on them it would break their builds.

seancorfield21:05:31

(That's true of any repository for any language)

bigos21:05:10

Elm has moved packages that no longer work with new version to a separate repository

bigos21:05:45

or I am wrong, i mean a separate web directory

seancorfield21:05:53

Yes, Elm has a very deeply coupled ecosystem and can use checkers to see if library versions are compatible or not.

bigos21:05:50

I will try https://github.com/owainlewis/athena and disappear for a while, thank you for your help

seancorfield21:05:53

Clojure builds on the Java/JVM world so it uses the "same" system as all the other JVM languages in terms of libraries and versions...

seancorfield21:05:10

Feel free to ask any questions here, to avoid days of frustration!

bigos21:05:36

I will remember the lesson!

seancorfield21:05:53

Athena hasn't been updated since Clojure 1.6 so you may run into problems with that too.

seancorfield21:05:11

And it uses an even older version of core.async than Pegasus.

bigos21:05:31

ok for learning to add libraries i need to find something else that will work

seancorfield21:05:49

That said, at least athena.core loads

(! 680)-> clj -Sdeps '{:deps {athena {:mvn/version "RELEASE"}}}'
Clojure 1.10.0
user=> (require 'athena.core)
WARNING: boolean? already refers to: #'clojure.core/boolean? in namespace: clojure.tools.analyzer.utils, being replaced by: #'clojure.tools.analyzer.utils/boolean?
WARNING: boolean? already refers to: #'clojure.core/boolean? in namespace: clojure.tools.analyzer, being replaced by: #'clojure.tools.analyzer.utils/boolean?
WARNING: bounded-count already refers to: #'clojure.core/bounded-count in namespace: clojure.core.async, being replaced by: #'clojure.core.async/bounded-count
nil
user=> 

seancorfield21:05:57

(version 1.0.6)

noisesmith21:05:14

It's OK - I just spent 45 minutes running cucumber smoke tests against an app that had gone down and wondering why my tests were failing when they passed just before...

chrisulloa21:05:01

non-deterministic tests?

noisesmith22:05:37

they are smoke tests, so they rely on the remote service being up

noisesmith22:05:55

instead of checking if the service was still running, I dug deep into why the tests might be flaky

seancorfield22:05:35

And it's even more ancient than athena 🙂 But that just goes to show that some very old, unmaintained libraries are just fine to use!

bigos22:05:27

because of its simplicity