Hey guys, I use textmate a LOT on OS-X Leopard 1.5.6 as my main CLI text editor via .bash_profile and I edit a lot of files from my computer with textmate. But I have issues with permissions when trying to "mate" files which my user does not have permissions to read. Even if I "sudo mate". Textmate pretends it opened this file but the file is empty, and when you save it it will ask for administrative privileges to do so.
Steps to reproduce: $ echo "this is a test" > testfile $ sudo chown root testfile $ sudo chmod 700 testfile $ sudo mate testfile
Result: Textmate opens a window called "testfile" but shows nothing in this file. If you edit this file and hit save, a window pops up which asks for your credentials to save over this file.
Expected result: #1 - preferred: uses the above "sudo" permission to pass into and/or launch textmate under for editing of this file. Which would allow opening and saving of this file without requiring re-entry of credentials (annoying). #2 - secondary/temporary alternative: upon failing opening a file (like what's happening here) asking the user for credentials which would allow opening the file. If this fails, do not open the window because clearly, you don't have permissions for this file anyway, you shouldn't have an editor window open for it. If their credentials succeed, use the "open" permission for saving also.
Anyone have a workaround for this, or any ideas? The contact area said to post here first. I googled a bit and didn't find anything so I'm starting here.
Cheers!
- Andrew
On 23 Apr 2009, at 00:01, Andrew Farley wrote:
[...] Even if I "sudo mate". Textmate pretends it opened this file but the file is empty, and when you save it it will ask for administrative privileges to do so.
TextMate only supports saving as root, not opening files as root.
The ‘mate’ shell command is a simple helper app which effectively does: “open -a TextMate «file»” resulting in TextMate receiving an “open this file” message, so running the messanger (mate) as root (sudo) does not help (as TextMate is already running as your current user, and it shouldn’t be attempted to run TextMate as root, as many things rely on $HOME/Library/… plus all the frameworks pulled in).
I am however aware of the desire to use ‘sudo mate’ and have some proof-of-concept code that works, although it’s not ideal, but I do expect these things to be fully addressed in the future.
[...] Anyone have a workaround for this, or any ideas?
Unless you have very good reason not to make the files readable by your normal user, I’d say you should simply make them readable by your current user. You can still make them only root-writable, as TM will handle that.
Alternatively you can do a wrapper for mate that handles these things (i.e. letting TM edit a temporary file, either using “mate -w” or via pipes).
On Thu, Apr 23, 2009 at 4:01 PM, Allan Odgaard mailinglist@textmate.org wrote:
On 23 Apr 2009, at 00:01, Andrew Farley wrote:
[...] Even if I "sudo mate". Textmate pretends it opened this file but the file is empty, and when you save it it will ask for administrative privileges to do so.
TextMate only supports saving as root, not opening files as root.
,,,
I am however aware of the desire to use ‘sudo mate’ and have some proof-of-concept code that works, although it’s not ideal, but I do expect these things to be fully addressed in the future.
Actually, I have to put in a vote for leaving things as they are. I actually prefer getting prompted when I SAVE a file which I don't normally have permissions.
Now if Textmate worked like, say vim, and refused to let you override when you forgot to run it as root, then I'd want to at least be able to run it as root, but having TM run under my user permissions and only doing the equivalent of a sudo when I've told it in order to save the file seems much safer to me.
On 24 Apr 2009, at 04:25, Rick DeNatale wrote:
[..] I am however aware of the desire to use ‘sudo mate’ [...]
Actually, I have to put in a vote for leaving things as they are. [...]
Running ‘sudo mate «file»’ will only act as root for that particular file (when loading/saving).