Search This Blog

Saturday, March 30, 2013

How to run Sublime editor on remote cloud Linux server

Sublime is a graphical text editor that uses GTK libraries on Linux. If you would like to run it from your remote cloud servers session please follow the instruction below.
  1. Install the Sublime locally on your cloud server 
  2. Check what libraries you may be missing 

  3. The listing below shows that any libraries are missing.

     root@server:~/Sublime Text 2# ldd ./sublime_text
   =>  (0x00007fff7d1ff000)
   => /usr/lib/x86_64-linux-gnu/ (0x00007f85d64d9000)
   => /lib/x86_64-linux-gnu/ (0x00007f85d62d1000)
   => /lib/x86_64-linux-gnu/ (0x00007f85d5fda000)
   => /lib/x86_64-linux-gnu/ (0x00007f85d5dbd000)
   => /lib/x86_64-linux-gnu/ (0x00007f85d5bb9000)
   => /lib/x86_64-linux-gnu/ (0x00007f85d59b5000)
   => /usr/lib/x86_64-linux-gnu/ (0x00007f85d567d000)
   => /usr/lib/x86_64-linux-gnu/ (0x00007f85d5376000)
   => /lib/x86_64-linux-gnu/ (0x00007f85d50f1000)
   => /lib/x86_64-linux-gnu/ (0x00007f85d4edb000)
   => /lib/x86_64-linux-gnu/ (0x00007f85d4b3c000)
   => /usr/lib/x86_64-linux-gnu/ (0x00007f85d4936000)
   => /usr/lib/x86_64-linux-gnu/ (0x00007f85d472e000)
   => /lib/x86_64-linux-gnu/ (0x00007f85d44f2000)
            /lib64/ (0x00007f85d6731000)
   => /usr/lib/x86_64-linux-gnu/ (0x00007f85d42d5000)
   => /usr/lib/x86_64-linux-gnu/ (0x00007f85d40d2000)
   => /usr/lib/x86_64-linux-gnu/ (0x00007f85d3ecb000)

  4. Try to execute it and it should complain about some libraries now that are loaded dynamically after start.  
    root@server:~/Sublime Text 2# ./sublime_text
    Unable to load
    Unable to load gdk_cairo_create from
    Unable to load gdk_cursor_new_for_display from
    Unable to load gdk_cursor_unref from
    Unable to load gdk_error_trap_pop from
    Unable to load gdk_error_trap_push from
    Unable to load gtk_window_unfullscreen from
    Unable to load pango_font_description_free from
    Unable to load pango_font_description_new from
    Unable to load pango_font_description_set_family from
    Unable to load pango_font_description_set_size from
    Unable to load pango_cairo_show_layout from
    Unable to load pango_cairo_update_layout from
    Unable to load all required GTK functions
    Unable to init px

  6. Let's find the missing library file and install the necessary package   
    root@server:~/Sublime Text 2# aptitude install apt-file
    root@server:~/Sublime Text 2# apt-file update
    root@server:~/Sublime Text 2# apt-file search
    ia32-libs: /usr/lib32/
    ia32-libs: /usr/lib32/
    ia32-libs: /usr/lib32/
    libgtk2.0-0: /usr/lib/x86_64-linux-gnu/
    libgtk2.0-0: /usr/lib/x86_64-linux-gnu/
    libgtk2.0-0-dbg: /usr/lib/debug/usr/lib/x86_64-linux-gnu/
    libgtk2.0-dev: /usr/lib/x86_64-linux-gnu/
    lsb-build-desktop3: /usr/lib/lsb3/
    root@server:~/Sublime Text 2# aptitude install libgtk2.0-0
    root@server:~/Sublime Text 2# ./sublime_text
    (sublime_text:14069): Gtk-WARNING **: cannot open display:

  8. We need to enable X11 forwarding and set up a X11 server where the application output can be displayed

  9. If you connecting from Linux you need to use the -X option for ssh client.
    If you using Windows putty program you need to enable the X11 forwarding at Connection-SSH-X11-"Enable X11 forwarding". For the "X display location" option use the localhost:0.0

  10. Open new ssh session to the cloud server and test

  11. If client and server are configured properly you should be able to see DISPLAY variable being set
    root@urado2:~# set | grep DIS
    root@urado2:~# cat /etc/ssh/sshd_config | grep X11
    X11Forwarding yes
    X11DisplayOffset 10

  12. Test if we can start out sublime editor or if we get any new errors
    root@urado2:~/Sublime Text 2# ./sublime_text
    (sublime_text:16851): Gtk-WARNING **: cannot open display: localhost:10.0

    To fix this we need to have an X11 windows server running on our local machine  If you are using Windows you can install for example Xming X Server for Windows

  14. Final test after the Xming server is up and running

  15. After lunch you should be able now to see the screen of your editor that was lunch on Linux cloud. 
    As this is a remote session there maybe some issues with lag and latency what will influence responsiveness and delays when editing.

1 comment:

  1. This works, but is extremely slow when using Sublime Text. Did you experience these performance issues? If not, what cloud provider are you using?