Homebrew-core: vim8.1 build doesn't support python

Created on 21 May 2018  Â·  6Comments  Â·  Source: Homebrew/homebrew-core

brew install vim command, which will install vim8.1, when open vim and input :version, here's the detail: (see the -python and +python3)

VIM - Vi IMproved 8.1 (2018 May 17, compiled May 18 2018 13:18:41)
macOS version
Included patches: 1
Compiled by Homebrew
Huge version without GUI.  Features included (+) or not (-):
+acl               +cmdline_compl     -ebcdic            -hangul_input      -lua               +mouse_xterm       [-python]            +tag_binary        +vertsplit         -xpm
+arabic            +cmdline_hist      +emacs_tags        +iconv             +menu              +multi_byte        [+python3]           +tag_old_static    +virtualedit       -xsmp
+autocmd           +cmdline_info      +eval              +insert_expand     +mksession         +multi_lang        +quickfix          -tag_any_white     +visual            -xterm_clipboard
-autoservername    +comments          +ex_extra          +job               +modify_fname      -mzscheme          +reltime           -tcl               +visualextra       -xterm_save
-balloon_eval      +conceal           +extra_search      +jumplist          +mouse             +netbeans_intg     +rightleft         +termguicolors     +viminfo
+balloon_eval_term +cryptv            +farsi             +keymap            -mouseshape        +num64             +ruby              +terminal          +vreplace
-browse            +cscope            +file_in_path      +lambda            +mouse_dec         +packages          +scrollbind        +terminfo          +wildignore
++builtin_terms    +cursorbind        +find_in_path      +langmap           -mouse_gpm         +path_extra        +signs             +termresponse      +wildmenu
+byte_offset       +cursorshape       +float             +libcall           -mouse_jsbterm     +perl              +smartindent       +textobjects       +windows
+channel           +dialog_con        +folding           +linebreak         +mouse_netterm     +persistent_undo   +startuptime       +timers            +writebackup
+cindent           +diff              -footer            +lispindent        +mouse_sgr         +postscript        +statusline        +title             -X11
-clientserver      +digraphs          +fork()            +listcmds          -mouse_sysmouse    +printer           -sun_workshop      -toolbar           -xfontset
+clipboard         -dnd               -gettext           +localmap          +mouse_urxvt       +profile           +syntax            +user_commands     -xim

Options like brew install vim --enable-pythoninterp --enable-python3interp doesn't work by saying

Warning: vim: this formula has no --enable-python3interp option so it will be ignored!
Warning: vim: this formula has no --enable-pythoninterp option so it will be ignored!

But the auto/configure file says it has...
However, if it doesn't have +python, ycm and clang_complete will not work when I open a ***.cpp file as below:

Error detected while processing function <SNR>15_ClangCompleteInit[146]..<SNR>15_initClangCompletePython:
line    2:
clang_complete: No python support available.
line    3:
Cannot use clang library
line    4:
Compile vim with python support to use libclang
Press ENTER or type command to continue

How to fix it? Maybe modify vim.rb ? Thx.

outdated

Most helpful comment

Thank you all. There's no problem with the build, for no reason my /usr/bin/vim didn't link to the homebrew vim. :( I'll close the issue.

All 6 comments

@wind2412:

     Per the following lines in Formula/vim.rb, Homebrew builds vim with Python 3.x support by default and with Python 2.x support instead by request:

â‹®
  LANGUAGES_OPTIONAL = %w[lua python@2 tcl].freeze
  LANGUAGES_DEFAULT  = %w[python].freeze

  option "with-python@2", "Build vim with python@2 instead of python[3] support"
  LANGUAGES_OPTIONAL.each do |language|
    option "with-#{language}", "Build vim with #{language} support"
  end
  LANGUAGES_DEFAULT.each do |language|
    option "without-#{language}", "Build vim without #{language} support"
  end
â‹®
  def install
    â‹®
    (LANGUAGES_OPTIONAL + LANGUAGES_DEFAULT).each do |language|
      feature = { "python" => "python3", "python@2" => "python" }
      if build.with? language
        opts << "--enable-#{feature.fetch(language, language)}interp"
      end
    end

    if opts.include?("--enable-pythoninterp") && opts.include?("--enable-python3interp")
      # only compile with either python or python@2 support, but not both
      # (if vim74 is compiled with +python3/dyn, the Python[3] library lookup segfaults
      # in other words, a command like ":py3 import sys" leads to a SEGV)
      opts -= %w[--enable-python3interp]
    end

    system "./configure", "--prefix=#{HOMEBREW_PREFIX}",
                          "--mandir=#{man}",
                          "--enable-multibyte",
                          "--with-tlib=ncurses",
                          "--enable-cscope",
                          "--enable-terminal",
                          "--with-compiledby=Homebrew",
                          *opts
â‹®
  end
â‹®

Specifically, this Homebrew vim formula code makes it so that:

  • If no Python-related options are passed to brew install vim, then brewautomatically uses the vim formula's --with-python option by default and thence proceeds to handle that option by passing vim's configure script its --enable-python3interp option.
  • If you pass brew install vim the --with-python@2 option, then brew passes vim's configure script its --enable-pythoninterp option instead.

As such, this means Homebrew cannot currently install a copy of vim built with support for both Python 2.x and Python 3.x at the same time. In general, one cannot assume that Homebrew will pass build scripts their options through verbatim; formula options are typically specified as wrappers for build flags. Note also that the in-source comment which I quoted above states that an executable so constructed crashes at run-time once built, at least since the last time any contributors checked, hence your initial observation in filing this issue. You're likely welcome to try fixing this (and removing the relevant comment if/when it no longer applies,) of course.

However, when I pass --with-python@2, it seems things doesn't happen...

> brew reinstall vim --with-python@2                                                                  09:05:08
==> Reinstalling vim --with-python@2
==> Downloading https://github.com/vim/vim/archive/v8.1.0001.tar.gz
Already downloaded: /Users/***/Library/Caches/Homebrew/vim-8.1.0001.tar.gz
==> ./configure --prefix=/usr/local --mandir=/usr/local/Cellar/vim/8.1.0001/share/man --enable-multibyte --with-tlib=ncurses --enable-cscope --enable-terminal --with-compiledby=Homebrew --enable-perlinter     
[no `--enable-pythoninterp` at all... So the result is the same as no `--with-python@2`, also `-python +python3`...]

@wind2412:

     brew reinstall is…a bit _odd_, to say the least: it…doesn't _quite_ handle options in the most intuitive way in that it may or may not honor the options you pass it depending on the obscure outcome of some…rather _obtuse_ logic, if I may say so. In particular, the command:

  • handles options that you originally installed a formula with as if you've passed them even if you didn't.
  • might ignore some options you _do_ pass it if you didn't initially install the formula to which you want to apply those options with them enabled, though my memory on this is a bit less precise.

Performing a 'brew uninstall' followed by a 'brew install' _does_ work, however, even though brew reinstall appears to be treating cached options somewhat 'stickily,' so one can do that to purge the option cache involved here correctly. (The reason there's an option cache in the first place is for brew upgrade.) I've seen (and even been a _part_ of!) the confusion (and sometimes even minor mayhem, so _please_ take that with at least a grain of salt!) resulting from similar implementation-user behavior-expectation mismatches before (cf. Homebrew/brew#1699, Homebrew/brew#1656, and probably some other, more applicable ones I'm forgetting and/or can't find at the moment…)

@RandomDSdevel
Still doesn't work :(
The option is still not in the configure this time...

> brew uninstall vim
brew install vim Uninstalling /usr/local/Cellar/vim/8.1.0001... (1,432 files, 23.3MB)

> brew install vim --with-python@2
Updating Homebrew...
==> Downloading https://github.com/vim/vim/archive/v8.1.0001.tar.gz
Already downloaded: /Users/zhengxiaolin/Library/Caches/Homebrew/vim-8.1.0001.tar.gz
==> ./configure --prefix=/usr/local --mandir=/usr/local/Cellar/vim/8.1.0001/share/man --enable-multibyte --with-tlib=ncurses --enable-cscope --enable-terminal --with-compiledby=Homebrew --enable-perlinter  (still no the option `--enable-pythoninterp` QAQ)
......

Care to try brew update-reset, followed by a brew update, and lastly post the output of brew --config. This is to make sure everything is up to date, and you have the correct version.

Also, the output of brew doctor may help.

Thank you all. There's no problem with the build, for no reason my /usr/bin/vim didn't link to the homebrew vim. :( I'll close the issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dredmorbius picture dredmorbius  Â·  3Comments

ghostbar picture ghostbar  Â·  4Comments

jyutzler picture jyutzler  Â·  4Comments

ghost picture ghost  Â·  3Comments

kiendang picture kiendang  Â·  3Comments