MP_EDITOR doesn't work

Ryan Schmidt ryandesign at
Thu Apr 6 00:35:27 UTC 2017

> On Apr 5, 2017, at 16:27, Lenore Horner <LenoreHorner at> wrote:
>> On Apr 5, 2017, at 16:12, Rainer Müller <raimue at> wrote:
>> On 2017-04-05 21:54, db wrote:
>>> On 4 Apr 2017, at 11:21, db <iamsudo at> wrote:
>>>> On 4 Apr 2017, at 11:18, Rainer Müller <raimue at> wrote:
>>>>> How did you test this? This works fine for me:
>>>>> $ export MP_EDITOR=less
>>>>> $ port edit zlib
>>>> export VISUAL=/opt/local/bin/vim     works
>>>> export MP_EDITOR=/opt/local/bin/vim  doesn't
>>> Could you please try it with an editor?
>> It works for me. I cannot reproduce the problem you have.
>> Rainer
> For me (MacOS 10.12.3, latest MacPorts, .profile as the relevant file to edit) 
> $ export MP_EDITOR=/usr/bin/nano
> works.  However, following, 
> $ export MP_EDITOR=/usr/bin/edit
> to use TextWrangler (yes, I have it installed) fails with “Error: unable to invoke editor /usr/bin/edit: couldn't execute "/usr/bin/edit": no such file or directory”.  I tried 
> $ export MP_EDITOR=/Applications/
> but that fails with “Error: unable to invoke editor /Applications/ couldn't execute "/Applications/": permission denied” when I do 
> $ port edit texlive-xetex 
> and puts me in vim if I prepend sudo to the command.  (Oh, never mind.  I forgot I had the app store version and never installed the command line tools. Now 
> $ export MP_EDITOR=/usr/local/bin/edit 
> (note the correction to
> works.)  
> I haven’t installed any editors through macports so I can’t check the /opt path, but at least stuff in /usr works as expected.  (And thanks to poking at this, I now know two things I didn’t know before I started down this rabbit hole.)

Did you notice that as of El Capitan, OS X includes a feature called System Integrity Protection which prevents third parties from modifying the contents of system directories, such as /usr/bin, and for that reason the TextWrangler helpers are no longer installed to that location? They're now available inside the TextWrangler application bundle at /Applications/

`edit` also doesn't work like `vi` in its default mode, in that it does not wait for the document to be closed before exiting. This can be confusing for some tools that expect the editor to wait. On my system, I define the EDITOR variable like this in my bash startup script:


And then is a short shell script in a directory in my PATH which contains:

/Applications/ +1 --wait --resume "$@"

This tells TextWrangler to open, select the first line of the file, wait until the file is closed before exiting, and when exiting, return to the program that caused TextWrangler to open (e.g. Terminal).

More information about the macports-users mailing list