# Makie app from command line

**URL:** <https://discourse.julialang.org/t/makie-app-from-command-line/53890>\
**Category:** Visualization\
**Tags:** question\
**Created:** [January 25, 2021, 7:50am UTC](https://discourse.julialang.org/t/makie-app-from-command-line/53890 "2021-01-25T07:50:45Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [January 25, 2021, 7:50am UTC](https://discourse.julialang.org/t/makie-app-from-command-line/53890/1 "2021-01-25T07:50:45Z")

</div>

How can I launch a Makie.jl based app from the command line?

I tried:

```julia
julia --project -e "include(\"./src/KiteViewer.jl\");main()"

```

which shortly shows the Makie windows but then terminates. How can I  
achieve that it stays open until I close the Makie window?

Full source: [https://github.com/ufechner7/KiteViewer](https://github.com/ufechner7/KiteViewer)

---

<div class="post-metadata">

**Author:** ![tomaklutfu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tomaklutfu/32/2411_2.png) [@tomaklutfu](https://discourse.julialang.org/u/tomaklutfu)\
**Post date:** [January 25, 2021, 8:06am UTC](https://discourse.julialang.org/t/makie-app-from-command-line/53890/2 "2021-01-25T08:06:27Z")

</div>

If you need to drop into `REPL`, use `-i` in the command line. It prevents immediate close when the execution ends.

```julia
julia --project -ie "include(\"./src/KiteViewer.jl\");main()"

```

---

<div class="post-metadata">

**Author:** ![magister-ludi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/magister-ludi/32/4003_2.png) [@magister-ludi](https://discourse.julialang.org/u/magister-ludi)\
**Post date:** [January 25, 2021, 12:10pm UTC](https://discourse.julialang.org/t/makie-app-from-command-line/53890/3 "2021-01-25T12:10:40Z")

</div>

Is it really necessary to invoke the REPL for this? For `GTK.jl`, for instance, there is a good [description](https://juliagraphics.github.io/Gtk.jl/latest/manual/nonreplusage/) for using that framework without using the REPL. A standalone script shouldn’t need to drop into a different context.

I haven’t used `Makie.jl` very much, so I don’t know whether the recipe provided by `GTK` can be modified usefully.

---

<div class="post-metadata">

**Author:** ![tomaklutfu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tomaklutfu/32/2411_2.png) [@tomaklutfu](https://discourse.julialang.org/u/tomaklutfu)\
**Post date:** [January 25, 2021, 12:26pm UTC](https://discourse.julialang.org/t/makie-app-from-command-line/53890/4 "2021-01-25T12:26:05Z")

</div>

You can use similar mechanism but I don’t know if `Makie` exposes some function for exiting gui.

---

<div class="post-metadata">

**Author:** ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)\
**Post date:** [January 25, 2021, 12:41pm UTC](https://discourse.julialang.org/t/makie-app-from-command-line/53890/5 "2021-01-25T12:41:12Z")

</div>

You can use:

```julia
using GLMakie
gl_screen = display(scatter(1:4));
wait(gl_screen)

```

Which will block as long as that window is open

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [January 26, 2021, 1:28am UTC](https://discourse.julialang.org/t/makie-app-from-command-line/53890/6 "2021-01-26T01:28:36Z")

</div>

Thanks for all the good replies!

I now use the following start script:

```julia
#!/bin/bash
cd "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"
source ~/.bashrc

echo "Lauching KiteViewer..."
julia --optimize=1 --project -e "include(\"./src/KiteViewer.jl\");main(true)"

```

I need the second line to make sure the script also works when launched via a double click on a link to it that I have on the desktop.

Startup time is about 30s with Julia 1.6beta and optimization level one. Still some room for improvement, but good enough for now.

The main function looks like that:

```julia
function main(gl_wait=false)
    scene, layout = layoutscene(resolution = (840, 900), backgroundcolor = RGBf0(0.7, 0.8, 1))
    ...
    gl_screen = display(scene)

    if gl_wait
        wait(gl_screen)
    end
    return nothing
end

```

---

<div class="post-metadata">

**Author:** ![yakir12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yakir12/32/297_2.png) [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Post date:** [January 26, 2021, 8:08am UTC](https://discourse.julialang.org/t/makie-app-from-command-line/53890/7 "2021-01-26T08:08:36Z")

</div>

Just in case you missed it, you could compile an app for this with [https://julialang.github.io/PackageCompiler.jl/dev/apps/#Creating-an-app-1](https://julialang.github.io/PackageCompiler.jl/dev/apps/#Creating-an-app-1), thus reducing time to first plot by a lot.

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [January 26, 2021, 8:27am UTC](https://discourse.julialang.org/t/makie-app-from-command-line/53890/8 "2021-01-26T08:27:11Z")

</div>

Yes, I could use package compiler, but for now my priority is to implement the full functionality of my program. And there is hope that also the latency without package compiler gets reduced much further: [https://github.com/JuliaPlots/Makie.jl/issues/792](https://github.com/JuliaPlots/Makie.jl/issues/792)

---

<div class="post-metadata">

**Author:** ![yakir12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yakir12/32/297_2.png) [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Post date:** [January 26, 2021, 8:49am UTC](https://discourse.julialang.org/t/makie-app-from-command-line/53890/9 "2021-01-26T08:49:24Z")

</div>

I see no other way forward other than cloning Julius, Simon, and Tim. Imagine the possibilities!

---

<div class="post-metadata">

**Author:** ![ellocco](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ellocco/32/31331_2.png) [@ellocco](https://discourse.julialang.org/u/ellocco)\
**Post date:** [February 9, 2023, 11:08am UTC](https://discourse.julialang.org/t/makie-app-from-command-line/53890/10 "2023-02-09T11:08:48Z")

</div>

> [@yakir12](#):
>
> [https://julialang.github.io/PackageCompiler.jl/dev/apps/#Creating-an-app-1](https://julialang.github.io/PackageCompiler.jl/dev/apps/#Creating-an-app-1)

The link is broken, please have a look here:

> **[Apps · PackageCompiler](https://julialang.github.io/PackageCompiler.jl/stable/apps.html)**
>
> Documentation for PackageCompiler.

---

<div class="post-metadata">

**Author:** ![ellocco](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ellocco/32/31331_2.png) [@ellocco](https://discourse.julialang.org/u/ellocco)\
**Post date:** [February 10, 2023, 1:07am UTC](https://discourse.julialang.org/t/makie-app-from-command-line/53890/11 "2023-02-10T01:07:26Z")

</div>

Hi,

I have tried to follow your idea of an Application, but I fail.  
Do you have an idea what is missing:

> **[Stefans\_Julia\_RePo/AppDir at main · StefanPofahl/Stefans\_Julia\_RePo](https://github.com/StefanPofahl/Stefans_Julia_RePo/tree/main/AppDir)**
>
> main/AppDir

---

<div class="post-metadata">

**Author:** ![yakir12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yakir12/32/297_2.png) [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Post date:** [February 10, 2023, 8:40am UTC](https://discourse.julialang.org/t/makie-app-from-command-line/53890/12 "2023-02-10T08:40:16Z")

</div>

Hi Stefan,  
Posting on a 2 year old topic is not encouraged (also ominously called necroposting). Additionally, it’s not easy for people to help you if you only supply them with a link to a repo expecting them to figure out the problem on their own.  
Instead, it’s best practice to start a new topic where you explain exactly what you tried and what went wrong. In fact, to get the best help possible, please follow [these excellent suggestions](https://discourse.julialang.org/t/please-read-make-it-easier-to-help-you/14757) as closely as you can.

---

<div class="post-metadata">

**Author:** ![ellocco](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ellocco/32/31331_2.png) [@ellocco](https://discourse.julialang.org/u/ellocco)\
**Post date:** [February 11, 2023, 9:29pm UTC](https://discourse.julialang.org/t/makie-app-from-command-line/53890/13 "2023-02-11T21:29:30Z")

</div>

> [@ellocco](#):
>
> Do you have an idea what is missing:

Meanwhile, I was able to modify my project - mentioned above - in a way that the `GLMakie`-Application is now opperational as stand alone executable under MS Windows.  
The main obsticle was the wrong starting point. The example in the [PackageCompile-package](https://github.com/JuliaLang/PackageCompiler.jl/tree/master/examples/MyApp) is to complex for me and I do not understand which side-effects there are, if I delete or modify parts of it.  
The important part of the code came from @sdanisch (see above):

```julia
gl_screen = display(scatter(1:4));
wait(gl_screen)

```
