Sublime Forum

Subl does not work via sudo or as root under OS 10.9.1

#1

1st I try it via sudo

brandon-mba:~ brandon$ sudo subl Password: Unable to find Sublime Text
2nd I become root and try it via the softlink

brandon-mba:~ brandon$ sudo su - brandon-mba:~ root# subl Unable to find Sublime Text brandon-mba:~ root# which subl /usr/local/bin/subl brandon-mba:~ root# /usr/local/bin/subl Unable to find Sublime Text

Then I try it via the file, skipping the softlink

brandon-mba:~ root# ls -l /usr/local/bin/subl lrwxr-xr-x 1 brandon admin 62 Jan 10 09:56 /usr/local/bin/subl -> /Applications/Sublime Text.app/Contents/SharedSupport/bin/subl brandon-mba:~ root# /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl Unable to find Sublime Text

Any suggestions?

0 Likes

Cannot start sublime under sudo
#2

Unfortunatly, even if you get it to find the app, it may run into authentication problems as soon as you try to save a file elevated root privs :frowning: see this other thread

0 Likes

#3

I’m having the exact same problem with Sublime Text 3 in Mac OS 10.9.

(This used to work in ST2.)

0 Likes

#4

Well, it’s not so often that you need to work as root under OS X, and usually, that’s something reserved for knowledgeable people, so I wonder what is beyond the reach of vi ?

Not wanting to start a flamewar sublime vs vim, just curious.

0 Likes

#5

[quote=“cbueche”]Well, it’s not so often that you need to work as root under OS X, and usually, that’s something reserved for knowledgeable people, so I wonder what is beyond the reach of vi ?

Not wanting to start a flamewar sublime vs vim, just curious.[/quote]

Well, this thread is not at all about personal editor preference, but about a new bug (that should probably be fixed) in Sublime Text.

0 Likes

#6

It seems when running in sudo, the subl script is looking for Sublime Text at /Applications/Sublime Text 3.app.

In order to fix this, you must start without Sublime Text 3 installed. If you already have Sublime Text installed, it has to be removed. After you download and drop into the Applications folder, rename to to Sublime Text 3.app. Then you can follow the normal procedure of linking subl to a local bin path: ln -s /Applications/Sublime\ Text\ 3.app/Contents/SharedSupport/bin/subl /usr/local/bin/subl

Hope this helps!

0 Likes

#7

Just tried jgornick’s trick. Didn’t work for me. Anyone else know how to get pass this annoying error?

0 Likes

#8

I’ve added a little function called e to my .bashrc like this:

e() {
  [ $SUDO_USER ] && su -u "$SUDO_USER" subl || subl
}
0 Likes