macvim icon indicating copy to clipboard operation
macvim copied to clipboard

MacVim opens from Terminal (mvim) but does not render interface from Finder

Open dspruell opened this issue 3 years ago • 2 comments

  • macOS Big Sur 11.1
  • MacVim Custom Version 8.2.2164 (169)
VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Dec 19 2020 21:23:05)
macOS version
Included patches: 1-2164
Compiled by [email protected]
Huge version with MacVim GUI.

This is macvim: 8.2.2164,169 (auto_updates) installed as a cask from Homebrew.

When I launch MacVim using the mvim script from Terminal, it launches the app and renders a GUI window. Everything is as it should be.

But when launching from Finder (either Cmd-space and typing MacVim.app, or double clicking the app bundle from the Applications folder, the app runs; it creates an icon in the dock, it presents a menu, but it doesn't render a window for the editor. Cmd-O opens a dialog to select a file to open, but opening a file does not render an editor window for the file. The Window menu does not list any open app windows. It's running and responding appropriately, but not rendering a window when launched from Finder.

I've seen this behavior in several macOS releases now over the years. It's sporadic. When the issue occurs, it's frustrating and I move on, but at some point I switch back to the MacVim task and open a new window, and it just works as if there was never an issue.

As an experiment I backed up and removed my existing .vim/, .viminfo and .vimrc which are customized. Afterward, MacVim launched correctly (rendered windows) from Finder. I'll review settings but it's not clear to me why a customization would cause failures running from finder vs. running from start script in Terminal.

dspruell avatar Dec 31 '20 08:12 dspruell

When you are launching MacVim from the dock, your environment is different from when you run it from the terminal (where the script mvim will inherit the environmental variables from whatever shell you are using). If you have plugins that interface with the system, or use scripting language and so on, that could result in a bad interaction that maybe is causing Vim to freeze/crash in the background but unfortunately the UI doesn't show you much detail.

I think Console.app will show the relevant logs if you filter by MacVim, but I need to play around to see if that's the case.

Do you mind telling me what types of plugins you are using that could seem suspicious given what I said?

But yeah I agree some better ways to diagnose issues would be better than a silent failure/crash to the user.

ychin avatar Jan 03 '21 00:01 ychin

Thank you for reminding me about the environment. I think I identified a condition in the shell that impacts new MacVim instances running.

I run keychain (https://www.funtoo.org/Keychain) and have the following in my .bash_profile:

eval $(keychain --quiet --eval --agents ssh id_rsa)

New invocations of the shell prompt for the SSH key passphrase and block new shell instances until entered, or until an error causes keychain to exit. Until keychain adds identities to the agent, each attempt to spawn a new shell effectively blocks. It appears every attempt to open a new MacVim window also encounters this. The behavior stops when SSH key identities are added to the agent by keychain, and then new shells initialize normally; MacVim windows render without issue. The reason this has appeared to be sporadic for me is that sometimes I would open Terminal and add SSH identities before launching MacVim (no issues occur), and sometimes I would attempt to open the editor first (issues occur, and later resolved when I would open new shells).

Not quite sure if there's an issue per se, though. I can work around this by launching applications in a specific order. Should this cause MacVim windows to exhibit this behavior? Any other recommendations?

dspruell avatar Jan 06 '21 07:01 dspruell