Fork me on GitHub
Nick Cellino04:08:10

hi all. is it currently feasible to use clojure.spec.alpha with nbb? I’ve done a couple things to try and make this work but keep coming up short.

Nick Cellino04:08:48

I’m using the instructions here: to install dependencies from clojars

Nick Cellino04:08:44

my nbb.edn:

{:deps {integrant/integrant {:mvn/version "0.8.0"}}}
script I am trying to run:
(ns script
  (:require [deps]
            [integrant.core :as ig]))

(println ig/ref)
➜  nbb-classpath-issue-repro git:(master) ✗ npx nbb script.cljs
Downloading dependencies...
Extracting dependencies...
----- Error --------------------------------------
Message:  Could not find namespace: clojure.spec.alpha
Could not find namespace: clojure.spec.alpha

Nick Cellino04:08:15

I tried adding as a dependency in my nbb.edn, and then changing

[clojure.spec.alpha :as s]
in nbb-deps/integrant/core.cljc to be:
[cljs.spec.alpha :as s]
but i get the same error. I’m sure there’s something pretty basic i’m missing here…


@U03RD9KKKRS Currently clojure.spec doesn't work with nbb. However, malli does work

Nick Cellino12:08:07

Gotcha. I guess I should've elaborated a little - the actual thing I was trying to accomplish is using Integrant with nbb. Is that a no-go since it makes use of clojure.spec? I assume I can just remove the spec parts from the integrant source code but I didn't know if there was an easier way


Ah right. Well, currently there's probably not an easier way. Babashka runs with a fork of clojure.spec.alpha (minor changes). Perhaps we can have a similar fork for nbb

Nick Cellino12:08:20

I see. Yes, I read your post about the babashka/clojure.spec situation. Well okay, I'll have to play around with it a bit today and see what I can come up with


I'm not an expert at how to configure clj-kondo for nbb so I copied the .clj-kondo folder from nbb into my repo folder. It still does not seem to grok the promesa config. Is there a better way to configure it or do I have to clear caches or something?


maybe this one is too old :rolling_on_the_floor_laughing:

clj-kondo v2020.12.12


yeah, upgrading works


if you include promesa in deps.edn and then run this:

$ clj-kondo --lint $(clojure -Spath) --dependencies --parallel --copy-configs
it should copy a config for promesa that works

eccentric J13:08:01

The steps that have been working for me: 1. Make sure clj-kondo is installed 2. Add the same version of promesa nbb uses to deps.edn 3. Open a file in an editor that makes use of clojure-lsp or clj-kondo It should generate the .clj-kondo/* config files which includes the promesa types. Would you be open to an nbb init cmd kind of like package.json that populates some of those things like the deps.edn?


What more should the nbb init command do?

eccentric J13:08:18

Could generate an nbb.edn file as well, saw some commits earlier for that feature. Thinking near equivalent to npm init


An alternative would maybe be a npm init template or a feature in #babashka-neil to add a clj-kondo config for a library

eccentric J19:08:12

Oh interesting, didn't realize npm init supported templates

eccentric J19:08:48

Anyway yeah I think a npm init nbb package would definitely work if it was named create-nbb


% clj-kondo --lint $(clojure -Spath) --dependencies --parallel --copy-configs
No configs copied.
% cat deps.edn                                                               
; This file is only here to assist with editor integration, specifically Cursive on IntelliJ IDEA

; nbb DOES NOT USE THIS FILE - deps are built in (like promesa) or added via npm => package.json

{:paths ["src" "test"]
 :deps  {org.clojure/clojurescript {:mvn/version "1.11.51"}
         funcool/promesa           {:mvn/version "8.0.446"}
         reagent/reagent           {:mvn/version "1.1.0"}}}


is my field report


Do you have a .clj-kondo directory?


in the project


% mkdir .clj-kondo
% clj-kondo --lint $(clojure -Spath) --dependencies --parallel --copy-configs
Configs copied:
- .clj-kondo/funcool/promesa


updated field report

🎉 1

provided you already have .clj-kondo directory