Skip to content

Add additional possible path for Mathematica on MacOS #96

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 16, 2025

Conversation

dahong67
Copy link
Contributor

Thanks for the very nice package!

Issue

Installation on my machine initially failed with the following message during the package build:

ERROR: Error building `MathLink`: 
ERROR: LoadError: Could not find Mathematica or Wolfram Engine installation.
Please set the `JULIA_MATHLINK` and `JULIA_MATHKERNEL` variables.

For some context, I'm on an M1 Max Macbook Pro and running macOS Sequoia 15.2. I get the following under "About Wolfram" when I look in Mathematica (though "Mathematica" seems to be called "Wolfram for Desktop" now?):

  • Version Number: 14.1.0.0
  • Platform: Mac OS X ARM (64-bit)

Investigating the paths, it seems that what my machine needed was:

  • ENV["JULIA_MATHLINK"] = joinpath(path, "Contents/Frameworks/mathlink.framework/mathlink")
  • ENV["JULIA_MATHKERNEL"] = joinpath(path, "Contents/MacOS/MathKernel")

where path was the output of mdfind "kMDItemCFBundleIdentifier == 'com.wolfram.*'" (/Applications/Wolfram.app on my machine). Guessing it has to do with Wolfram renaming some of these things in recent versions?

What this PR implements

This PR simply adds this case to the list of cases considered in deps/build.jl.

I figure that adding to the end of the list has the least chance of breaking cases that are already working, but perhaps the better fix would be to change

for path in readlines(`mdfind "kMDItemCFBundleIdentifier == 'com.wolfram.Mathematica'"`)

to instead be

for path in readlines(`mdfind "kMDItemCFBundleIdentifier == 'com.wolfram.*'"`)

Also, I saw that @simonbyrne is implementing what looks to be a better long-term solution in #68. However, that seems to currently be blocked by something on the Wolfram side (if I'm understanding correctly), so perhaps this can be useful to some folks in the meantime?

Seems to be what is needed for Wolfram Mathematica 14.1 on MacOS.
@fremling
Copy link
Collaborator

Hi @dahong67. SOrry for letting this hang for so long.

I'm not in a Mac myself and could not verify it. A few months down the line, does the solutions work well for you?

@dahong67
Copy link
Contributor Author

Hi @fremling. No problem! Just tested this PR on my machine and can confirm that it still works on my end.

@dahong67
Copy link
Contributor Author

Just to give a bit more detail, here's what happens when I try to install the master branch:

(@v1.11) pkg> activate --temp
  Activating new project at `/var/folders/h_/3320nshd7t1bzbtcrj023bkr0000gn/T/jl_CWayvt`

(jl_CWayvt) pkg> add MathLink#master
    Updating git-repo `https://github.com/JuliaInterop/MathLink.jl.git`
   Resolving package versions...
    Updating `/private/var/folders/h_/3320nshd7t1bzbtcrj023bkr0000gn/T/jl_CWayvt/Project.toml`
  [18c93696] + MathLink v0.6.2 `https://github.com/JuliaInterop/MathLink.jl.git#master`
    Updating `/private/var/folders/h_/3320nshd7t1bzbtcrj023bkr0000gn/T/jl_CWayvt/Manifest.toml`
  [18c93696] + MathLink v0.6.2 `https://github.com/JuliaInterop/MathLink.jl.git#master`
  [8f399da3] + Libdl v1.11.0
  [de0858da] + Printf v1.11.0
  [4ec0a83e] + Unicode v1.11.0
Precompiling project...
  ✗ MathLink
  0 dependencies successfully precompiled in 1 seconds. 2 already precompiled.
  1 dependency errored.
  For a report of the errors see `julia> err`. To retry use `pkg> precompile`

(jl_CWayvt) pkg> st
Status `/private/var/folders/h_/3320nshd7t1bzbtcrj023bkr0000gn/T/jl_CWayvt/Project.toml`
  [18c93696] MathLink v0.6.2 `https://github.com/JuliaInterop/MathLink.jl.git#master`

(jl_CWayvt) pkg> build
    Building MathLink  `~/.julia/scratchspaces/44cfe95a-1eb2-52ea-b672-e2afdf69b78f/e2a46cb879638599db7305ecdc3249680d1f358b/build.log`
ERROR: Error building `MathLink`: 
[ Info: The JULIA_PKG_SERVER_REGISTRY_PREFERENCE variable
[ Info: false
ERROR: LoadError: Could not find Mathematica or Wolfram Engine installation.
Please set the `JULIA_MATHLINK` and `JULIA_MATHKERNEL` variables.
Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:35
 [2] find_lib_ker()
   @ Main ~/.julia/packages/MathLink/PwwGL/deps/build.jl:93
 [3] top-level scope
   @ ~/.julia/packages/MathLink/PwwGL/deps/build.jl:112
 [4] include(fname::String)
   @ Main ./sysimg.jl:38
 [5] top-level scope
   @ none:5
in expression starting at /Users/dahong/.julia/packages/MathLink/PwwGL/deps/build.jl:99

And here's what happens when I install using this PR:

(@v1.11) pkg> activate --temp
  Activating new project at `/var/folders/h_/3320nshd7t1bzbtcrj023bkr0000gn/T/jl_U6CkRj`

(jl_U6CkRj) pkg> add MathLink#565988d
   Resolving package versions...
    Updating `/private/var/folders/h_/3320nshd7t1bzbtcrj023bkr0000gn/T/jl_U6CkRj/Project.toml`
  [18c93696] + MathLink v0.6.0 `https://github.com/JuliaInterop/MathLink.jl.git#565988d`
    Updating `/private/var/folders/h_/3320nshd7t1bzbtcrj023bkr0000gn/T/jl_U6CkRj/Manifest.toml`
  [18c93696] + MathLink v0.6.0 `https://github.com/JuliaInterop/MathLink.jl.git#565988d`
  [8f399da3] + Libdl v1.11.0
  [de0858da] + Printf v1.11.0
  [4ec0a83e] + Unicode v1.11.0

julia> using MathLink

julia> W"Sin"
W"Sin"

julia> sin1 = W"Sin"(1.0)
W`Sin[1.0]`

julia> sinx = W"Sin"(W"x")
W`Sin[x]`

julia> W`Sin[1]`
W`Sin[1]`

julia> weval(sin1)
0.8414709848078965

julia> weval(sinx)
W`Sin[x]`

julia> weval(W"Integrate"(sinx, (W"x", 0, 1)))
W`Plus[1, Times[-1, Cos[1]]]`

julia> weval(sinx; x=2.0)
0.9092974268256817

@fremling fremling merged commit 01e1105 into JuliaInterop:master May 16, 2025
0 of 3 checks passed
@fremling
Copy link
Collaborator

Thanks for fixing this dependency issue. Merging it in and will update with a new release asap.

@dahong67
Copy link
Contributor Author

Great, thanks! 🎊

@dahong67 dahong67 deleted the patch-1 branch May 17, 2025 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants