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

Setting up the JLINK path - confusion between README and code #71

Closed daslu closed 4 months ago

daslu commented 4 months ago

The README recommends setting up the path to the JLINK jar using WOLFRAM_INSTALL_PATH: https://github.com/scicloj/wolframite/blob/8510c7e/README.md

It turns out that in the code, two different environment variables are set up: https://github.com/scicloj/wolframite/blob/31e9c9bee0ad5b1e45f49966ac7e0f4d4f4f9ae5/src/wolframite/runtime/system.clj#L65 .. but only JLINK_JAR_PATH is used: https://github.com/scicloj/wolframite/blob/31e9c9b/src/wolframite/runtime/jlink.clj#L29

holyjak commented 4 months ago

Is this correct? The info argument to path--jlink should respect your setting of WOLFRAM_INSTALL_PATH. Did you observe it did not?

I would argue that it is very rare / likely wrong if you are setting JLINK_JAR_PATH - in all cases, you should be setting WOLFRAM_INSTALL_PATH, because we need not only the jar but also the wolfram kernel executable.

holyjak commented 4 months ago

Ok, I see there is indeed a problem. (system/info) returns something like

{:user-paths {"WOLFRAM_INSTALL_PATH" "/tmp/fake"}, ; JLINK_JAR_PATH would be here if set
 :defaults
 {:root
  "/Applications/Wolfram Engine.app/Contents/Resources/Wolfram Player.app/Contents",
  :kernel "MacOS/WolframKernel",
  :product :wolfram-engine,
  :os :mac}}

and we look at either the jlink path or the defaults.

Instead, we should:

  1. If there is jlink path, use that
  2. If there is WOLFRAM_INSTALL_PATH, us that to compute jlink path
  3. Else, use the defaults
light-matters commented 4 months ago

@daslu Can I ask what your system setup and install path was (if it wasn't customised)? In general, we try to guess a reasonable default path.

daslu commented 4 months ago

Now it is the default chosen by Wolfram's install process (on Ubuntu Lnux):

$ echo $WOLFRAM_INSTALL_PATH 
/usr/local/Wolfram/WolframEngine/14.0

Earlier, I used something customized for my own habits, and that is where I experienced the problem.

light-matters commented 4 months ago

Ah, I see. Hopefully the path above will work without any environment variables.

daslu commented 4 months ago

Indeed works for me, thanks.