Fork me on GitHub
#nbb
<
2022-08-27
>
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: https://github.com/babashka/nbb/blob/main/doc/dependencies.md 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)
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 Cellino04:08:15

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…

borkdude09:08:03

@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

borkdude12:08:26

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

genRaiy13:08:48

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?

genRaiy13:08:39

maybe this one is too old :rolling_on_the_floor_laughing:

clj-kondo v2020.12.12

genRaiy13:08:14

yeah, upgrading works

borkdude13:08:38

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

jaide13: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?

borkdude13:08:56

What more should the nbb init command do?

jaide13:08:18

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

borkdude14:08:45

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

jaide19:08:12

Oh interesting, didn't realize npm init supported templates

jaide19:08:48

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

genRaiy08:09:33

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

genRaiy08:09:39

is my field report

borkdude08:09:38

Do you have a .clj-kondo directory?

borkdude08:09:08

in the project

genRaiy08:09:27

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

genRaiy08:09:32

updated field report

🎉 1
borkdude13:08:50

provided you already have .clj-kondo directory