Fork me on GitHub

With deps.edn, is there a way to alias a module for another rather than just its version?


I have a case where I'd like to alias react-native with react-native-web for seamless interop between native and web for a single codebase


Looks like I might be able to do with via shadow-cljs


This might work since I'd only want to change what's target in the browser. Please shout out if anybody has any other ideas. Thanks.


@mruzekw yeah I do this with shadow-cljs, one sec


use the :js-options :resolve field in your build config, here鈥檚 how mine looks

:js-options {:extensions [".web.js" ".js" ".json"]
                :resolve    {"react-native" {:target :npm
                                             :require "react-native-web"}}}


@mruzekw deps.edn doesn't define anything related to the module or its name. All it does is pull down dependencies on your machine and start processes with the right paths and options setup


Do you mean with ClojureScript?


From a cljsjs dependency?


Hi All, I am learning Clojure(script). I just recorded screen while trying to build login form using Clojure Script, Reagent, next.jdbc, Postgresql. The video is two hour long, so you may want to speed up while viewing. I am newbie, so please pardon my Clojure(script). Thank You.

馃挴 4
馃帀 4
馃憖 4
馃憤 4

How to investigate and fix the error of executing clj for REPL? Just installed on Ubuntu 18.04 Clojure CLI, following the instruction below: > To install with the Linux script installer: > Ensure that the following dependencies are installed: bash, curl, rlwrap, and Java. > Use the linux-install script to download and run the install, which will create /usr/local/bin/clj, /usr/local/bin/clojure, and /usr/local/lib/clojure: curl -O聽 chmod +x sudo ./ when executing

for REPL, I got the following error trace:
[yubrshen@yubrshen-Alienware-15-R3 athens-sandbox (master)]$ clj
Error building classpath. Failed to read artifact descriptor for org.clojure:clojure:jar:1.10.1
org.eclipse.aether.resolution.ArtifactDescriptorException: Failed to read artifact descriptor for org.clojure:clojure:jar:1.10.1
	at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom(
	at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.readArtifactDescriptor(
	at org.eclipse.aether.internal.impl.DefaultRepositorySystem.readArtifactDescriptor(
	at clojure.lang.MultiFn.invoke(
	at java.base/
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(
	at java.base/java.util.concurrent.ThreadPoolExecutor$
	at java.base/
Caused by: org.eclipse.aether.resolution.ArtifactResolutionException: Could not transfer artifact org.clojure:clojure:pom:1.10.1 from/to central (): /home/yubrshen/.m2/repository/org/clojure/clojure/1.10.1/clojure-1.10.1.pom.part.lock (No such file or directory)
I Googled, haven't found any mention of the error. I suspect that my Java version or installation might have a problem:
[yubrshen@yubrshen-Alienware-15-R3 athens-sandbox (master)]$ java --version
java 11.0.2 2019-01-15 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.2+9-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.2+9-LTS, mixed mode)
Really appreciate if you could give me a pointer to investigate. Thanks in advance!


@yubrshen Based on those errors, I'd say the most likely issues are either file system permissions or network/proxy access.


@yubrshen - ls -l /home/yubrshen/.m2/repository/org/clojure/clojure/ ?


Hi! I'm have done a little elisp before (but only a little), and am now exploring the nice features and syntax of Clojure. Function argument destructuring is a fine feature, that saves a lot of tedious typing. Here is an example function, which first destructures the keymap argument into two variables must and opt . It then goes on with an assertion to check that must is not nil.

(defn foo [{:keys [must opt]}]
  {:pre  [(not (nil? must))]}
I wonder if it is possible to make the not-nil-assertion right in the destructuring, to eliminate the need for two separate lines/steps? A way to mark must as an obligatory argument so to speak, in the destructuring? I know of the :or feature, but that is not the same as an assertion which fires an exception when the condition is unmet.


there is no feature that does assertions inside destructure - closest you get is :or to set defaults

Endre Bakken Stovner10:05:52

I want a function:

(f "abc") ; ["abc"]
(f ["abc"]) ; ["abc"]
If the argument is a string, put it in a vector, if it is a vector, do nothing. I know an (if (string? v) [v] v) will do this, just wondering if there is a different way.

Kris C12:05:28

I don't see anything wrong here, but I'm no expert...


(flatten [["abc"]]) -> ["abc"] (flatten ["abc"]) -> ["abc"]


so (fn [x] (flatten [x]))

Endre Bakken Stovner06:05:18

Thanks! But you need (fn [x] (flatten (vector [x]))) in case x is just "abc".


~ % clj
Clojure 1.10.1
user=> (defn foo [x] (flatten [x]))
user=> (foo "abc")
user=> (foo ["abc"])


[x] is shorthand for (vector x)


if you must have a vector as output instead of a seq you can do:


(vec (flatten [x]))

Endre Bakken Stovner10:05:19

I guess there is something about checking the type that feels slightly wrong.


Is it safe to assume that all namespaces that start with an uppercase are probably coming from Java ? e.g. in Math/pow or Integer/parseInt

馃憤 4

To be clear, Math and Integer are not namespaces, they are classes. Clojure also uses upper case when defining classes (eg. defprotocol, deftype, defrecord, definterface, gen-class)

馃憤 4

namespaces are different, they don't exist in java


(the clojure namespace construct has a representation in java, but it's not something a non-clojure java class would be likely to care about, use, or resepect)


Thanks @U051SS2EU Yeah, those are classes :face_palm: but also I thought namespaces were the same as packages in Java. :thinking_face:


It's much weirder / messier than that. If a namespace creates a class, the heirarchy of the ns is translated into the class' package


but the ns itself is a data structure, and clojure keeps a mapping of all ns symbols to their implementations, and each ns contains mappings describing what's visible to them and what's exported from them


okay, see. Thanks a lot simple_smile

Manuel Ceron13:05:30

Hello Clojurians! If I have a list of maps '({} {} {}) and I want to add something to the first map. What would be the idiomatic way of doing it? I'm currently doing this:

=> (def mylist '({} {} {}))
=> (conj (rest mylist) (assoc (first mylist) :key "value"))
({:key "value"} {} {})

Manuel Ceron13:05:49

But I'm wondering if there is a better way

Alex Miller (Clojure team)13:05:25

if the first map is special, then maybe it should really be a map of maps and you should use update-in or assoc-in

Alex Miller (Clojure team)13:05:49

it's generally weird to have such a specific need is what I'm saying


I might do something like (let [[h & other] mylist] (conj other (assoc h :key "value"))), which looks a little weird on its own for such a simple example, but it does reflect a pattern I use regularly.

Manuel Ceron13:05:25

Thanks for the suggestions, I like the idea of restructuring, but also might refactor things to use nested maps 馃槃

Sam G14:05:05

Hello! I am new to web dev and am working on a website using Reitit for the routing. I followed but I am having some troubles getting routing to work as I hoped. I define my routes like this:

(ns website.routes 
 (:require [reitit.frontend :as rf]
           [reitit.frontend.easy :as rfe]
           [re-frame.core :as re-frame]
           [ :as e]))

(def routes
    {:name :home}]
     {:name :posts}]
     {:name :blank}]]
     {:name :projects}]]])

(defn on-navigate [new-match]
  (when new-match
    (re-frame/dispatch [::e/navigated new-match])))

(def router

(defn init-routes! []
   {:use-fragment false}))
If I navigate to localhost/ , localhost/posts or localhost/projects it works great. The problem comes when I want to have nested routes such as localhost/posts/post-one, navigating to that page does not work. Actually, navigating to localhost/posts/ with the trailing / does not work either. I have two questions: 1. How can I get nested routes to work as expected? I would like to be able to navigate to localhost/posts/post-one or localhost/posts/post-one/ and have it correctly route the user. 2. When I upload the website to github pages, how can I get it to respect the hosts address? For example, I have my website on and if a user navigates to the posts page it will not recognize the route unless it is which, as you can imagine, breaks when you try to reload or link to the page since that page doesnt actually exist.


usually you'd want to write your routes starting with a slash so like

(def routes
    {:name :home}]
     {:name :posts}]
     {:name :blank}]]
     {:name :projects}]]])
and to make it more flexible with the trailing slash, you can use the trailing slash handler

Sam G14:05:53

If I redefine my routes like this they stop working all-together. localhost/posts and localhost/posts/ both redirect to a blank page now. I notice I am using reitit.frontend and reitit.frontend.easy to define my router; should I be using reitit.ring like they are in the example?


ah sorry i can't help with frontend code. you can try asking in #reitit


@seancorfield @phoenixai2082 thanks for pointing to the probable root cause of the problem. It is related to the fact that /home/yubrschen/.m2 does not exist in my setup! The moral of my lesson: I should have read the trace to find any hint related to my own environment, that is, this path, and investigate the state of this path. This is part of the learning.

馃帀 8