No X11 DISPLAY variable was set, but this program performed an operation which requires it. (Using Gitlab)

Asked by Shresth Suman

I am want to run SikuliX via Gitlab.

Command: - sudo java -jar /home/tntesting/SikuliX/sikulix.jar -v

Error: No X11 DISPLAY variable was set, but this program performed an operation which requires it.

I have connected to my ubuntu machine using the remote desktop connection.
When I run the "Command" manually from the remote desktop connection monitor, the sikulix works.
Log -
sikuli@tnsikulil64:/home/tntesting/SikuliX$ sudo java -jar /home/tntesting/SikuliX/sikulix.jar -v
[DEBUG] IDE: starting
[DEBUG] IDE: no extensions.txt nor valid content
[DEBUG] IDE: adding extension: /root/.Sikulix/Extensions/jython-standalone-2.7.1.jar
[DEBUG] IDE: Running: /home/tntesting/SikuliX/sikulix.jar
[DEBUG] IDE: AppData: /root/.Sikulix
[DEBUG] IDE: Classpath: /home/tntesting/SikuliX/sikulix.jar:/root/.Sikulix/Extensions/jython-standalone-2.7.1.jar
[DEBUG] IDE: no extensions.txt nor valid content
[39 debug] RunTimeINIT: temp folder ok: /tmp/Sikulix_1955149882
Options: *** options dump
Options: testing =
Options: OptionsFile = /root/.Sikulix/SikulixStore/SikulixOptions.txt
Options: *** options dump end
***** show environment for 1.1.4-SNAPSHOT-#303-2019-06-10_09:04 IDE
user.home: /root
user.dir (work dir): /home/tntesting/SikuliX
user.name: root
java.io.tmpdir: /tmp
running 64Bit(amd64) on l (4.15.0-91-generic) from a jar
java 8 version 1.8 vm 25.242-b08 class 52.0 arch 64
app data folder: /root/.Sikulix
executing jar: /home/tntesting/SikuliX/sikulix.jar
*** classpath dump sikulix
  0: file:/home/tntesting/SikuliX/sikulix.jar
  1: file:/root/.Sikulix/Extensions/jython-standalone-2.7.1.jar
*** classpath dump end
***** show environment end
[168 debug] init user preferences
[201 debug] IDE: running with Locale: en_US
[DEBUG] IDE: --- Sikuli parameters ---
[DEBUG] IDE: 1: -v
[205 debug] RunTimeIDE: libsExport: folder exists: /root/.Sikulix/SikulixLibs (1.1.4 - 201906100904)
[205 debug] RunTimeIDE: loadLib: libJXGrabKey.so (success)
[206 debug] HotkeyManager: add Capture Hotkey: CTRL+SHIFT 2 (50, 3)
[211 debug] HotkeyManager: add Abort Hotkey: ALT+SHIFT C (67, 9)
[212 debug] IDE: Init ScriptingSupport
[217 debug] IDESupport: enter
[1169 debug] Runner: added: Text [txt] text/text
[1170 debug] Runner: added: Robot [robot] text/robot
[1447 debug] Runner: added: JavaScript [js] text/javascript
[1448 debug] Runner: added: Sikulix [sikuli, skl, jar] directory/sikulix
[1455 debug] Runner: added: Jython [py, $py.class] text/jython
[1456 debug] IDESupport: added: Jython
[1457 debug] IDESupport: added: JavaScript
[1457 debug] IDESupport: added: Text
[1457 debug] IDESupport: exit: defaultrunner: Jython (py)
[1458 debug] IDE: Reading Preferences
[1463 debug] Screen: initScreens: starting
[1463 debug] Screen: Accessing: GraphicsEnvironment.getLocalGraphicsEnvironment()
[1463 debug] Screen: Accessing: GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices()
[1463 debug] Screen: ScreenDevice 0 has (0,0) --- will be primary Screen(0)
[1463 debug] Screen: Monitor 0: (0, 0) 1920 x 1080
[1464 debug] Screen: initScreens: ending
[1464 debug] IDE: Adding components to window
[1477 debug] IDE: [I18N] menuRecent
[1496 debug] IDE: [I18N] menuToolAndroid
[1499 debug] IDE: creating tabbed editor
[1585 debug] IDE: creating message area
[1666 debug] EditorConsolePane: starting redirection to message area
IDE terminated: returned: 0

But when I run the same "Command" via gitlab (using .gitlab-ci.yml). It gives the above mentioned error.
variable: SIKULIX_HOME_OS_LINUX: /home/tntesting/SikuliX/sikulix.jar
Here is the log :
$ sudo java -jar $SIKULIX_HOME_OS_LINUX -v
 [DEBUG] IDE: starting
 [DEBUG] IDE: no extensions.txt nor valid content
 [DEBUG] IDE: adding extension: /root/.Sikulix/Extensions/jython-standalone-2.7.1.jar
 [DEBUG] IDE: Running: /home/tntesting/SikuliX/sikulix.jar
 [DEBUG] IDE: AppData: /root/.Sikulix
 [DEBUG] IDE: Classpath: /home/tntesting/SikuliX/sikulix.jar:/root/.Sikulix/Extensions/jython-standalone-2.7.1.jar
 [DEBUG] IDE: no extensions.txt nor valid content
 [38 debug] RunTimeINIT: temp folder ok: /tmp/Sikulix_2127086446
 Options: *** options dump
 Options: testing =
 Options: OptionsFile = /root/.Sikulix/SikulixStore/SikulixOptions.txt
 Options: *** options dump end
 ***** show environment for 1.1.4-SNAPSHOT-#303-2019-06-10_09:04 IDE
 user.home: /root
 user.dir (work dir): /home/tntesting/Gitlab-runner/builds/shYsv6eQ/0/TimeNET/Development
 user.name: root
 java.io.tmpdir: /tmp
 running 64Bit(amd64) on l (4.15.0-91-generic) from a jar
 java 8 version 1.8 vm 25.242-b08 class 52.0 arch 64
 app data folder: /root/.Sikulix
 executing jar: /home/tntesting/SikuliX/sikulix.jar
 *** classpath dump sikulix
   0: file:/home/tntesting/SikuliX/sikulix.jar
   1: file:/root/.Sikulix/Extensions/jython-standalone-2.7.1.jar
 *** classpath dump end
 ***** show environment end
 Exception in thread "main" java.awt.HeadlessException:
 No X11 DISPLAY variable was set, but this program performed an operation which requires it.
  at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:204)
  at java.awt.Window.<init>(Window.java:536)
  at java.awt.Frame.<init>(Frame.java:420)
  at javax.swing.JFrame.<init>(JFrame.java:233)
  at org.sikuli.ide.SikulixIDE.<init>(SikulixIDE.java:146)
  at org.sikuli.ide.SikulixIDE.get(SikulixIDE.java:156)
  at org.sikuli.ide.SikulixIDE.main(SikulixIDE.java:60)
 [54 debug] RunTimeIDE: ***** final cleanup at System.exit() *****
 [65 debug] FileManager: deleteFileOrFolder:
 /tmp/Sikulix_2127086446
 IDE terminated: returned: 1

Does anyone have any idea why this is happening?
Please let me know in case you need further information.

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
Shresth Suman
Solved:
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

GitLab is a headless environment.

To use SikuliX, you have to provide some "fake" monitor environment (an example might be xvfb).

Revision history for this message
Shresth Suman (shsu7085) said :
#2

Thank you for your reply!
My ubuntu machine does have a monitor connected to it. Whenever I run the command directly from the machine it runs without any error. However, when I run the same command using the gitlab yml file, it gives an error.
Workaround - export DISPLAY=:0.0

I do not know how this command solves it but it is working for now.
Please let me know in case I have a wrong understanding.

Revision history for this message
RaiMan (raimund-hocke) said :
#3

Exactly this was missing when run from GitLab:

Error: No X11 DISPLAY variable was set, but this program performed an operation which requires it.

So be happy to have solved it ;-)