Fork me on GitHub

Hello, asking this in attempts to get a Java library working in 100% clojure. Is there a way to do type hinting to specify something like List<Room> or java.util.List<>


Like I need to return a property as a typed Collection. Or are generics indeed being erased at runtime

Alex Miller (Clojure team)04:05:24

They are erased and there is no way to say that in Clojure


Alright! Thanks! Shall see if there's another way around it :thinking_face:


2 quick questions: I'm trying to decide whether to try figwheel-main or shadow-cljs, and I'm leaning toward shadow because supposedly if I want to do mobile down the road (after getting decent at web, or to make the web things I make also work on mobile) shadow is supposed to make that easy. 1. How much truth is there to that? 2. Why is Java a dependency of shadow-cljs?? (Is it because it handles not just ClojureScript, but also Clojure (for the server side of things)? ...but if it uses Node.js, doesn't that mean the server side would be in JS (CLJS)??)


hello, the way in which Shadow will make a lot of things easier than Figwheel is related to NPM deps, with Shadow you can add almost any NPM dependency directly, this don't work this way out of the box with Figwheel. About the Java dep, that's because Clojurescript is written in Clojure, which requires the JVM, both Shadow and Figwheel will require Java to compile


@U066U8JQJ that’s not true anymore, at least for React Native development (haven’t tried browser in a while) it does work out of the box as of last year


(talking about adding NPM dependencies)


I know CLJS add the bundle version option, that requires an external bundler like Webpack, did this changed on the Figwheel side?


ah, for React Native you are running in the Node environment, so require just works there, I guess that's why you can use figwheel + NPM there


but for browser, no luck on Figwheel afaik for npm deps


Also with React Native you must still use the metro bundler which is part of the “regular” RN workflow. If you’re doing browser dev, shadow-cljs would actually save you from using an extra bundler, so that’s nice there.


Must still use the metro bundler...for which? figwheel or shadow? Sorry, lost track there.


...but it essence if I want to do web for sure and mobile probably, then shadow-cljs sounds best (for a noob)?


@U066U8JQJ I did do the first part of the ClojureScript Quick Guide, and that ran. I had installed Java (started following the Clojure Getting Started page and then thought "no wait...don't need this since CLJS based on JS). I was wrong, obviously, but I never got to the point of setting the JAVA_HOME variable but the CLJS quick guide part I did still worked. Is it important to set it anyway?


(Not sure how to do that. Conflicting accounts on the web.)


the metro thing @raspasov said is something specific for React Native develop, unless you are doing that, no need to worry about it

👍 3

I never set JAVA_HOME too, if you OS can find java and compile without it, its fine


OK, great (about the variable). Even though I think it's right near the top of the Clojure Getting Started write-up! 😛


As far as React Native, well I'm 90% sure I'll want to do mobile soon enough. Just trying to pick the best option (shadow.cljs vs figwheel-main) knowing that in advance. Based on minimizing/easing whatever slew of extra tools I would have to learn at that point with for each option.


@factorhengineering I haven’t used shadow-cljs, but many people are happy with it so I assume it’s a pretty good option.


metro is specific to React Native, nothing to do with figwheel or shadow-cljs, yes


OK. Good to know. So no reason to think either option is better from your perspective?


That shadow easing mobile thing must have been a dumb rumour.


I'm still going to try it only because I tried it on my previous (failed/abandoned 😞 ) go-around months ago when I tried setting everything up for dev entirely from Windows (no WSL2).


I want to see if switching to WSL2 makes it any easier for me to get going with shadow-cljs. ...change one variable at a time, you know? 🧪


the maintainer of Shadow uses Windows, so its likely it works good there because he is on top of it 🙂 but I guess both should work fine


I used figwheel a long time ago, but since I switched to Shadow I never looked back, there are many small things that are nice about Shadow, but the biggest and easiest selling point is easy NPM integration on the browser, just that would be enough to keep on it for me


Whoa. That gives me a sinking feeling, actually. 😟 Not that I think it will be worse on Linux, but that now I have no reason to think I'll be any better at figuring it out. lol


Oh well...installing node now, then taking on shadow again...


but from a friend that was using windows before, its usually the hardest place for dev environments these days


the others usually have a few command lines you run and everything gets working


It is taking me days and days to put everything together, but I am taking super-detailed notes so if I ever have to set things up again I can not have to look things up in 300 different places again.


The actual steps, though, do seem maybe a bit shorter on the Linux side.


Wha-a-at. I remember node taking way-y-y longer to install on Windows. If it's really properly installed then this is a difference.


@U066U8JQJ @raspasov Thank you both. It almost seems like I might be actually writing code sometime somewhat soon. 🙂

😃 9

@seancorfield I guess you are referring to the yarn alternative to npm, which is listed in the shadow-cljs write-up as such (a viable alternative). I'm just about to start setting up shadow-cljs, and looking at that option now.


Trying to install shadow-cljs on WSL2 Ubuntu 20.04. Dependencies Java OpenJDK and Node.JS already installed. No mention (that I can find) on the shadow-cljs github page of how to actually install it, but found, on the command npm install -g shadow-cljs. Permission errors so tried sudo npm install -g shadow-cljs. Now I get npm ERR! cb() never called! npm ERR! This is an error with npm itself. Please report this error at: npm ERR! <> npm ERR! A complete log of this run can be found in: npm ERR! /root/.npm/_logs/2021-05-04T05_10_49_170Z-debug.log e


OK, well after checking the log file and seeing nothing helpful to me, I just tried running the exact same sudo installation command again, and this time it worked. Go figure!


I guess that’s the same guide at


I'm reading it now. I did a web search for the comment about installing it globally because I vaguely remembered that text from when I installed it on Windows months back.


doing everything sudo might make it look like its working, but it's defnitely not necessary


It seems really strange that the github page for shadow-cljs didn't mention how to install or point to the guide...not even in the 'Guides' section.


I am using shadow-cljs in wsl2 ubuntu and all i did was (apart from following the guide and asking help here a lot!) that I installed shadow-cljs and then always start with shadow-clj restart (start expects clean shutdown, which with wsl is not going to happen, restart ignores previous garbage), then I use the web interface after.


I did it without sudo first and it said (among other errors) npm WARN checkPermissions Missing write access to /usr/lib/node_modules and npm ERR! The operation was rejected by your operating system. npm ERR! It is likely you do not have the permissions to access this file as the current user npm ERR! npm ERR! If you believe this might be a permissions issue, please double-check the npm ERR! permissions of the file and its containing directories, or try running npm ERR! the command again as root/Administrator.


yeah, so did you check the permissions?


sudo is the only approach I know in that department. lol


that's not a check


ls -la usually works for me


and you use chown and chmod to change it


In that folder it mentioned?




I would say that keeping permissions in order is the absolute must


don't use linux or wsl if you are not doing it, that's just my opinion of course


All new to me.


to be clear, I check it automatically when I list directory content, and in my experience you only rarely need to actually change anything


but since everything constantly depends on them being in order, I don't see how one can avoid it. doing everything sudo is not just that now you are constantly in superuser mode, but also everything you start will be running like that too


I just tried navigating to the parent folder (/usr/lib/) and running ls -la. In the giant list of folders I see node_modules has drwxr-xr-x beside it.


could be some package you installed or you ran npm install in that folder earlier


I'm guessing that's the permissions?


1st ever attempt at installing it.


@ashnur come on, I mean I get where you’re coming from but he’s just trying to get his Clojure(Script) running 🙂 You can figure out how to do perfect Linux administration later…


Folder wouldn't have even existed before.


@raspasov please do not misrepresent what I am saying, nothing 'perfect' or 'linux administration'


Would really hope I wouldn't have to run an installation, have it break on a brand new folder's permissions, need me to fix the permissions somehow, and then run the installation again.


you don't have to fix them, just clear up and try again imho


Not sure what you mean by 'clear up' vs 'fix'.


no need for apologies, not about my ego, i don't want anyone to waste time, being able to see things that can be trivial to avoid if one is knowledgeable about them is a big help.

👌 3

@factorhengineering a fix would be to change the permissions of the files. but that requires intimate knowledge of everything you touch


a clear up is when you remove what you recently added and redo the things you did, but with more foresight (or hindsight :D)


presumably avoiding mistakes, because, and I apologize too for the assumption, but you do seem to be rushing into this whole thing 🙂


So in this case that would be...deleting the folder the installation complained about (and that it added itself) and trying again?


I could only confirm this if I knew better what you were doing.


I mean I guess that could work. Even the sudo version needed two tries (with no intervening actions by me in between). Ha ha.


All I'm doing is installing shadow-cljs with the commands above.


well, try the guide 🙂 that's what worked for me


Updated Windows, installed WSL2, got Ubuntu 20.04 from Windows Store, and just installed Emacs, Doom, Java, and a few of their stated dependencies and maybe a thing or two more. Pretty fresh OS.


Definitely. Going to the guide next. 🙂


By the way...


I recommend “yarn” but that’s just my experience (more reliable than “npm”)


Since you're in WSL2 Ubuntu, do you know how to change the font colour the CLI uses for folders and paths (and comments in vim). I'm dying trying to read the horrible dark blue text on a black background.


I tried this, which is supposed to change the actual "blue" and/or "dark blue", but it did not work:


I think maybe the reason it didn't work is because the WSL2 Ubuntu 20.04 CLI isn't 'tty' but maybe something else?


i know what I am doing, but I don't recommend. I start this and use gui, then start and everything looks exactly the same anywhere in kitty because I have the same config copied everywhere


I have my monitor way brighter than I want it at this time of night and I can still barely read it. I think I'm up for something drastic. HOW can this be the default???


no one uses the default


Ha ha ha. Helpless noobs do! It's a trap!!


btw, what cli you are using? the new Terminal app?


I do have vcxsrv set up. That was one of those 'other things' I installed.


Just whatever CLI you get thrown into when you launch Ubuntu 20.04.


OH YEAH...and another thing! I have the Terminal app, but it will not serve up WSL2 tabs. I'm almost certain it did right after I installed it, but it just doesn't feel like it anymore.


Solving that might solve the colour issue. With any luck the default CLI colours of WSL2 are sane in Terminal.


I'm looking at this kitty thing, but I'm sad if I can't just change a pre-existing Ubuntu config file. 😔


Welp. I just ran Terminal yet again on a whim, and today it does feel like saying Ubuntu-20.04 tabs can exist. All this flakiness... lol


The blue in Terminal is much better. Yay!


@factorhengineering As discussed in that thread the other day, the lack of WSL2 distros in Terminal is a known bug but it’s a timing bug: it is most likely to happen if you try to start Terminal either immediately after a reboot, while Windows is still “busy” starting things up, or if you’re system is under heavy load. As noted, I also encountered that bug but only if I try to start Terminal immediately after a reboot.


(and, yeah, I changed the default Terminal color scheme — can’t remember what I changed it to or whether it’s specific to the Insider builds I’m running, just FYI)


Do you happen to know the name of the default CLI you get if you just run (WSL2) Ubuntu 20.04 (straight from the Start menu, not in Terminal?


It's great that Terminal is finally working again (after multiple attempts throughout the day yesterday and the day before), but it would be nice to know if I can salvage the readability of the text in the CLI that reliably starts up. Ha ha.


@factorhengineering it’s just a bash shell (running in a regular window).


That solution I found was for tty (and did not work for me).


(apparently I’m using the Campbell color scheme in Terminal)


I'm OK with the colour scheme in the Terminal CLI...though the vim comments are the same terrible blue as the default CLI and the vim in that.


Code looks pretty nice in vim in Terminal with the Campbell color scheme selected, if that helps.


How do you change the colour scheme?


In the Settings menu item.


(in Terminal — I do not start Ubuntu directly from the Start Menu and I’ve no idea whether you can control the colors there)


A colour picker! Yay!


If you run Ubuntu 20.04 from the Start menu, what is that CLI called.


If I knew how to change the colour scheme in Terminal and that fixes the vim in Terminal, as you say, that would be great.


Greater still would be fixing the colours (really just 'blue' and possibly 'dark blue') in the default CLI that you get when you run from the start menu. I can't do a proper search for how, though, because I don't even know what it's called. 😞


@ashnur thanks for the help earlier. @seancorfield it's very late again so I'll have to revisit this tomorrow. Thanks to you too! If you or anyone here knows the name of the default WSL2 Ubuntu 20.04 CLI I'll read it tomorrow and scour the net for a way to add some red and green to that blue and make it readable in the CLI and in vim! 🙂


As I said above “it’s just a bash shell (running in a regular window)“.


Can someone help me out please. I have a function

(defn macro-expand-code [code macros]
  (map (partial macro-expand-line macros) code))
macro-expand-line returns either something like: A single string:
"mov :a 2"
Or a list of strings:
("mul :a :a" "mul  :b  :b" "add :a  :b")
So I end up with
'("mov :a 2" "mov :b 5" ("mul :a :a" "mul  :b  :b" "add :a  :b") ("add :a 10"))
But I dont want the inner nesting. I thought I could use mapcat rather than map , but then I end up with:
("m" "o" "v" " " ":" "a" " " "2" "m" "o" "v" " " ":" "b" " " "5" "mul :a :a" "mul  :b  :b" "add :a  :b" "add :a 10")
The single strings get expanded out to individual string per character...


Nevrmind, got it! This works

(defn macro-expand-code [code macros]
  (->> (map (partial macro-expand-line macros) code)

Darin Douglass10:05:41

If you wanted to use mapcat, you would need to make macro-expand-line always return a coll (which I'd recommend over using flatten).


Oh yeah! That works. I just changed macro-expand-line to

(defn macro-expand-line [macros line]
  (let [macro-call (is-macro-call? (keys macros) line)]
    (if macro-call
      (expand line (macros macro-call))
      (list line)))) ; made this a list.
And now this works:
(defn macro-expand-code [code macros]
  (mapcat (partial macro-expand-line macros) code))


I do vaguely remember reading something about avoid flatten if possible

Darin Douglass11:05:55

Ya I’m almost all situations you don’t need flatten. I think the biggest problem is it delazies everything you give it, where mapcat won’t. In your situation mapcat works better IMO because it necessitates getting rid of a bug/unexpected behavior caused macro-expand-line not returning the same type all the time.


I’m working more extensively with atoms for the first time. I’m using them as a sort of in-mem database for a prototype to hold a map. I had lots of functions deref ing atoms to get their state. I was doing this at different points in a pipeline but then I thought this is bad because the state could change between steps. Instead, I started doing (let [current-vals @db]) at the very top and then always working with this. Now, is current-vals in this example still blocking db , or did it make a copy (a snapshot if you will) and moved on so that other threads can continue reading and writing to db ?

Noah Bogart11:05:23

A copy. Deref ing an atom gets the persistent data structure contained inside

👍 3

(To be a bit pedantic for beginners) you don't get a copy because no copy is created. Deref ing an atom gives you whatever immutable value is referenced by the atom at that time.


hehe be pedant away @UHL84CDTP 😄 thanks! I

🤓 3

Is it possible to install Java libraries from using tools-deps ?


what do you mean under “install”?


for example, I would like to use this library in my Clojure project


normally you don’t need to “install” a library. The way to start using it is to describe that you need it in some form (normally dictated by you build tool)


If I add this line under the deps alias org.geotools/gt-swing {:mvn/version "25.0"}


I am getting this error Error building classpath. Could not find artifact org.geotools:gt-shapefile:jar:25.0 in central ()


so next step is to add :mvn/repos {"mvn" {:url ""}}


org.geotools:gt-shapefile this artifact is not a part of maven central, I think


but I get a 403


there is a Note


so you need to add that repository instead of


where did you see that note 🙂


I clicked on a version


super! thank you very much!!!

Endre Bakken Stovner15:05:17

Does anybody want to take a stab at guessing what might be due to?

Endre Bakken Stovner15:05:13

I'm trying to set up a Clojure development on my new M1 Mac. That is the error I get when I try to lein run the code I'm currently working on.


you have a user.clj file that is calling everclear.dag.core/file-to-map which is calling slurp on nil


% clj
Clojure 1.10.2
user=> (slurp nil)
Execution error (IllegalArgumentException) at user/eval1 (REPL:1).
Cannot open <nil> as a Reader.

Endre Bakken Stovner05:05:26

I gzipped the entire folder when moving the code to my new machine so I thought the error could not be due to missing files. Also, it said compile error so I thought it wasn't due to things happening when my code was running. So these lines mean it happened in my user.clj file? [user$eval42029 invokeStatic "form-init16520803458208972728.clj" 1] [user$eval42029 invoke "form-init16520803458208972728.clj" 1] Thanks, I actually learned a lot. It is also the first time I've seen a stack trace like that so I imagined it had something to do with my new Clojure version having failed to install properly or something.


So I'm having some trouble making an HTTP GET to the IMDB API due to an SSL problem. I have no idea how to fix this, can someone give me a hand?

(let [url ""]
    @(http/get url ))
{:opts {:method :get, :url ""},
 :error #error{:cause "Unrecognized record version (D)TLS-0.0 , plaintext connection?",
               :via [{:type,
                      :message "Unrecognized record version (D)TLS-0.0 , plaintext connection?",
                      :at [ bytesInCompletePacket "" 98]}],
               :trace [[ bytesInCompletePacket "" 98]
                       [ bytesInCompletePacket "" 64]
                       [ readRecord "" 605]
                       [ unwrap "" 499]
                       [ unwrap "" 475]
                       [ unwrap "" 634]
                       [org.httpkit.client.HttpsRequest doHandshake "" 98]
                       [org.httpkit.client.HttpClient doRead "" 193]
                       [org.httpkit.client.HttpClient run "" 494]
                       [java.lang.Thread run "" 830]]}}


@ggfpc12495 Are you using the SNI client?


(alter-var-root #'org.httpkit.client/*default-client* (fn [_] sni-client/default-client))
I have this line in my file, but the result is the same


Should it be somewhere in specific?


@ggfpc12495 Can you try it with bb maybe?

bb -e '(:body @(org.httpkit.client/get ""))'


that works for me


works for me too


that's weird


of figured it out


I had a java property that disabled SNI from a previous experiment, so the SNI client wasn't doing anything


I think this should be enabled by default, there is an issue for this


Hello team, it seems that it is not possible to convert string into json if there is a string in the string as shown below, is there any way to convert this string into json?

(json/read-str "{\"testing this \"hhh\" next\" :1,     \"b\" :2}")


(json/generate-string {:key "value contains a \"string\""}) check what valid JSON looks like if it contains a string

👍 3