nbb

Nick Cellino 2022-08-27T04:28:10.274539Z

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 Cellino 2022-08-27T04:28:48.130169Z

I’m using the instructions here: https://github.com/babashka/nbb/blob/main/doc/dependencies.md to install dependencies from clojars

Nick Cellino 2022-08-27T04:30:44.261539Z

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.alpha

Nick Cellino 2022-08-27T04:35:15.858639Z

I 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…

borkdude 2022-08-27T09:43:03.987719Z

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

Nick Cellino 2022-08-27T12:00:07.297499Z

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

borkdude 2022-08-27T12:05:26.838459Z

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 Cellino 2022-08-27T12:21:20.226819Z

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

ray 2022-08-27T13:01:48.563329Z

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?

ray 2022-08-27T13:03:39.227719Z

maybe this one is too old 🤣

clj-kondo v2020.12.12

ray 2022-08-27T13:13:14.495359Z

yeah, upgrading works

borkdude 2022-08-27T13:16:38.477779Z

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

ray 2022-09-12T08:28:33.008969Z

% 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"}}}

ray 2022-09-12T08:28:39.947479Z

is my field report

borkdude 2022-09-12T08:29:38.327899Z

Do you have a .clj-kondo directory?

borkdude 2022-09-12T08:30:08.924079Z

in the project

ray 2022-09-12T08:36:27.293169Z

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

ray 2022-09-12T08:36:32.976939Z

updated field report

🎉 1
ray 2022-09-12T08:36:52.857219Z

thanks @borkdude

❤️ 1
2022-08-27T13:23:01.397869Z

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?

borkdude 2022-08-27T13:24:56.566049Z

What more should the nbb init command do?

2022-08-27T13:54:18.783519Z

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

borkdude 2022-08-27T14:22:45.376979Z

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

2022-08-27T19:24:12.234819Z

Oh interesting, didn't realize npm init supported templates

2022-08-27T19:26:48.660229Z

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

borkdude 2022-08-27T13:16:50.680789Z

provided you already have .clj-kondo directory