macvim-dev / macvim

Vim - the text editor - for macOS
https://macvim.org
Vim License
7.47k stars 680 forks source link

mvim -v (installed via Homebrew): "plugin requires [mac]Vim to be compiled with +python" #1292

Closed johnnyutahh closed 1 year ago

johnnyutahh commented 1 year ago

Steps to reproduce

https://gist.githubusercontent.com/johnnyutahh/9cbeac8e23c2052c0b7352e3b9b09cdc/raw

Expected behaviour

No error when running mvim -v

Version of Vim and architecture

macvim 9.0.0065 installed via Homebrew

Environment

see sw_vers output in: https://gist.githubusercontent.com/johnnyutahh/9cbeac8e23c2052c0b7352e3b9b09cdc/raw

How MacVim was installed

homebrew: brew install -s macvim

Logs and stack traces

No response

Vim configuration where issue is reproducable

No response

Issue has been tested with given configuration

Issue has been tested with no configuration

Other conditions

johnnyutahh commented 1 year ago

Is there a way to install a mvim (commandline) that is the same version as MacVim.app GUI... possibly as a menucommand from said GUI? I have looked but not yet found a way to do that. Not sure it would solve this problem, anyway, but would be nice.

I run mvim -v from cmdline to open an existing-open-from-GUI files--if such a GUI file is open, there's an app context switch to to the GUI from the iTerm2/Terminal command (I suppose I'm not telling anyone anything new here).

johnnyutahh commented 1 year ago

Also: this scenario worked without the +python-needed error on a previous macOS install (same version of macOS, different MacBook, both MacBook's Intel-based) with the exact-same vim-plugin configuration.

Now that I rebuilt/migrated my Homebrew environment on the new MacBook, the above error is (inexplicably) happening. I then tried a macvim brew uninstall, cleanup, then reinstall with -s... and same error.

eirnym commented 1 year ago

Hey,

This plugin is a quite old one. It requires Python 2 to work properly out of the box and was never updated to support Python 3.

Since macOS Monterey (maybe a little bit earlier) python 2 is not shipped with macOS or Xcode.

+python is Python 2, +python3 is Python 3.

I have MacVim from GitHub releases and it's compiled with +python/dyn which means, that it's supported when python 2 is installed.

After python 2 is installed, it's required to install all dependencies this plugin requires to work including "system" ones (which come with macOS preinstalled)

Alternatively, you can try to upgrade the plugin or search for a replacement

PS: please, also note, that it's impossible to use both python 2 and python 3 in the same Vim process

ychin commented 1 year ago

@johnnyutahh This is really a Homebrew problem. If you look at their formula for MacVim, they don't include Python 2 in their dependency, and only have Python 3: https://github.com/Homebrew/homebrew-core/blob/master/Formula/macvim.rb. So if you want Python 2 support you should bring it up with them on https://github.com/Homebrew/homebrew-core. That said, Python 2 is basically dead and completely obsolete. Is there a way you can find an updated plugin that uses Python 3? At this point I don't think anyone is going to agree to add Python 2 support back in. I looked at the notmuch-abook plugin and it does seem like it stopped being updated 7 years ago, which explains the lack of Python 3 migration support. Honestly I do wish Python 3 did a better job with backwards compatibility, but I digress.

If you want Python 2 support in MacVim, easiest solution is to grab our binary release from https://github.com/macvim-dev/macvim/releases. This is actually controlled by us (instead of Homebrew), and for now we still build with Python 2 support. You just need to install Python 2 from Homebrew as well (since macOS doesn't come with it anymore) and it would work. You just need to use the GUI to update MacVim instead of Homebrew.

Otherwise you can build MacVim yourself from source and you can do whatever you want including Python 2 support.

johnnyutahh commented 1 year ago

Thanks all, very helpful!

The following line I just added to my ~/.bashrc appears to (initially) solve this problem (along with brew uninstall mvim).

PATH="/Applications/MacVim.app/Contents/bin:$PATH"

Is this the proper way to configure for github-based MacVim.app command-line usage? And if so, might it be beneficial to better highlight in docs somewhere? (I stumbled upon this in lieu of docs)

eirnym commented 1 year ago

Your way to use official mvim and aliases is a good and preferred way to run MacVim.

For a few reasons I have quite a script in my shell's rc file to run proper combinations of flags to make sure that everything is correct. I have for a normal user without ssh:

As far as I remember -g openes graphical Vim and -f forces to wait for specific Vim process to finish (useful for git and few other commands waiting for edit).Please consult with these and additional flags in MacVim documentation.

ychin commented 1 year ago

@johnnyutahh Yeah that's the way you set the PATH. It is documented (:h macvim-PATH or :h mvim) but I guess the help doc is just kind of large at this point so it's hard to find.

eirnym commented 1 year ago

@ychin yes, doc is already quite long to read in the single document. It's better to split it up

Also it's better to inform a user how to use it by duplicating documentation in other way. Will wiki do a thing? Probably yes.

ychin commented 1 year ago

Yeah I need to fix up the wiki/readme to have better build instructions / etc, since that's where usually people go for first "how do I get/install/run/build this" rather than the help. I think the help doc is a little long but for now I think it's fine to be one doc as long as the sections and organizations make sense. It should serve more as a reference though.

ychin commented 1 year ago

Just closing this since it was resolved by downloading the pre-build binary instead of Homebrew.