Problem launching console version

60 views
Skip to first unread message

Robert Hicks

unread,
Dec 5, 2007, 2:53:41 PM12/5/07
to vim...@googlegroups.com
If I do: /Applications/MacVim/MacVim.app/Contents/MacOS/Vim

Vim opens fine in Terminal.app...

If I create a link:

sudo ln -s /Applications/MacVim/MacVim.app/Contents/MacOS/Vim vim

I get:

[robert]$ vim2
2007-12-05 14:49:21.687 vim2[14599] WARNING: Could not locate Colors.plist.
2007-12-05 14:49:21.687 vim2[14599] WARNING: Could not locate
SystemColors.plist.
E254: Cannot allocate color Red
E254: Cannot allocate color White
E254: Cannot allocate color Blue
E254: Cannot allocate color Red
E254: Cannot allocate color Grey
E254: Cannot allocate color Blue
E254: Cannot allocate color Brown
E254: Cannot allocate color SeaGreen
E254: Cannot allocate color SeaGreen
E254: Cannot allocate color Yellow
E254: Cannot allocate color Red
E254: Cannot allocate color Blue
E254: Cannot allocate color Magenta
E254: Cannot allocate color DarkCyan
E254: Cannot allocate color LightMagenta
E254: Cannot allocate color Grey
E254: Cannot allocate color Blue
E254: Cannot allocate color Magenta
E254: Cannot allocate color Red
E254: Cannot allocate color Yellow
E254: Cannot allocate color Black
E254: Cannot allocate color LightGrey
E254: Cannot allocate color DarkBlue
E254: Cannot allocate color Grey
E254: Cannot allocate color DarkBlue
E254: Cannot allocate color Grey
E254: Cannot allocate color DarkBlue
E254: Cannot allocate color LightGrey
E254: Cannot allocate color LightBlue
E254: Cannot allocate color LightMagenta
E254: Cannot allocate color Blue
E254: Cannot allocate color LightCyan
E254: Cannot allocate color LightGrey
E254: Cannot allocate color Grey90
E254: Cannot allocate color Grey90
E254: Cannot allocate color Cyan
Error detected while processing /Users/robert/.vimrc:
line 12:
E484: Can't open file /usr/local/bin/vim/runtime/syntax/syntax.vim
Press ENTER or type command to continue

and then Vim opens up...

The E484 error is correct because that path is bogus.

Robert

Nico Weber

unread,
Dec 5, 2007, 4:17:15 PM12/5/07
to vim...@googlegroups.com
> sudo ln -s /Applications/MacVim/MacVim.app/Contents/MacOS/Vim vim
>
> I get:
>
> [robert]$ vim2
> 2007-12-05 14:49:21.687 vim2[14599] WARNING: Could not locate
> Colors.plist.
> 2007-12-05 14:49:21.687 vim2[14599] WARNING: Could not locate
> SystemColors.plist.


As a workaround, doing `alias vim='/Applications/MacVim/MacVim.App/
Contents/MacOS/Vim` should work.

Nico

björn

unread,
Dec 5, 2007, 4:20:40 PM12/5/07
to vim...@googlegroups.com
On 05/12/2007, Robert Hicks <sig...@gmail.com> wrote:
>
> If I do: /Applications/MacVim/MacVim.app/Contents/MacOS/Vim
>
> Vim opens fine in Terminal.app...
>
> If I create a link:
>
> sudo ln -s /Applications/MacVim/MacVim.app/Contents/MacOS/Vim vim
>
> I get:
>
> [robert]$ vim2
> 2007-12-05 14:49:21.687 vim2[14599] WARNING: Could not locate Colors.plist.
> 2007-12-05 14:49:21.687 vim2[14599] WARNING: Could not locate
> SystemColors.plist.
> E254: Cannot allocate color Red
- snip -

I have noticed this myself. The problem is that NSBundle fails to
find files in the app bundle when you create a symlink. My guess is
that it looks at argv[0] and uses the path assuming it points inside
the bundle, which obviously isn't the case when you symlink.

I don't really know how to fix this actually...does anybody else know
a fail-safe way to get the app bundle inside a Cocoa app? To be
clear: [NSBundle mainBundle] seems to fail when you symlink directly
to the binary inside Contents/MacOS.


/Björn

Robert Hicks

unread,
Dec 5, 2007, 6:37:04 PM12/5/07
to vim...@googlegroups.com

I do the Vim.app the same way and it works with symlinks.

Robert

Robert Hicks

unread,
Dec 5, 2007, 6:39:04 PM12/5/07
to vim...@googlegroups.com

That does work. Thanks for that.

Robert

Ben Schmidt

unread,
Dec 5, 2007, 7:09:07 PM12/5/07
to vim...@googlegroups.com
> I do the Vim.app the same way and it works with symlinks.

Yeah. It is a more typical Vim installation that stores its runtime files outside
the bundle, IIRC, and thus plays nicer with Unix tricks like symlinking. MacVim is
more Mac-like and needs a bit more TLC with things like this.

Ben.

Send instant messages to your online friends http://au.messenger.yahoo.com

Robert Hicks

unread,
Dec 6, 2007, 8:15:49 AM12/6/07
to vim...@googlegroups.com
Ben Schmidt wrote:
>> I do the Vim.app the same way and it works with symlinks.
>
> Yeah. It is a more typical Vim installation that stores its runtime files outside
> the bundle, IIRC, and thus plays nicer with Unix tricks like symlinking. MacVim is
> more Mac-like and needs a bit more TLC with things like this.

I *thought* it stored its runtime files in the Vim.app as well?

Robert

björn

unread,
Dec 6, 2007, 4:29:30 PM12/6/07
to vim...@googlegroups.com

It does, but unlike MacVim it does not rely on NSBundle for getting
the path to the runtime files.

/Björn

Nico Weber

unread,
Dec 7, 2007, 10:14:00 AM12/7/07
to vim...@googlegroups.com
> I have noticed this myself. The problem is that NSBundle fails to
> find files in the app bundle when you create a symlink. My guess is
> that it looks at argv[0] and uses the path assuming it points inside
> the bundle, which obviously isn't the case when you symlink.
>
> I don't really know how to fix this actually...does anybody else know
> a fail-safe way to get the app bundle inside a Cocoa app? To be
> clear: [NSBundle mainBundle] seems to fail when you symlink directly
> to the binary inside Contents/MacOS.

Here's what carbon vim does in its gui_mch_prepare():

#ifdef USE_EXE_NAME
# ifndef USE_FIND_BUNDLE_PATH
HGetVol(volName, &applVRefNum, &applDirID);
/* TN2015: mention a possible bad VRefNum */
FSMakeFSSpec(applVRefNum, applDirID, "\p", &applDir);
# else
/* OSErr GetApplicationBundleFSSpec(FSSpecPtr theFSSpecPtr)
* of TN2015
* This technic remove the ../Contents/MacOS/etc part
*/
(void)GetCurrentProcess(&psn);
/* if (err != noErr) return err; */

(void)GetProcessBundleLocation(&psn, &applFSRef);
/* if (err != noErr) return err; */

(void)FSGetCatalogInfo(&applFSRef, kFSCatInfoNone, NULL,
NULL, &applDir, NULL);

/* This technic return NIL when we disallow_gui */
# endif
exe_name = FullPathFromFSSpec_save(applDir);
#endif


The mentioned technical note looks interesting too. Perhaps this works
better than [NSBundle mainBundle]?

Nico

Nico Weber

unread,
Dec 7, 2007, 10:40:41 AM12/7/07
to vim...@googlegroups.com
>> I don't really know how to fix this actually...does anybody else know
>> a fail-safe way to get the app bundle inside a Cocoa app? To be
>> clear: [NSBundle mainBundle] seems to fail when you symlink directly
>> to the binary inside Contents/MacOS.
>
> Here's what carbon vim does in its gui_mch_prepare():

Then again, all other applications I tried don't support this either.
IIUC, at least some parts of Cocoa rely on [NSBundle mainBundle] (to
find Info.plist for example), so I guess it's not really possible to
fix this.

But we could at least display a dialog along the lines of "Some error
occurred. This happens if you symlink directly to the binary which
cocoa doesn't support. Create an alias or a shell script instead." if
[NSBundle mainBundle] returns nil.

Nico

björn

unread,
Dec 9, 2007, 1:12:26 PM12/9/07
to vim...@googlegroups.com

Agreed.

/Björn

Reply all
Reply to author
Forward
0 new messages