Sublime Forum

Unable to save /etc/hosts

#1

I ran sudo subl /etc/hosts command from my Mac and after hitting save I got “Unable to save /etc/hosts” error message.

MacVim happily saved it for me.

What’s wrong?

Thanks.

0 Likes

#2

That’s because the subl command ends up launching Sublime Text 2 under your user id instead of as root. The only way to do what you want is to do:

sudo /Applications/Sublime\ Text\ 2.app/Contents/MacOS/Sublime\ Text\ 2

Note that this will tie up that terminal session until ST2 quits, and that it will be reading prefs from /var/root/Library/Application Support/Sublime Text 2, not your home directory.

0 Likes

Cannot start sublime under sudo
#3

I do exactly the same with TextMate and MacVim and they work properly without the need of what you mentioned. I only add sudo when the file is not in my home directory. I don’t even have to add sudo with TextMate, it asks me for the password when I hit save.

0 Likes

#4

I’m just telling you how it is, don’t blame me. The fact it isn’t necessary in TextMate and MacVim means they do a better job of dealing with it than ST2. Submit a feature request for ST2.

0 Likes

#5

Implemented in build 2147, a lot of people were asking for this.

0 Likes

#6

Great, thank you for the update.

0 Likes