Ubuntu – Ubuntu Can’t Run Sublime Text 2 executable

sublime-text

I've installed Sublime Text 2 on my Ubuntu linux VM. The executable appears to be in /opt/sublime_text_2.

When I click on sublime_text executable it opens a new terminal window and does not open sublime text.

If I enter from the terminal: /opt/sublime_text_2/sublime_text a new terminal window pops up with the following:

#!/bin/bash
/opt/sublime_text_2/sublime_text --class=sublime-text-2 "$@"

and Sublime Text does not open

Best Answer

I'd suggest re-installing Sublime Text from scratch. I highly recommend using Sublime Text 3, as it has many new features and bug fixes that aren't in ST2, and many plugins available through Package Control are moving to ST3-only versions to take advantage of the additional features. Also, ST3 is available as a .deb for Ubuntu, making installation a 1-step process.

To install ST3, go to the download page and select Ubuntu 64-bit or Ubuntu 32-bit, depending on your system. After downloading, go to your Downloads directory in your terminal and run

sudo dpkg -i sublime-text_build-3059_amd64.deb

or

sudo dpkg -i sublime-text_build-3059_i386.deb

depending on the version you downloaded. It will install everything in /opt/sublime_text, will place a sublime_text.desktop file in /usr/share/applications (and put an icon in the Unity launcher, IIRC), and will also create /usr/bin/subl for starting Sublime from the command line.


If for some reason you absolutely need to use ST2, then reinstall by following these steps:

  1. run sudo rm -r /opt/sublime_text_2 to remove the old directory.
  2. Go to http://www.sublimetext.com/2 and download either the Linux 32-bit or Linux 64-bit file, depending on your system.
  3. In your terminal, determine the name of the file you downloaded (either Sublime Text 2.0.2.tar.bz2 or Sublime Text 2.0.2x64.tar.bz2) and run

    tar jxvf "Sublime Text 2...tar.bz2"
    

    to unpack the archive and create a directory named Sublime Text 2.

  4. Run

    sudo mv "Sublime Text 2" /opt/sublime_text_2
    

    to move the directory to the proper location and rename it to something without spaces.

  5. Double-check that /usr/local/bin is in your PATH by running

    echo $PATH
    

    then create a subl shortcut by running

    sudo ln -s /opt/sublime_text_2/sublime_text /usr/local/bin/subl
    

You should now be able to start Sublime correctly from the command line.

Related Question