ImageMagick "display" and "convert" fail with a Visual C++ runtime error

Brian Dessent
Fri Apr 20 06:26:00 GMT 2007

Dmitry Golovaty wrote:

> Thanks - the culprit is the MATLAB entry
> /cygdrive/c/Program Files/MATLAB/R2007a/bin/win32
> in the path; removing it fixes the problem ... is there way to pluck
> it out automatically (e.g. in .bashrc) when the path is imported from
> Windows at Cygwin start-up? Thanks again and sorry for starting
> another thread - I did not subscribe in time to get the original
> message.


Well, there are a number of ways you could handle this.  The first one I
would try is just removing the offending directory from the PATH
alltogether and see if Matlab still works.  A lot of programs like to
add themselves to the PATH so that you can easily run them from a
Command Prompt but they still work fine without actually being in the
PATH if you launch them from a shortcut or whatnot.

If you just want to remove the entry in your shell startup files you
could try something like:

PATH=${PATH/\/cygdrive\/c\/Program Files\/MATLAB\/R2007a\/bin\/win32:/}


- uses a shell-builtin, so there's no overhead during shell startup for
having to run anything external


- very ugly on account of having to escape every / in the pattern.

- bash-specific, so it should only go in .bashrc, not rcfiles that might
be shared by other shells such as .profile or /etc/profile.

- won't work if the directory to be removed is the last in PATH, as it
requires matching the trailing ':' so as not to leave a "::" sequence
anywhere (which actually means "put . in the PATH" which you probably
don't want.)

An alternative would be something that uses a tool like sed, awk, or
perl to do the change, such as:

PATH=$(echo $PATH | perl -F: -lane \
   'print join(":",grep{!m,MATLAB/R2007a/bin/win32,i} @F)')


- should work with any shell

- directory to remove is a regular expression, so you can specify a
partial string to match, and use of ',' as delimiter means you don't
have to quote slashes

- splitting the PATH on ':' and treating it as a list means you don't
have to worry about matching ':'s or where in the string the directory
might occur


- Slower shell startup.


Unsubscribe info:
Problem reports:

More information about the Cygwin mailing list