I am trying to use https://github.com/clojure/tools.build to make a Clay notebook and I am finding that requiring scicloj.clay.v2.api causes the command-line to never exit. Here is a minimal build.clj:
(ns build
(:require
[scicloj.clay.v2.api :as clay]))
(defn hello
[_opts]
(println "hello"))
In a shell the command clojure -T:build hello never exits. When I remove the require the command will run and exit. Is there something more I need to do to exit Clay?Thanks for reporting this. I don't see a reason for this to happen. Exploring ..
still looking.. opened an issue: https://github.com/scicloj/clay/issues/98
It turns out the problem is that Clay starts a #portal session in order to receive Portal's client-side code. That session should be carefully stopped afterwards. I will try to fix this in a future version. For now, here is a workaround:
(defn hello
[_opts]
(println "hello"))
Thank you for looking into this! I do not understand your workaround. That function looks the same as in the minimal build script. In a real build script I would be calling clay/make! .
Ohh, sorry, I pasted the wrong code.
Here:
(defn hello
[_opts]
(println "hello")
(portal.api/close))
That does not change things for me. The command-line still never exits. Here's the build script now:
(ns build
(:require
[scicloj.clay.v2.api :as clay]))
(defn hello
[_opts]
(println "hello")
(portal.api/close))
Including [portal.api] in the :require also does not change behavior. Is there another piece I am missing?Thanks, interesting.
Could you share your deps.edn or project.clj , the Clojure version and the Java version?
I wish to make sure we are running the same setup and look further (though maybe not today or tomorrow).
deps.edn
{:paths ["dev"
"notebooks"
"scripts"
"src"]
:deps {org.clojure/clojure {:mvn/version "1.11.1"}
org.babashka/cli {:mvn/version "0.8.58"}
aerial.hanami/aerial.hanami {:mvn/version "0.20.0"}
cheshire/cheshire {:mvn/version "5.12.0"}
com.github.seancorfield/honeysql {:mvn/version "2.6.1126"}
com.github.seancorfield/next.jdbc {:mvn/version "1.3.925"}
org.scicloj/clay {:mvn/version "2-alpha87"}
org.scicloj/noj {:mvn/version "1-alpha31"}
org.xerial/sqlite-jdbc {:mvn/version "3.45.2.0"}
scicloj/tablecloth {:mvn/version "7.029.1"}}
:aliases {:build {:deps {io.github.clojure/tools.build {:mvn/version "0.10.0"}
org.scicloj/clay {:mvn/version "2-alpha87"}}
:ns-default build}
}
}
Clojure version:
$ clojure --version
Clojure CLI version 1.11.1.1413
Java version:
$ java -version
openjdk version "20.0.1" 2023-04-18I appreciate the help!
As an aside, is the portal session also the reason clojure -T:build hello takes longer to print "hello" with the Clay require than without the require?
Thanks for the detailed report! This is very helpful.
As an aside, is the portal session also the reason clojure -T:build hello takes longer to print "hello" with the Clay require than without the require?That could be caused by a few other things. Possibly, we are requiring some heavy namespaces somewhere, and possibly, that can be improved somehow (e.g., with ahead-of-time compilation).
Clay has been designed and tested mostly with a REPL experience in mind. It is a great idea to use it in a tools.build context, but we are expected to be surprised with some problems of this kind.I understand. Thank you for the explanation!