leiningen 2024-01-18

I am struggling with installing https://cljdoc.org/d/lambdaisland/kaocha/1.87.1366/doc/2-installing and https://github.com/weavejester/environ in the same build. I am following the directions but it seems my Kaocha installation is being ignored, what am I doing wrong?

(defproject server "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url ""
  :license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"
            :url ""}
  :dependencies [[org.clojure/clojure "1.11.1"]
                 [com.github.seancorfield/honeysql "2.5.1103"]
                 [environ "1.2.0"]
                 [clj-http "3.12.3"]
                 [clj-time "0.15.2"]
                 [cheshire "5.12.0"]
                 [org.clojure/tools.reader "1.3.7"]
                 [net.clojars.wkok/openai-clojure "0.14.0"]
                 [io.pinecone/pinecone-client "0.7.2"]
                 [ring/ring-core "1.11.0-alpha1"]
                 [ring/ring-jetty-adapter "1.8.2"]
                 [compojure "1.7.0"]
                 [ring-cors "0.1.13"]
                 [ring-json-response "0.2.0"]
                 [com.taoensso/timbre "6.3.1"]]
  :main ^:skip-aot server.core
  :plugins [[lein-environ "1.2.0"]]
  :target-path "target/%s"
  :aliases {"kaocha" ["run" "-m" "kaocha.runner"]}
  :profiles {:uberjar {:aot :all
                       :jvm-opts ["-Dclojure.compiler.direct-linking=true"]}
             :dev [:project/dev :profiles/dev]
             :project/dev {:dependencies [[lambdaisland/kaocha "1.87.1366"]]}})

Those are different files used by different, largely incompatible, tooling

Am I? following is instructions for environ (dark) and Kaocha (light), am I misreading that they're both talking about Leiningen/project.clj?

Sorry, it has been a long time since I've used lein now, and just saw the alias key and thought that didn't belong

@nnnsadeh how are you trying to run the tests? What command?

lein test works, I am trying to run lein kaocha

You need to specify the :profile/dev profile

Hmm, no :dev supposedly pulled that in...

Sorry, been eight years since I used lein heavily... Profiles were always a weird area...

Maybe @vemv can help you when he is around...

❯ lein with-profile +project/dev classpath
Warning: profile :profiles/dev not found.
I did this and it shows kaocha being downloaded and also on the classpath

this is also true with lein classpath since i think dev is included by default

and then i just ran lein kaocha and it worked

❯ lein kaocha
Warning: profile :profiles/dev not found.
WARNING: Did not load a configuration file and using the defaults.
This is fine for experimenting, but for long-term use, we recommend creating a configuration file to avoid changes in behavior between releases.
To create a configuration file using the current defaults and configuration file location, create a file named tests.edn that contains '#kaocha/v1 {}'.
WARNING: In :test-paths, no such file or directory: test
WARNING: No tests were found. This may be an issue in your Kaocha test configuration. To investigate, check the :test-paths and :ns-patterns keys in tests.edn.

using your project.clj file but with all the deps removed. I added environ back in and it still “worked” except it gave an error because environ brought in clojure 1.8 and kaocha requries 1.9+

❯ lein kaocha
Warning: profile :profiles/dev not found.
ERROR: Kaocha requires Clojure 1.9 or later.
And then adding Clojure 1.11.1 it works (no tests are found)

do you have a file at ~/.lein/profiles.clj? I’m not sure how multiple :dev profiles are merged, but perhaps you have one in <project>/profiles.clj or ~/.lein/profiles.clj and it’s clobbering?

I don't have a ~/.lein/profiles.clj

can you post the output of running lein kaocha?

$ lein kaocha --version
Can't find 'kaocha.runner' as .class or .clj for lein run: please check the spelling.
Execution error (FileNotFoundException) at user/eval140$fn (form-init14676761731919941110.clj:1).
Could not locate kaocha/runner__init.class, kaocha/runner.clj or kaocha/runner.cljc on classpath.

Full report at:
/var/folders/2p/5wjfhyyd6zqc9qw_gq9f1zx80000gn/T/clojure-12318744842917680805.edn

can you make a new directory in your /tmp directory called check and make the file /tmp/check/project.clj with these contents:

(defproject server "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url ""
  :license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"
            :url ""}
  :dependencies [[environ "1.2.0"]
                 [org.clojure/clojure "1.11.1"]]
  :main ^:skip-aot server.core
  :plugins [[lein-environ "1.2.0"]]
  :target-path "target/%s"
  :aliases {"kaocha" ["run" "-m" "kaocha.runner"]}
  :profiles {:uberjar {:aot :all
                       :jvm-opts ["-Dclojure.compiler.direct-linking=true"]}
             :dev [:project/dev :profiles/dev]
             :project/dev {:dependencies [[lambdaisland/kaocha "1.87.1366"]]}})
and then run lein kaocha This setup works on my machine. And perhaps that can tell us. Also would love the full output of lein classpath

$ vim /tmp/check/project.clj
$ lein kaocha --version
Can't find 'kaocha.runner' as .class or .clj for lein run: please check the spelling.
Execution error (FileNotFoundException) at user/eval140$fn (form-init17859507483933356489.clj:1).
Could not locate kaocha/runner__init.class, kaocha/runner.clj or kaocha/runner.cljc on classpath.

Full report at:
/var/folders/2p/5wjfhyyd6zqc9qw_gq9f1zx80000gn/T/clojure-2284241369372617117.ed

can you tell me what pwd is here?

Did you mean ~/tmp/check or /tmp/check?

And you wanted pwd in my project directory or /tmp/check? The latter is /tmp/check

The former is /Users/nsadeh/Dropbox/modeldiplomat/server

i want to make sure that you are running lein kaocha from /tmp/check

$ lein kaocha --version
Warning: profile :profiles/dev not found.
WARNING: Did not load a configuration file and using the defaults.
This is fine for experimenting, but for long-term use, we recommend creating a configuration file to avoid changes in behavior between releases.
To create a configuration file using the current defaults and configuration file location, create a file named tests.edn that contains '#kaocha/v1 {}'.
lambdaisland/kaocha "1.87.1366"

ok. so that works

From /tmp/check

you have to run lein kaocha from the directory your project is in

Yea that still is broken in the same way

Same output as before

cd ~/Dropbox/modeldiplomat/server`
lein kaocha
that doesn’t work though?

That is correct

i’m confused. where did you run lein kaocha for the /tmp/check one? Why didn’t you run it from that directory

I am not sure I am getting this right. I ran lein kaocha twice, once from /tmp/check, and once from the project directory ~/Dropbox/modeldiplomat/server . The former resulted in Warning: profile :profiles/dev not found, and the latter resulted in Can't find 'kaocha.runner' as .class or .clj

What does the full report say?

It should have the entire stacktrace, which likely isn't useful, but you never know