scicloj / wolframite

An interface between Clojure and Wolfram Language (the language of Mathematica)
https://scicloj.github.io/wolframite/
Mozilla Public License 2.0
56 stars 2 forks source link

Initialization fail (MathLink program has closed the link) #39

Closed light-matters closed 7 months ago

light-matters commented 7 months ago

Running the namespace

(ns physics.cavity.simple-loss
  (:require
   [wolframite.core :refer [eval] :rename {eval e} :as wl]))

fails to initialize wolframite. This, while using the latest main branch (scicloj/wolframite {:git/url "https://github.com/scicloj/wolframite" :git/sha "723e5dfc89f9fc67dac07f47c58d1e9f90cd0053"})

2. Unhandled clojure.lang.Compiler$CompilerException
   Error compiling wolframite/core.clj at (133:1)
   #:clojure.error{:phase :execution,
                   :line 133,
                   :column 1,
                   :source "wolframite/core.clj"}
             Compiler.java: 7665  clojure.lang.Compiler/load
                   RT.java:  381  clojure.lang.RT/loadResourceScript
                   RT.java:  372  clojure.lang.RT/loadResourceScript
                   RT.java:  459  clojure.lang.RT/load
                   RT.java:  424  clojure.lang.RT/load
                  core.clj: 6161  clojure.core/load/fn
                  core.clj: 6160  clojure.core/load
                  core.clj: 6144  clojure.core/load
               RestFn.java:  408  clojure.lang.RestFn/invoke
                  core.clj: 5933  clojure.core/load-one
                  core.clj: 5928  clojure.core/load-one
                  core.clj: 5975  clojure.core/load-lib/fn
                  core.clj: 5974  clojure.core/load-lib
                  core.clj: 5953  clojure.core/load-lib
               RestFn.java:  142  clojure.lang.RestFn/applyTo
                  core.clj:  669  clojure.core/apply
                  core.clj: 6016  clojure.core/load-libs
                  core.clj: 6000  clojure.core/load-libs
               RestFn.java:  137  clojure.lang.RestFn/applyTo
                  core.clj:  669  clojure.core/apply
                  core.clj: 6038  clojure.core/require
                  core.clj: 6038  clojure.core/require
               RestFn.java:  408  clojure.lang.RestFn/invoke
                      REPL:    1  physics.cavity.simple-loss/eval16977/loading--auto--
                      REPL:    1  physics.cavity.simple-loss/eval16977
                      REPL:    1  physics.cavity.simple-loss/eval16977
             Compiler.java: 7194  clojure.lang.Compiler/eval
             Compiler.java: 7183  clojure.lang.Compiler/eval
             Compiler.java: 7149  clojure.lang.Compiler/eval
                  core.clj: 3215  clojure.core/eval
                  core.clj: 3211  clojure.core/eval
    interruptible_eval.clj:   87  nrepl.middleware.interruptible-eval/evaluate/fn/fn
                  AFn.java:  152  clojure.lang.AFn/applyToHelper
                  AFn.java:  144  clojure.lang.AFn/applyTo
                  core.clj:  667  clojure.core/apply
                  core.clj: 1990  clojure.core/with-bindings*
                  core.clj: 1990  clojure.core/with-bindings*
               RestFn.java:  425  clojure.lang.RestFn/invoke
    interruptible_eval.clj:   87  nrepl.middleware.interruptible-eval/evaluate/fn
                  main.clj:  437  clojure.main/repl/read-eval-print/fn
                  main.clj:  437  clojure.main/repl/read-eval-print
                  main.clj:  458  clojure.main/repl/fn
                  main.clj:  458  clojure.main/repl
                  main.clj:  368  clojure.main/repl
               RestFn.java: 1523  clojure.lang.RestFn/invoke
    interruptible_eval.clj:   84  nrepl.middleware.interruptible-eval/evaluate
    interruptible_eval.clj:   56  nrepl.middleware.interruptible-eval/evaluate
    interruptible_eval.clj:  152  nrepl.middleware.interruptible-eval/interruptible-eval/fn/fn
                  AFn.java:   22  clojure.lang.AFn/run
               session.clj:  218  nrepl.middleware.session/session-exec/main-loop/fn
               session.clj:  217  nrepl.middleware.session/session-exec/main-loop
                  AFn.java:   22  clojure.lang.AFn/run
               Thread.java: 1583  java.lang.Thread/run

1. Caused by com.wolfram.jlink.MathLinkException
   Connected MathLink program has closed the link, but there might still be data
   underway.
light-matters commented 7 months ago

Using the same test, I get a similar (but different) error again (Manjaro, i3).

`1. Caused by clojure.lang.ExceptionInfo MathLink connection was lost. Perhaps you need to activate Mathematica first, you are trying to start multiple concurrent connections (from separate REPLs), or there is some other issue and you need to retry, or restart and retry... {:kernel-link-opts ["-linkmode" "launch" "-linkname" "\"//usr/local/Wolfram/WolframEngine/13.3/Executables/WolframKernel\" -mathlink"], :cause #error { :cause "MathLink connection was lost." :via [{:type com.wolfram.jlink.MathLinkException :message "MathLink connection was lost." :at [com.wolfram.jlink.NativeLink nextPacket "NativeLink.java" 305]}] :trace [[com.wolfram.jlink.NativeLink nextPacket "NativeLink.java" 305] [com.wolfram.jlink.WrappedKernelLink nextPacket "WrappedKernelLink.java" 237] [com.wolfram.jlink.KernelLinkImpl waitForAnswer "KernelLinkImpl.java" 174] [com.wolfram.jlink.KernelLinkImpl discardAnswer "KernelLinkImpl.java" 191] [wolframite.core$initBANG$fn17952 invoke "core.clj" 90] [wolframite.core$initBANG invokeStatic "core.clj" 89] [wolframite.core$initBANG invoke "core.clj" 81] [wolframite.core$initBANG invokeStatic "core.clj" 85] [wolframite.core$initBANG invoke "core.clj" 81] [wolframite.core$make_wl_evaluator invokeStatic "core.clj" 121] [wolframite.core$make_wl_evaluator invoke "core.clj" 120] [wolframite.core$eval17965 invokeStatic "core.clj" 133] [wolframite.core$eval17965 invoke "core.clj" 133] [clojure.lang.Compiler eval "Compiler.java" 7194] [clojure.lang.Compiler load "Compiler.java" 7653] [clojure.lang.RT loadResourceScript "RT.java" 381] [clojure.lang.RT loadResourceScript "RT.java" 372] [clojure.lang.RT load "RT.java" 459] [clojure.lang.RT load "RT.java" 424] [clojure.core$load$fn6908 invoke "core.clj" 6161] [clojure.core$load invokeStatic "core.clj" 6160] [clojure.core$load doInvoke "core.clj" 6144] [clojure.lang.RestFn invoke "RestFn.java" 408] [clojure.core$load_one invokeStatic "core.clj" 5933] [clojure.core$load_one invoke "core.clj" 5928] [clojure.core$load_lib$fn6850 invoke "core.clj" 5975] [clojure.core$load_lib invokeStatic "core.clj" 5974] [clojure.core$load_lib doInvoke "core.clj" 5953] [clojure.lang.RestFn applyTo "RestFn.java" 142] [clojure.core$apply invokeStatic "core.clj" 669] [clojure.core$load_libs invokeStatic "core.clj" 6016] [clojure.core$load_libs doInvoke "core.clj" 6000] [clojure.lang.RestFn applyTo "RestFn.java" 137] [clojure.core$apply invokeStatic "core.clj" 669] [clojure.core$require invokeStatic "core.clj" 6038] [clojure.core$require doInvoke "core.clj" 6038] [clojure.lang.RestFn invoke "RestFn.java" 408] [physics.cavity.simple_loss$eval16826$loading6789auto__16827 invoke "simple_loss.clj" 1] [physics.cavity.simple_loss$eval16826 invokeStatic "simple_loss.clj" 1] [physics.cavity.simple_loss$eval16826 invoke "simple_loss.clj" 1] [clojure.lang.Compiler eval "Compiler.java" 7194] [clojure.lang.Compiler eval "Compiler.java" 7183] [clojure.lang.Compiler load "Compiler.java" 7653] [user$eval16822 invokeStatic "NO_SOURCE_FILE" 1] [user$eval16822 invoke "NO_SOURCE_FILE" 1] [clojure.lang.Compiler eval "Compiler.java" 7194] [clojure.lang.Compiler eval "Compiler.java" 7149] [clojure.core$eval invokeStatic "core.clj" 3215] [clojure.core$eval invoke "core.clj" 3211] [nrepl.middleware.interruptible_eval$evaluate$fn8755$fn8756 invoke "interruptible_eval.clj" 87] [clojure.lang.AFn applyToHelper "AFn.java" 152] [clojure.lang.AFn applyTo "AFn.java" 144] [clojure.core$apply invokeStatic "core.clj" 667] [clojure.core$with_bindingsSTAR invokeStatic "core.clj" 1990] [clojure.core$with_bindingsSTAR doInvoke "core.clj" 1990] [clojure.lang.RestFn invoke "RestFn.java" 425] [nrepl.middleware.interruptible_eval$evaluate$fn8755 invoke "interruptible_eval.clj" 87] [clojure.main$repl$read_eval_print9206$fn9209 invoke "main.clj" 437] [clojure.main$repl$read_eval_print9206 invoke "main.clj" 437] [clojure.main$repl$fn9215 invoke "main.clj" 458] [clojure.main$repl invokeStatic "main.clj" 458] [clojure.main$repl doInvoke "main.clj" 368] [clojure.lang.RestFn invoke "RestFn.java" 1523] [nrepl.middleware.interruptible_eval$evaluate invokeStatic "interruptible_eval.clj" 84] [nrepl.middleware.interruptible_eval$evaluate invoke "interruptible_eval.clj" 56] [nrepl.middleware.interruptible_eval$interruptible_eval$fn8788$fn__8792 invoke "interruptible_eval.clj" 152] [clojure.lang.AFn run "AFn.java" 22] [nrepl.middleware.session$session_exec$main_loop8858$fn8862 invoke "session.clj" 218] [nrepl.middleware.session$session_exec$main_loop__8858 invoke "session.clj" 217] [clojure.lang.AFn run "AFn.java" 22] [java.lang.Thread run "Thread.java" 1583]]}} core.clj: 93 wolframite.core/init!/fn core.clj: 89 wolframite.core/init! core.clj: 81 wolframite.core/init! core.clj: 85 wolframite.core/init! core.clj: 81 wolframite.core/init! core.clj: 121 wolframite.core/make-wl-evaluator core.clj: 120 wolframite.core/make-wl-evaluator core.clj: 133 wolframite.core/eval17965 core.clj: 133 wolframite.core/eval17965 Compiler.java: 7194 clojure.lang.Compiler/eval Compiler.java: 7653 clojure.lang.Compiler/load RT.java: 381 clojure.lang.RT/loadResourceScript RT.java: 372 clojure.lang.RT/loadResourceScript RT.java: 459 clojure.lang.RT/load RT.java: 424 clojure.lang.RT/load core.clj: 6161 clojure.core/load/fn core.clj: 6160 clojure.core/load core.clj: 6144 clojure.core/load RestFn.java: 408 clojure.lang.RestFn/invoke core.clj: 5933 clojure.core/load-one core.clj: 5928 clojure.core/load-one core.clj: 5975 clojure.core/load-lib/fn core.clj: 5974 clojure.core/load-lib core.clj: 5953 clojure.core/load-lib RestFn.java: 142 clojure.lang.RestFn/applyTo core.clj: 669 clojure.core/apply core.clj: 6016 clojure.core/load-libs core.clj: 6000 clojure.core/load-libs RestFn.java: 137 clojure.lang.RestFn/applyTo core.clj: 669 clojure.core/apply core.clj: 6038 clojure.core/require core.clj: 6038 clojure.core/require RestFn.java: 408 clojure.lang.RestFn/invoke simple_loss.clj: 1 physics.cavity.simple-loss/eval16826/loading--auto-- simple_loss.clj: 1 physics.cavity.simple-loss/eval16826 simple_loss.clj: 1 physics.cavity.simple-loss/eval16826 Compiler.java: 7194 clojure.lang.Compiler/eval Compiler.java: 7183 clojure.lang.Compiler/eval Compiler.java: 7653 clojure.lang.Compiler/load REPL: 1 user/eval16822 REPL: 1 user/eval16822 Compiler.java: 7194 clojure.lang.Compiler/eval Compiler.java: 7149 clojure.lang.Compiler/eval core.clj: 3215 clojure.core/eval core.clj: 3211 clojure.core/eval interruptible_eval.clj: 87 nrepl.middleware.interruptible-eval/evaluate/fn/fn AFn.java: 152 clojure.lang.AFn/applyToHelper AFn.java: 144 clojure.lang.AFn/applyTo core.clj: 667 clojure.core/apply core.clj: 1990 clojure.core/with-bindings core.clj: 1990 clojure.core/with-bindings RestFn.java: 425 clojure.lang.RestFn/invoke interruptible_eval.clj: 87 nrepl.middleware.interruptible-eval/evaluate/fn main.clj: 437 clojure.main/repl/read-eval-print/fn main.clj: 437 clojure.main/repl/read-eval-print main.clj: 458 clojure.main/repl/fn main.clj: 458 clojure.main/repl main.clj: 368 clojure.main/repl RestFn.java: 1523 clojure.lang.RestFn/invoke interruptible_eval.clj: 84 nrepl.middleware.interruptible-eval/evaluate interruptible_eval.clj: 56 nrepl.middleware.interruptible-eval/evaluate interruptible_eval.clj: 152 nrepl.middleware.interruptible-eval/interruptible-eval/fn/fn AFn.java: 22 clojure.lang.AFn/run session.clj: 218 nrepl.middleware.session/session-exec/main-loop/fn session.clj: 217 nrepl.middleware.session/session-exec/main-loop AFn.java: 22 clojure.lang.AFn/run Thread.java: 1583 java.lang.Thread/run

`

light-matters commented 7 months ago

Tried again using a fresh install of mathematica on the same machine and still no joy.

light-matters commented 7 months ago

This issue was resolved by commit: 5c395551545d7e4678ffb07b687acaaf02e0ad9c