Skip to content
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

GMT.jl not working on Apple Silicon in macOS #770

Closed
truedichotomy opened this issue Dec 1, 2021 · 8 comments
Closed

GMT.jl not working on Apple Silicon in macOS #770

truedichotomy opened this issue Dec 1, 2021 · 8 comments

Comments

@truedichotomy
Copy link

I encountered the following error when trying to install GMT on my M1 Mac running macOS 12.0.1:

(@v1.7) pkg> precompile
Precompiling project...
  ✗ GMT
  0 dependencies successfully precompiled in 5 seconds (485 already precompiled)

ERROR: The following 1 direct dependency failed to precompile:

GMT [5752ebe1-31b9-557e-87aa-f909b540aa54]

Failed to precompile GMT [5752ebe1-31b9-557e-87aa-f909b540aa54] to /Users/gong/.julia/compiled/v1.7/GMT/jl_Zp8aPA.
    Building Conda → `~/.julia/scratchspaces/44cfe95a-1eb2-52ea-b672-e2afdf69b78f/6cdc8832ba11c7695f494c9d9a1c31e90959ce0f/build.log`
    Building GMT ──→ `~/.julia/scratchspaces/44cfe95a-1eb2-52ea-b672-e2afdf69b78f/91ea96b1ae21a8f8878b7e042f76ad97ff152df1/build.log`
ERROR: LoadError: IOError: could not spawn `gmt --show-library`: no such file or directory (ENOENT)
Stacktrace:
  [1] _spawn_primitive(file::String, cmd::Cmd, stdio::Vector{Any})
    @ Base ./process.jl:100
  [2] #690
    @ ./process.jl:113 [inlined]
  [3] setup_stdios(f::Base.var"#690#691"{Cmd}, stdios::Vector{Any})
    @ Base ./process.jl:197
  [4] _spawn
    @ ./process.jl:112 [inlined]
  [5] open(cmds::Cmd, stdio::Base.DevNull; write::Bool, read::Bool)
    @ Base ./process.jl:371
  [6] open
    @ ./process.jl:362 [inlined]
  [7] open(cmds::Cmd, mode::String, stdio::Base.DevNull)
    @ Base ./process.jl:342
  [8] read(cmd::Cmd)
    @ Base ./process.jl:416
  [9] read(cmd::Cmd, #unused#::Type{String})
    @ Base ./process.jl:427
 [10] top-level scope
    @ ~/.julia/packages/GMT/dEogU/src/GMT.jl:54
 [11] include
    @ ./Base.jl:418 [inlined]
 [12] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::Nothing)
    @ Base ./loading.jl:1318
 [13] top-level scope
    @ none:1
 [14] eval
    @ ./boot.jl:373 [inlined]
 [15] eval(x::Expr)
    @ Base.MainInclude ./client.jl:453
 [16] top-level scope
    @ none:1
in expression starting at /Users/gong/.julia/packages/GMT/dEogU/src/GMT.jl:1

julia> versioninfo()
Julia Version 1.7.0
Commit 3bf9d17731 (2021-11-30 12:12 UTC)
Platform Info:
  OS: macOS (arm64-apple-darwin21.1.0)
  CPU: Apple M1
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-12.0.1 (ORCJIT, cyclone)
@joa-quim
Copy link
Member

joa-quim commented Dec 1, 2021

I suspect the problem lies in Conda that may not have a M1 GMT version (better to ask that in the GMT forum).
I know that it works on M1 when one builds GMT manually.

@joa-quim
Copy link
Member

joa-quim commented Dec 2, 2021

Are you able to check if GMT was installed and, eventually, a Intel version?

@truedichotomy
Copy link
Author

There is a darwin-arm64 version of GMT available and I have installed on my M1 mac:
https://github.com/GenericMappingTools/gmt/releases/tag/6.3.0

@joa-quim
Copy link
Member

joa-quim commented Dec 2, 2021

Hmm, and you have GMT on the path? When GMT.jl finds the GMT lib it tries to use it, otherwise it installs from Conda. But it didn't in your case, did it?
Another bad thing is that Apple manages to screw the dependencies paths in the bundle (the dmg) so deeply it becomes useless for externals (Julia, Python, Matlab) but in that case we see errors claiming that certain images do not exist, which dos not seem to be the case in your stacktrace. ... so I'm confused.

@truedichotomy
Copy link
Author

What GMT environmental variables would I need to set?

I manually linked /Applications/GMT-6.3.0.app/Contents/Resources/bin/gmt to /usr/local/bin/gmt and tried to install GMT.jl again. This time it got the follow error message which seems to be different than the one I got previously:

julia> Pkg.precompile()
Precompiling project...
  ✗ GMT
  0 dependencies successfully precompiled in 2 seconds (500 already precompiled)

ERROR: The following 1 direct dependency failed to precompile:

GMT [5752ebe1-31b9-557e-87aa-f909b540aa54]

Failed to precompile GMT [5752ebe1-31b9-557e-87aa-f909b540aa54] to /Users/gong/.julia/compiled/v1.7/GMT/jl_R95qAD.
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/otool-classic: can't open file: @executable_path/../lib/libgdal.29.dylib (No such file or directory)
ERROR: LoadError: failed processes:
  Process(`otool -L @executable_path/../lib/libgdal.29.dylib`, ProcessExited(1)) [1]
  Process(`grep libproj`, ProcessExited(1)) [1]

Stacktrace:
  [1] pipeline_error(procs::Base.ProcessChain)
    @ Base ./process.jl:544
  [2] (::Base.var"#697#698"{Base.ProcessChain})()
    @ Base ./process.jl:320
  [3] iterate(itr::Base.EachLine{Base.PipeEndpoint}, state::Nothing) (repeats 2 times)
    @ Base ./io.jl:1019
  [4] _collect(cont::UnitRange{Int64}, itr::Base.EachLine{Base.PipeEndpoint}, #unused#::Base.HasEltype, isz::Base.SizeUnknown)
    @ Base ./array.jl:660
  [5] collect
    @ ./array.jl:649 [inlined]
  [6] #readlines#378
    @ ./io.jl:553 [inlined]
  [7] readlines(s::Base.OrCmds)
    @ Base ./io.jl:553
  [8] top-level scope
    @ ~/.julia/packages/GMT/dEogU/src/GMT.jl:62
  [9] include
    @ ./Base.jl:418 [inlined]
 [10] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::Nothing)
    @ Base ./loading.jl:1318
 [11] top-level scope
    @ none:1
 [12] eval
    @ ./boot.jl:373 [inlined]
 [13] eval(x::Expr)
    @ Base.MainInclude ./client.jl:453
 [14] top-level scope
    @ none:1
in expression starting at /Users/gong/.julia/packages/GMT/dEogU/src/GMT.jl:1
Stacktrace:
 [1] pkgerror(msg::String)
   @ Pkg.Types /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Pkg/src/Types.jl:68
 [2] precompile(ctx::Pkg.Types.Context; internal_call::Bool, strict::Bool, warn_loaded::Bool, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
   @ Pkg.API /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Pkg/src/API.jl:1362
 [3] precompile
   @ /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Pkg/src/API.jl:1013 [inlined]
 [4] #precompile#220
   @ /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Pkg/src/API.jl:1011 [inlined]
 [5] precompile()
   @ Pkg.API /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Pkg/src/API.jl:1011
 [6] top-level scope
   @ REPL[6]:1

@joa-quim
Copy link
Member

joa-quim commented Dec 2, 2021

The problem is this

can't open file: @executable_path/../lib/libgdal.29.dylib

That is the same issue as discussed here.
It's what I said. I don't know what Apple does with those relative paths.

I'm afraid that GMT installation will not work for GMT.jl. My preferred solution is to build GMT locally and drop the bundle. Sorry.

@truedichotomy
Copy link
Author

I removed the GMT bundle installation and reinstalled with homebrew on the M1 mac, after that I was able to successfully install GMT.jl in Julia 1.7. Thanks for your tip.

@joa-quim
Copy link
Member

joa-quim commented Dec 2, 2021

Nice. I was hesitant to suggest the brew via because sometimes it screws too.

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

No branches or pull requests

2 participants