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
            linux-vdso.so.1 =>  (0x00007fff7d1ff000)
            libgobject-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 (0x00007f85d64d9000)
            librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f85d62d1000)
            libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007f85d5fda000)
            libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f85d5dbd000)
            libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f85d5bb9000)
            libutil.so.1 => /lib/x86_64-linux-gnu/libutil.so.1 (0x00007f85d59b5000)
            libX11.so.6 => /usr/lib/x86_64-linux-gnu/libX11.so.6 (0x00007f85d567d000)
            libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f85d5376000)
            libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f85d50f1000)
            libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f85d4edb000)
            libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f85d4b3c000)
            libgthread-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgthread-2.0.so.0 (0x00007f85d4936000)
            libffi.so.6 => /usr/lib/x86_64-linux-gnu/libffi.so.6 (0x00007f85d472e000)
            libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f85d44f2000)
            /lib64/ld-linux-x86-64.so.2 (0x00007f85d6731000)
            libxcb.so.1 => /usr/lib/x86_64-linux-gnu/libxcb.so.1 (0x00007f85d42d5000)
            libXau.so.6 => /usr/lib/x86_64-linux-gnu/libXau.so.6 (0x00007f85d40d2000)
            libXdmcp.so.6 => /usr/lib/x86_64-linux-gnu/libXdmcp.so.6 (0x00007f85d3ecb000)
    

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

  6. Let's find the missing library file and install the necessary package   
  7.  
    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 libgdk-x11-2.0.so
    ia32-libs: /usr/lib32/libgdk-x11-2.0.so
    ia32-libs: /usr/lib32/libgdk-x11-2.0.so.0
    ia32-libs: /usr/lib32/libgdk-x11-2.0.so.0.2400.6
    libgtk2.0-0: /usr/lib/x86_64-linux-gnu/libgdk-x11-2.0.so.0
    libgtk2.0-0: /usr/lib/x86_64-linux-gnu/libgdk-x11-2.0.so.0.2400.6
    libgtk2.0-0-dbg: /usr/lib/debug/usr/lib/x86_64-linux-gnu/libgdk-x11-2.0.so.0.2400.6
    libgtk2.0-dev: /usr/lib/x86_64-linux-gnu/libgdk-x11-2.0.so
    lsb-build-desktop3: /usr/lib/lsb3/libgdk-x11-2.0.so
    
    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
    DISPLAY=localhost:10.0
    
    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
  13.  
    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?

    ReplyDelete