This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-05-23
Channels
- # announcements (12)
- # beginners (225)
- # calva (7)
- # cider (45)
- # clj-kondo (1)
- # cljdoc (1)
- # cljsrn (3)
- # clojure (112)
- # clojure-dev (45)
- # clojure-europe (6)
- # clojure-finland (2)
- # clojure-india (1)
- # clojure-nl (27)
- # clojure-spec (37)
- # clojure-uk (171)
- # clojurescript (39)
- # core-async (9)
- # cursive (22)
- # datascript (8)
- # datomic (50)
- # emacs (12)
- # figwheel-main (17)
- # fulcro (42)
- # garden (2)
- # hoplon (27)
- # jobs (4)
- # kaocha (8)
- # klipse (2)
- # luminus (2)
- # off-topic (9)
- # perun (33)
- # planck (2)
- # re-frame (9)
- # reagent (48)
- # reitit (5)
- # remote-jobs (1)
- # rum (2)
- # shadow-cljs (23)
- # slack-help (3)
- # spacemacs (18)
- # sql (7)
- # tools-deps (24)
- # unrepl (9)
- # vim (30)
I'm trying to run it, but it's crashing immediately with Call to clojure.core/fn did not conform to spec.
I haven't changed a line of code yet.
@bolivier Sounds like you have an outdated version of some library in your stack.
compojure-api
is widely used and works well. Can you share your project.clj
if you're using Leiningen?
How to import relative path file in clojure
(defn read-file [fname]
(io/resource fname)
(with-open [rdr (io/reader fname)]
(into [] (line-seq rdr))))
(defproject invyte "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:dependencies [[org.clojure/clojure "1.8.0"]
[metosin/compojure-api "1.1.11"]]
:ring {:handler invyte.handler/app}
:uberjar-name "server.jar"
:profiles {:dev {:dependencies [[javax.servlet/javax.servlet-api "3.1.0"]
[cheshire "5.5.0"]
[ring/ring-mock "0.3.0"]]
:plugins [[lein-ring "0.12.0"]]}})
not sure what's pulling that in - there are probably 60+ transitive deps from that project
adding [org.clojure/core.unify "0.5.7"] could potentially workaround it, depends how much you're interested in figuring out the real why vs moving forward right now
(I'm referencing https://archive.clojure.org/design-wiki/display/design/Errors%2Bfound%2Bwith%2Bcore%2Bspecs.html for errors found with spec btw)
the real why is, I'm sure, interesting, but I'm pretty new and would probably be better off just moving forward
I wish the beginner docs didn't tell people to use lein-ring
but instead taught people how to start Jetty directly in their app, so they could just lein run
instead...
I don't see core.unify
coming in from any of those deps @bolivier -- what do you have in ~/.lein/profiles.clj
? I suspect that's more likely to be your problem.
(there are certainly plenty of version conflicts in the deps you have in project.clj
which is a problem in itself -- but it's not causing that error)
(as an aside, you will also probably find the error experience better with lein ring / lein run when using Clojure 1.10.1-RC1, to be actually released in the next week or two)
@bolivier I updated your project.clj
to use Clojure 1.10.1 and couldn't repro that error message -- so I'm fairly sure it's in your ~/.lein/profiles.clj
instead.
@seancorfield I don't have a ~/.lein/profiles.clj, and when I updated to 1.10.1, I get what looks like the same error still
That's weird. I can't repro that here. I don't even see core.unify
pulled in from those dependencies...
Something in your deps is pulling in leinjacker
and that's where the problem is -- it's pulling in an old version of core.unify
.
If you add [org.clojure/core.unify "0.5.7"]
to your project.clj
I think you might get past this.
(but, frankly, at this point I think I'd recommend looking at clj
/`deps.edn` instead of Leiningen so that you're working with something simpler)
I just checked and leinjacker
is not involved in any of those dependencies -- you must have a profiles.clj
file pulling in additional dependencies @bolivier
At this point, I have absolutely no idea. The errors you're reporting can't happen based on what you've told us.
The only way those errors can be produced is from a .lein/profiles.clj
file in your home directory.
I would suggest creating a very basic new project and seeing if you can get it running, and then adding dependencies one at a time until it fails.
I deleted ~/.m2
, figuring some of the java libs might be stored there, and it's definitely fetching leinjacker
again
The error you're reporting cannot be produced from the project file you provided.
The fix would be removing the dependencies that are bringing in the problematic libraries.
I created a project like this
[email protected]:~/clojure/brandon$ cat project.clj
(defproject invyte "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:dependencies [[org.clojure/clojure "1.10.1-beta1"]
[metosin/compojure-api "1.1.11"]]
:ring {:handler invyte.handler/app}
:uberjar-name "server.jar"
:profiles {:dev {:dependencies [[javax.servlet/javax.servlet-api "3.1.0"]
[cheshire "5.5.0"]
[ring/ring-mock "0.3.0"]]
:plugins [[lein-ring "0.12.0"]]}})
[email protected]:~/clojure/brandon$
and that runs a REPL just fine.If I run lein ring server
I get this error
Retrieving ring/ring-jetty-adapter/1.6.1/ring-jetty-adapter-1.6.1.jar from clojars
2019-05-22 22:25:16.562:INFO::main: Logging initialized @2584ms
Syntax error (FileNotFoundException) compiling at (/tmp/form-init4402686125591950306.clj:1:73).
Could not locate invyte/handler__init.class, invyte/handler.clj or invyte/handler.cljc on classpath.
Full report at: /tmp/clojure-6013848232846396032.edn
Subprocess failed
I can run the repl (in a new project with that project.clj) but I cannot run ring server
Right, I can run a REPL but I cannot run lein ring server
(and I wouldn't recommend doing that anyway)
{:user {:plugins [[cider/cider-nrepl β0.16.0β]]
:dependencies [[org.clojure/tools.nrepl β0.2.7"]]}}
For example, tools.nrepl
is at 0.2.13 and cider/cider-nrepl
is at 0.21.0 so you should at least update those and try again @bolivier
(and you probably shouldn't have cider
in there at all -- CIDER tries to inject the right version when it starts up anyway)
Hi, I'm a front end developer and recently fallen in love with clojure, Is there any suggestion and recommendation for someone who just want to start.
Clojure for the Brave and True
is probably the default recommendation, as something you can follow online
Clojure for the Brave and True is awesome but it is an entire book on Clojure though, and not without its own roadblocks. If you are just trying to get your feet wet it may be too much and end up scaring you. Don't let that happen! Try it, but if you meet a blockade, there are other resources, both paid and free, so just ask us again, maybe giving more details of what you are trying to achieve. Welcome! π
Thanks, I'm trying to up and running with clojure. I don't know which editor and which tools are popular in the community. I'm using vscode these day happily for front end web development
I believe most people use Emacs, IntelliJ with Cursive or Atom at this point in time. There are people using all the other editors as well. Just one tip: don't try to learn an editor while learning the language, or even to "fine tune" your editor too much. Get syntax highlighting working and use a terminal REPL until the limitations of this setup show up. Learning/working on both things at the same time can make it a rough and unpleasant experience. If you are fine with VSCode, stick with it until you get the basics of the language and the love in your heart grows stronger, and then you you will be better equipped to deviate from the learning path and work on your tools. π
https://medium.com/@jacekschae/slick-clojure-editor-setup-with-atom-a3c1b528b722
http://spacemacs.org/ is an Emacs starter kit where you can enable a Clojure "layer" that is very solid.
https://github.com/hlissner/doom-emacs is another Emacs starter kit with a very solid Clojure config.
and also which resources do u recommend for learning clojure, as you said clojure for the Brave and True maybe not a good choice
Well, those other two books are also regarded as great introductions. The one thing that worked for me was https://purelyfunctional.tv though π It's paid but he offers regional pricing to make it affordable. If you prefer videos, http://PF.TV is excellent. If you prefer books, those 3 will keep you pretty busy.
Since you come from JS land like I did, here are some interesting articles that I happen to have at hand.
JavaScript to ClojureScript reference: https://kanaka.github.io/clojurescript/web/synonym.html
I generally recommend either quick clojure
or mastering clojure
if you don't mind buying the books.
hello, i want to use the https://github.com/daviferreira/react-sanfona to build my nav, and i write the test code
i read the readme, and see that the title can be object, itβs that i can define my own component and show it in the title?
is it possible to make the http-kit client
return a channel with the result for async calls instead of a promise? I looked through the docs and I couldn't find anything.
Hi , I want to integrate google and FB sign in in my project .... please suggest me some decent libraries for that
Do you remember when I ordered the Purely Functional yearly subscription using my corporation hideous purchasing system? I managed to do it and they approved the order! Yihaa! This is the first course I'm going to watch this evening after my corporate hours: https://purelyfunctional.tv/courses/repl-driven-development-in-clojure/ I'll tell you my first impressions when I have watched the training video.
I just chatted to my line manager today: "Where is my next cool cloud project in which I can create cool infra using Terraform and do some big data processing using Clojure and Spark?"
I'm really burning to use my new Clojure skills to do some great system in some of the mainstream clouds using Terraform and using Clojure to implement the application logic.
BTW. Since the corporation order process wasn't a never ending story after all, I'm considering to order a couple of other good training sites for my corporate life and for Clojure development in the cloud (AWS, Azure, GCP). Any suggestions? For training my next cloud certification (GCP) I considered https://acloud.guru/ which is highly recommended by some of my corporate colleagues. Any comments?
My line manager told me to do a GCP certification - I thought that as part of my studies I could try to build a simple Dataproc system (GCP Hadoop managed service), use some Google published example big data and do some processing using Clojure Spark library, e.g. Flambo (https://github.com/sorenmacbeth/flambo).
BTW. Are there experiences how different Spark is regarding which library you use (Java, Scala, Python or Clojure)?
in my experience Scala is the best API to use β it has the most external libraries, its inclination toward immutability meshes well with Spark's execution model, and will overall have a much nicer development experience for those accustomed to a functional style.
I've never tried using Clojure for Spark, mostly because it's not supported by Databricks and I can't justify the DevOps overhead for a toy project that uses Clojure to call the Spark API, so I can't really compare it to Scala.
I have what could be a very stupid question β¦ but I just wrote what I think is βHello Worldβ in Clojure but there are an insane amount of directories & documents in my βproject.β β I have always heard that Clojure cuts down on the amount of code and makes things simpler β therefore I am worried I did something wrong?
I recommend to delete that project and e.g. download this one: https://github.com/puredanger/demo-deps
I think that's your problem - IDEs can be very opinionated about project layout, especially when coming from the Java world where this absurd duplication of namespaces is considered "best practice."
you've ended up with a batteries included bells and whistles template, like checking all the boxes in Visual Studio for an http://ASP.NET project
you could just start with a src/hello.clj, and a deps.edn file that is just {}
and that's enough
Can anyone please recommend any up to date Youtube / Udemy / Coursera / Lynda / or Pluralsight videos? β
Are you interested in learning Clojure the language or rather how to setup and work efficiently with Clojure tooling/editors?
Anyway, I think the best collection of videos, especially for beginners, is https://purelyfunctional.tv/
There's some useful stuff on https://lambdaisland.com/ too but sadly author seems to be busy with other things rather than adding more stuff consistently
and although I haven't watched this one it could be useful too: Clojure videos by Brian Will: https://www.youtube.com/watch?v=9A9qsaZZefw&list=PLAC43CFB134E85266
I am coming from Python so I am very familiar w/ Pycharm & Intellij and would love to stick w/ those editors.
amac:tmp alex$ mkdir hello
amac:tmp alex$ cd hello
amac:hello alex$ echo "{}" > deps.edn
amac:hello alex$ mkdir src
amac:hello alex$ echo "(ns hello)" > src/hello.clj
amac:hello alex$ clj
Clojure 1.10.0
user=> (require 'hello)
nil
If you have some issues with how to configure Cursive with deps.edn or something like that - chat here - we help you.
And if you buy a commercial Cursive license and have any issues related to Cursive - he responds very quickly to your emails and provides excellent support. I have used the support only once and it was amazingly fast and solved my issue right away. Used support only once since Cursive is very stable and intuitive.
Many corporate employees have subscriptions in Pluralsight (https://app.pluralsight.com). There are just a couple of Clojure courses (pretty old). A hint for Clojure gurus - why not create some learning material in Pluralsight (and possibly make some money).
I'm struggling to create a test that effectively tests atom
watch functions. I have to create a new atom each time and use swap!
in order to fire the function. Is there a better way?
@david.folkner Seems reasonable. Though remember your watch function is just a normal function, so you can test it independently of actually attaching (add-watch ...)
it to a atom.
If you are swap!
'ing on the ref
that add-watch
calls your watcher function with, then that can get kind of complicated. I would consider if there is a way to do what you need without that pattern?
There is probably a different way to do it. I did run into an infinite loop at first. I'm making a simple go-fish game. Watch looks for 0 cards in the deck or a players hand, then determines the game is over.
(defn game-over-watch
"Watches game state to determine when game is over.
Looks for empty deck or player hand. If game is not complete
it will swap the state to change it to complete."
[_ watched _ new-state]
(when (and (or (zero? (-> new-state :deck count))
(some #(zero? (-> % :hand count)) (:players new-state)))
(not= "complete" (:status new-state)))
(swap! watched assoc-in [:status] "complete")))
(defn mark-when-game-is-over
"Marks the state as complete when the game is over"
[state]
(when (and (or (zero? (-> state :deck count))
(some #(zero? (-> % :hand count)) (:players state))))
(assoc-in state [:status] "complete")))
(comp mark-when-game-is-over whatever-function-you-are-currently-passing-to-swap!)
Trying to stay within the rails of your idea, but maybe just compose your mark-when-game-is-over
to the function you pass to swap!
Hmmm...that could work. I have lots of other functions, so I'd have to call that a lot. I could macro it up though. That could be good practice.
Sure, I mean, it is a bit crazy, but you could also make your own swap! with something like (defn completionist-swap! [atm fx & args] (apply swap! atm (comp mark-when-game-is-over fx) args))
Yeah. The game could end mid-turn. I was thinking of using the state to drive everything. So it changes and drives all behavior, but this is just a simple learning app.
I'm trying to "require" reagent.core in a bare bones clojurescript program but getting a compile error: Caused by: clojure.lang.ExceptionInfo: No such namespace: reagent.core, could not locate reagent/core.cljs, reagent/core.cljc, or JavaScript source providing "reagent.core" in file /repos/gitnc/clojurescript_test2/src/demo/static_website.cljs {:tag :cljs/analysis-error} . What do I need to do to make "reagent.core" locatable?
@davecompton7 have you added the reagent library to your projects dependencies, and restarted the ClojureScript build process?
my starting point was this guide : https://betweentwoparens.com/deoploy-clojurescript-to-github-pages
I found this on their clojars page: https://clojars.org/reagent which was linked to on their github: https://github.com/reagent-project/reagent
Does anyone know if I can provide a seed to generate values using spec?
For example I can run: (-> int? s/gen g/generate)
, which generates a random integer. But Iβd like to generate an integer based on a seed (so I can reproduce it)
clojure.spec.test.alpha uses test.check under the hood, which accepts a :seed
keyword arg to check and quick-check
But not to actually generate values for other purposes, at least thatβs what it looks like to me
it tells you what seed it was using when it failed, so you can use that seed to reproduce the failure
but it's already randomizing its starting state, so I don't know when you'd need that
Ahh [org.clojure/test.check "0.10.0-alpha4"]
seems to have a generate function that accepts a seed, 0.9.0
didnβt accept one
I'm getting going with web development with clojure and luminus. I have things running in dev locally in my repl. How do I inspect the requests as they come through? I currently put println
statements in the functions I care about.
@david.folkner println
debugging is a perfectly reasonable approach. Are you looking for a way to print all requests? You could write simple middleware for that (there may even be such a thing in a library out there somewhere).
(defn print-mw [handler]
(fn [req]
(println "request:" req)
(let [resp (handler req)]
(println "response:" resp)
resp)))
That's a middleware function that would print all requests and responses.Gotcha. that's perfect. Thanks. All, would be a bit much, just wanted to inspect data and states...`pprint` it is!
I'm trying to use the "-w" option to get a recompile to happen every time my source file changes but it does not seem to be working.
here's the command line that I've tried: rm -rf demo-clojurescript-gh-pages/; clj -m cljs.main -d "demo-clojurescript-gh-pages/out" -c demo.static-website -w demo
from cljs.main --help output : -w, --watch paths Continuously build, only effective with the --compile main option. Specifies a system- dependent path-separated list of directories to watch.
https://github.com/clojure/clojurescript/blob/9a8196ebfe4265feda88a06de84affb9df469012/src/main/clojure/cljs/cli.clj#L625-L640 looks like it stops processing args when -c is encountered