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.
I’m using the instructions here: https://github.com/babashka/nbb/blob/main/doc/dependencies.md to install dependencies from clojars
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)
result:
➜ nbb-classpath-issue-repro git:(master) ✗ npx nbb script.cljs
Downloading dependencies...
Extracting dependencies...
Done.
----- Error --------------------------------------
Message: Could not find namespace: clojure.spec.alpha
Could not find namespace: clojure.spec.alphaI tried adding https://github.com/clojure/clojurescript 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…@nacellino Currently clojure.spec doesn't work with nbb. However, malli does work
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
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 🤣
clj-kondo v2020.12.12yeah, 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% 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/promesaupdated field report
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?
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
Oh interesting, didn't realize npm init supported templates
Anyway yeah I think a npm init nbb package would definitely work if it was named create-nbb
provided you already have .clj-kondo directory