# GMT.jl and VSCode

**URL:** <https://discourse.julialang.org/t/gmt-jl-and-vscode/76155>\
**Category:** Performance\
**Tags:** question, plotting, vscode, gmt\
**Created:** [February 10, 2022, 11:26am UTC](https://discourse.julialang.org/t/gmt-jl-and-vscode/76155 "2022-02-10T11:26:18Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![lazarusA](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lazarusa/32/6571_2.png) [@lazarusA](https://discourse.julialang.org/u/lazarusA)\
**Post date:** [February 10, 2022, 11:26am UTC](https://discourse.julialang.org/t/gmt-jl-and-vscode/76155/1 "2022-02-10T11:26:19Z")

</div>

I’m having some issues between GMT and VSCode. (macOS Big Sur).  
Running the following in terminal works fine. I get the image in a new window.

```julia
using GMT
plot(1:10, rand(10), lw=1, lc=:blue, marker=:square,
     markeredgecolor=0, size=0.2, markerfacecolor=:red, title="Hello World",
     xlabel="Spoons", ylabel="Forks", show=true)

```

but running within a VSCode I get:

```julia
psconvert [ERROR]: Cannot execute Ghostscript (gs).
ERROR: LoadError: Something went wrong when calling the module. GMT error number = 79
Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:33
 [2] gmt(::String)
   @ GMT ~/.julia/packages/GMT/jguOm/src/gmt_main.jl:295
 [3] showfig(d::Dict{Symbol, Any}, fname_ps::String, fname_ext::String, opt_T::String, K::Bool, fname::String)
   @ GMT ~/.julia/packages/GMT/jguOm/src/common_options.jl:3393
 [4] finish_PS_module(::Dict{Symbol, Any}, ::Vector{String}, ::String, ::Bool, ::Bool, ::Bool, ::Matrix{Float64}, ::Vararg{Any})
   @ GMT ~/.julia/packages/GMT/jguOm/src/common_options.jl:3549
 [5] common_plot_xyz(::String, ::Matrix{Float64}, ::String, ::Bool, ::Bool, ::Pair{Symbol, Any}, ::Vararg{Pair{Symbol, Any}})
   @ GMT ~/.julia/packages/GMT/jguOm/src/psxy.jl:221
 [6] #plot#271
   @ ~/.julia/packages/GMT/jguOm/src/plot.jl:130 [inlined]
 [7] top-level scope
   @ ~/Documents/testJulia/withgmt.jl:10
in expression starting at /Users/lalonso/Documents/testJulia/withgmt.jl:10

```

any pointers on how to solve this issue ? thanks.

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [February 10, 2022, 1:25pm UTC](https://discourse.julialang.org/t/gmt-jl-and-vscode/76155/2 "2022-02-10T13:25:07Z")

</div>

I seems that either Ghostscript is not installed or not in the path.  
Sorry, I may not be very responsive in the next few days. In case of need you can also try seek help I. The GMT forum.

---

<div class="post-metadata">

**Author:** ![lazarusA](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lazarusa/32/6571_2.png) [@lazarusA](https://discourse.julialang.org/u/lazarusA)\
**Post date:** [February 10, 2022, 5:56pm UTC](https://discourse.julialang.org/t/gmt-jl-and-vscode/76155/3 "2022-02-10T17:56:50Z")

</div>

Thanks… An update. Actually I was not seeing a previous error which is the following:

```julia
ERROR: LoadError: InitError: IOError: could not spawn `gmt --show-userdir`: 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] eachline(cmd::Cmd; keep::Bool)
    @ Base ./process.jl:318
  [6] eachline
    @ ./process.jl:317 [inlined]
  [7] #readlines#378
    @ ./io.jl:553 [inlined]
  [8] readlines
    @ ./io.jl:553 [inlined]
  [9] __init__ (test::Bool)
    @ GMT ~/.julia/packages/GMT/jguOm/src/GMT.jl:286
 [10] __init__ ()
    @ GMT ~/.julia/packages/GMT/jguOm/src/GMT.jl:266
 [11] _include_from_serialized(path::String, depmods::Vector{Any})
    @ Base ./loading.jl:768
 [12] _require_search_from_serialized(pkg::Base.PkgId, sourcepath::String)
    @ Base ./loading.jl:854
 [13] _require(pkg::Base.PkgId)
    @ Base ./loading.jl:1097
 [14] require(uuidkey::Base.PkgId)
    @ Base ./loading.jl:1013
 [15] require(into::Module, mod::Symbol)
    @ Base ./loading.jl:997
 [16] eval
    @ ./boot.jl:373 [inlined]
 [17] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)
    @ Base ./loading.jl:1196
 [18] invokelatest(::Any, ::Any, ::Vararg{Any}; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Base ./essentials.jl:716
 [19] invokelatest(::Any, ::Any, ::Vararg{Any})
    @ Base ./essentials.jl:714
 [20] inlineeval(m::Module, code::String, code_line::Int64, code_column::Int64, file::String; softscope::Bool)
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.5.11/scripts/packages/VSCodeServer/src/eval.jl:211
 [21] (::VSCodeServer.var"#60#64"{Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})()
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.5.11/scripts/packages/VSCodeServer/src/eval.jl:155
 [22] withpath(f::VSCodeServer.var"#60#64"{Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams}, path::String)
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.5.11/scripts/packages/VSCodeServer/src/repl.jl:185
 [23] (::VSCodeServer.var"#59#63"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})()
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.5.11/scripts/packages/VSCodeServer/src/eval.jl:153
 [24] hideprompt(f::VSCodeServer.var"#59#63"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.5.11/scripts/packages/VSCodeServer/src/repl.jl:36
 [25] (::VSCodeServer.var"#58#62"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})()
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.5.11/scripts/packages/VSCodeServer/src/eval.jl:124
 [26] with_logstate(f::Function, logstate::Any)
    @ Base.CoreLogging ./logging.jl:511
 [27] with_logger
    @ ./logging.jl:623 [inlined]
 [28] (::VSCodeServer.var"#57#61"{VSCodeServer.ReplRunCodeRequestParams})()
    @ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.5.11/scripts/packages/VSCodeServer/src/eval.jl:201
 [29] #invokelatest#2
    @ ./essentials.jl:716 [inlined]
 [30] invokelatest(::Any)
    @ Base ./essentials.jl:714
 [31] macro expansion
    @ ~/.vscode/extensions/julialang.language-julia-1.5.11/scripts/packages/VSCodeServer/src/eval.jl:34 [inlined]
 [32] (::VSCodeServer.var"#55#56")()
    @ VSCodeServer ./task.jl:423
during initialization of module GMT

```

and if I do in my terminal `which gmt` I get:

```julia
/usr/local/bin/gmt

```

as I said plotting in the Julia repl works just fine.

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [February 10, 2022, 6:09pm UTC](https://discourse.julialang.org/t/gmt-jl-and-vscode/76155/4 "2022-02-10T18:09:48Z")

</div>

Is the `Julia: Use Plot Pane` parameter in your VS code checked or not?

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [February 10, 2022, 7:29pm UTC](https://discourse.julialang.org/t/gmt-jl-and-vscode/76155/5 "2022-02-10T19:29:06Z")

</div>

Does it run from a normal REPL?  
One thing that is known to not work is the GMT Bundle distributed in the GMT site. The lib paths are screwed when seen from within Julia and the dependencies are not found.  
On the other hand the CI tests are run from a Mac VM (that builds GMT from brew). But if you don’t have a previous installation it should have been installed by Conda. Was not that the case?

---

<div class="post-metadata">

**Author:** ![kerry](https://avatars.discourse-cdn.com/v4/letter/k/46a35a/32.png) [@kerry](https://discourse.julialang.org/u/kerry)\
**Post date:** [April 18, 2022, 11:56pm UTC](https://discourse.julialang.org/t/gmt-jl-and-vscode/76155/6 "2022-04-18T23:56:50Z")

</div>

I have the same issue and error message running GMT in VSCode but only for GMT plotting commands inside .jl files. Interactively running GMT commands in an .ipynb cell works fine.
