# Test Plots on Travis: GKS can't open display

**URL:** https://discourse.julialang.org/t/test-plots-on-travis-gks-cant-open-display/9465
**Category:** General Usage
**Tags:** question, ci
**Created:** [March 2, 2018, 8:26pm UTC](https://discourse.julialang.org/t/test-plots-on-travis-gks-cant-open-display/9465 "2018-03-02T20:26:40Z")
**Posts on this page:** 12
**Page:** 1

<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: [March 2, 2018, 8:26pm UTC](https://discourse.julialang.org/t/test-plots-on-travis-gks-cant-open-display/9465/1 "2018-03-02T20:26:40Z")

</div>

I’m trying to test `Plots` on Travis and I get this:

```julia
GKS: can't open display on ""
     Is your DISPLAY environment variable set correctly?
     Did you enable X11 and TCP forwarding?
GKS: Open failed in routine OPEN_WS
GKS: GKS not in proper state. GKS must be either in the state WSOP or WSAC in routine ACTIVATE_WS

```

followed by a segmentation fault.  
Any idea how to remedy this?

---

<div class="post-metadata">

### Author: ![jheinen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jheinen/32/2787_2.png) [@jheinen](https://discourse.julialang.org/u/jheinen)
#### Post date: [March 2, 2018, 9:26pm UTC](https://discourse.julialang.org/t/test-plots-on-travis-gks-cant-open-display/9465/2 "2018-03-02T21:26:32Z")

</div>

Please refer to the Plots Test scripts. You have to tell Plots/GR, that you are on a headless system and set PLOTS\_TESTS=true and GKSwstype=100.

---

<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: [March 2, 2018, 9:35pm UTC](https://discourse.julialang.org/t/test-plots-on-travis-gks-cant-open-display/9465/3 "2018-03-02T21:35:30Z")

</div>

Awesome, thank you! Testing this now.  
I’m not sure if you meant anything other than adding these two lines to the `runtests.jl` file:

```julia
ENV["PLOTS_TEST"] = "true"
ENV["GKSwstype"] = "100"

```

Or if there is anything else peculiar I need to add to the `.travis.yml` file.

(I also specify `default(show=false)` because none of my plots are actually displayed, they are all being saved to file)

---

<div class="post-metadata">

### Author: ![jheinen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jheinen/32/2787_2.png) [@jheinen](https://discourse.julialang.org/u/jheinen)
#### Post date: [March 2, 2018, 9:45pm UTC](https://discourse.julialang.org/t/test-plots-on-travis-gks-cant-open-display/9465/4 "2018-03-02T21:45:56Z")

</div>

… These two Lines should fix the Problem - yes

---

<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: [March 2, 2018, 9:55pm UTC](https://discourse.julialang.org/t/test-plots-on-travis-gks-cant-open-display/9465/5 "2018-03-02T21:55:13Z")

</div>

Thank you so much for your help. Unfortunately, I’m still getting the segmentation fault… Has to be related somehow.

---

<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: [March 2, 2018, 10:06pm UTC](https://discourse.julialang.org/t/test-plots-on-travis-gks-cant-open-display/9465/6 "2018-03-02T22:06:25Z")

</div>

In case you want to take a close look, here’s the repo: [https://github.com/yakir12/Saves.jl](https://github.com/yakir12/Saves.jl)

---

<div class="post-metadata">

### Author: ![jheinen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jheinen/32/2787_2.png) [@jheinen](https://discourse.julialang.org/u/jheinen)
#### Post date: [March 2, 2018, 10:13pm UTC](https://discourse.julialang.org/t/test-plots-on-travis-gks-cant-open-display/9465/7 "2018-03-02T22:13:06Z")

</div>

Please set the environment varaiables **before** you include or start Plots related stuff…

---

<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: [March 2, 2018, 10:38pm UTC](https://discourse.julialang.org/t/test-plots-on-travis-gks-cant-open-display/9465/8 "2018-03-02T22:38:27Z")

</div>

The segmentation fault is till [there](https://travis-ci.org/yakir12/Saves.jl/jobs/348450101#L1182). I moved the two lines all the way to the [top of the test file](https://github.com/yakir12/Saves.jl/blob/master/test/runtests.jl#L1). I really appreciate any additional insight you might have, I obviously need it :spongebob: …

---

<div class="post-metadata">

### Author: ![jheinen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jheinen/32/2787_2.png) [@jheinen](https://discourse.julialang.org/u/jheinen)
#### Post date: [March 3, 2018, 11:23am UTC](https://discourse.julialang.org/t/test-plots-on-travis-gks-cant-open-display/9465/9 "2018-03-03T11:23:05Z")

</div>

Could you try an “intrinsic” format to save your plots (e.g. PDF or SVG), just to ensure, that the problem is Cairo-specific. If so, did you try the test on a local machine or, do you have a MWE to reproduce the segfault?

---

<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: [March 3, 2018, 12:52pm UTC](https://discourse.julialang.org/t/test-plots-on-travis-gks-cant-open-display/9465/10 "2018-03-03T12:52:00Z")

</div>

Gladly. I’ll be able to try that tonight (in 7 hours).  
It works perfect locally. I’ll try distilling it to a MWE tonight as well.

---

<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: [March 3, 2018, 9:23pm UTC](https://discourse.julialang.org/t/test-plots-on-travis-gks-cant-open-display/9465/11 "2018-03-03T21:23:30Z")

</div>

Right, so just plotting one simple plot and saving it to SVG [worked](https://travis-ci.org/yakir12/Saves.jl/jobs/348743327#L1248). But I’m after creating a gif or mp4 (so a bitmap not a vector graphic). Hmm, I’ll keep fiddling.

---

<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: [March 5, 2018, 10:16pm UTC](https://discourse.julialang.org/t/test-plots-on-travis-gks-cant-open-display/9465/12 "2018-03-05T22:16:24Z")

</div>

I played with a really clean version. While it finally worked on Linux, it didn’t on osx, the reason being that I can’t install ffmpeg via Travis on an osx. I checked with Plots to see how they do it, and they don’t. The tests for osx are skipped.  
Not sure how to proceed…

Here’s the repo: [https://github.com/yakir12/Saves.jl](https://github.com/yakir12/Saves.jl)  
Ignore [this](https://github.com/yakir12/Saves.jl/blob/823ecc0ff7dbbfd53dba2afd16cafd05bc66d727/.travis.yml#L31) line, it was my feeble attempt to install ffmpeg on the mac.
