babashka / pods

Pods support for JVM and babashka
Eclipse Public License 1.0
120 stars 12 forks source link

Problems using pods with sci #70

Closed ingydotnet closed 6 months ago

ingydotnet commented 6 months ago

I'm having trouble using babashka/pods from babashka/sci.

I saw 2 different behaviors. One where everything works but the program hangs forever at the end. Another where the program crashes with:

Execution error (IOException) at java.lang.ProcessImpl/forkAndExec (ProcessImpl.java:-2).
error=2, No such file or directory

I was able to reproduce both with a minimal Clojure program. The program and outputs are here: https://gist.github.com/ingydotnet/b014c4497edc3b54722ff772ef9e7878

I have a stack trace from an error that looks the same when using babashka.pods/load-pod https://gist.github.com/ingydotnet/ec5f290786ee64701a3e0e6abe5e1397

borkdude commented 6 months ago

You need to pass the context as the first argument to babashka.pods.sci/load-pod:

(declare ctx)

(defn load-pod [& args]
  (apply pods/load-pod ctx args))

(def ctx
  (sci/init
    {:namespaces
     {'babashka.pods
      {'load-pod
       ; Using this works but the program never terminates:
       ; See: z-out-1.txt
       #_(fn [& args] (apply pods/load-pod ctx args))

       ; Using this causes the runtime error:
       ; Execution error (IOException) at java.lang.ProcessImpl/forkAndExec (ProcessImpl.java:-2).
       ; error=2, No such file or directory
       ; See: z-out-2.txt
       (sci/copy-var load-pod nil)}}}))

Tested and worked.