Macvim: MacVim won't accept keyboard input

Created on 3 Jan 2018  Â·  8Comments  Â·  Source: macvim-dev/macvim

I am mystified. On my brand-new, work-issued MacBook Pro with High Sierra, I brew install macvim and then brew linkapps, and then launch /Applications/MacVim.app and the window will not accept keyboard input (I just get the system error sound for each keypress).

If I try launching mvim from the terminal, the MacVim window appears _behind_ the terminal window. When I click on it, it appears to focus, but keyboard input goes to the terminal, not to MacVim.

I am mystified. What can I do? I have never seen this behavior for any app, much less MacVim.

All 8 comments

I tried the binary snapshot first. I opened it from the finder, and it complained that the developer was unrecognized -- so I allowed it in system preferences, and then it opened fine and functioned normally. (Yay!)

Then I tried the tap with:

brew unlink macvim
brew cleanup
brew tap macvim-dev/macvim
brew install --HEAD macvim-dev/macvim/macvim

That version worked via mvim as well as clicking on the symlinked app in /Applications (yay! again!)

That will work for me for the time being. Do you want me to close this issue, or should I wait and verify that a regular release works first?

This is still broken in snapshot 144.

Specifically: this behaviour manifests when you launch MacVim via mvim from command line. If you launch it this way:

  • MacVim window will appear, but it'll be placed in the background, and won't be brought back to the front automatically
  • MacVim icon will be missing from the application switcher and Dock.
  • Even if you explicitly focus MacVim's window, it will not receive keyboard focus - any keyboard input will go to previously focused app.

None of the above will happen if you just launch MacVim via doubleclicking its application icon. There's a difference in the binary arguments, between those two launch modes:

From command line:

─┬= 00001 root /sbin/launchd
 └─┬= 13227 yacoob /Applications/MacVim.app/Contents/bin/../MacOS/Vim -f -g
   └──= 13236 yacoob /Applications/MacVim.app/Contents/MacOS/MacVim -MMNoWindow yes

Via icon doubleclick or Spotlight:

$ pstree -g3 -p 12928
─┬= 00001 root /sbin/launchd
 └─┬= 12928 yacoob /Applications/MacVim.app/Contents/MacOS/MacVim
   └──= 12929 yacoob /Applications/MacVim.app/Contents/MacOS/Vim -g -f

A brief search for MMNoWindow suggests that this is an explicit "show no window" mode, but I haven't found any recent changes around that. Maybe something else is triggering this behavior in vim launcher?

I've noticed this happening with official release downloaded from github, and for cask (which uses same dmg, if I'm not mistaken). I haven't yet tried compiling MacVim from current head, but for the moment please reopen this bug, so people can find the problem.

Thanks!

Erp, I won't be able to test a full build, as it requires full Xcode install - and I'm currently unable to get my hands on an environment equipped with that. Sorry :(

One more thing: I've verified that this is configuration independent, by launching mvim -U NONE -u NONE. It got "disabled" in the same way as I've described above.

I've just discovered that there must be some confounding factor here - I've rebooted the machine on which I've observed those problems since my last comment, and MacVim is behaving properly (window gets focus, is present in dock and switcher) when launched from command line. It still has -MMNoWindoow yes set. Can you tell me what kind of debug information can I provide you with in case I manage to get in this situation again?

This exact problem just appeared for me after a reboot. Running MacVim stable 8.1-151
I tried reinstalling, removing caches save state files, .vimrc, .gvimrc, .vim/ -- nothing worked.
Launching the application shortcut works fine. Using 'mvim' from the command line doesn't (just like is described above). It must be something in my environment. If I log in as a different user, then mvim works fine, but when I login back as my user, the problem is there again.

Apparently this has something to do with running under TMUX. The 'reattach-to-user-namespace' utility that fixes things so GUI apps can be launched from the command line within tmux apparently quit working correctly for 'mvim'. If I run 'mvim' from a non-tmux terminal window, then it works just fine. I seem to recall that 'reattach-to-user-namespace' was updated a while back, and I probably hadn't rebooted since that change, so I may have been using an older version of it that didn't have the problem?

The workaround is to start MacVim via the app shortcut, or from a non-TMUX terminal window, then leave it running. Once it starts correctly, the 'mvim' command works fine as long as the original MacVim keeps running.

Was this page helpful?
0 / 5 - 0 ratings