Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

E474: Invalid argument: diffopt+=internal,algorithm:patience on Vim 8.1 on MacOS #2

Closed
agude opened this issue Apr 21, 2020 · 2 comments
Assignees
Labels

Comments

@agude
Copy link
Owner

agude commented Apr 21, 2020

Here is the error:

Error detected while processing /Users/agude/.vimrc:
line  433:
E474: Invalid argument: diffopt+=internal,algorithm:patience
This script requires vim7.0+ with Python 3.6 support.

Here is the version info:

VIM - Vi IMproved 8.1 (2018 May 18, compiled Feb 29 2020 00:47:39)
macOS version
Included patches: 1-503, 505-680, 682-2292
Compiled by [email protected]
Normal version without GUI.  Features included (+) or not (-):
+acl               -farsi             -mouse_sysmouse    -tag_any_white
-arabic            +file_in_path      -mouse_urxvt       -tcl
+autocmd           +find_in_path      +mouse_xterm       -termguicolors
+autochdir         +float             +multi_byte        +terminal
-autoservername    +folding           +multi_lang        +terminfo
-balloon_eval      -footer            -mzscheme          +termresponse
-balloon_eval_term +fork()            +netbeans_intg     +textobjects
-browse            -gettext           +num64             +textprop
+builtin_terms     -hangul_input      +packages          +timers
+byte_offset       +iconv             +path_extra        +title
+channel           +insert_expand     -perl              -toolbar
+cindent           +job               +persistent_undo   +user_commands
-clientserver      +jumplist          +postscript        -vartabs
+clipboard         -keymap            +printer           +vertsplit
+cmdline_compl     +lambda            -profile           +virtualedit
+cmdline_hist      -langmap           +python/dyn        +visual
+cmdline_info      +libcall           -python3           +visualextra
+comments          +linebreak         +quickfix          +viminfo
-conceal           +lispindent        +reltime           +vreplace
+cryptv            +listcmds          -rightleft         +wildignore
+cscope            +localmap          +ruby/dyn          +wildmenu
+cursorbind        -lua               +scrollbind        +windows
+cursorshape       +menu              +signs             +writebackup
+dialog_con        +mksession         +smartindent       -X11
+diff              +modify_fname      -sound             -xfontset
+digraphs          +mouse             +spell             -xim
-dnd               -mouseshape        +startuptime       -xpm
-ebcdic            -mouse_dec         +statusline        -xsmp
-emacs_tags        -mouse_gpm         -sun_workshop      -xterm_clipboard
+eval              -mouse_jsbterm     +syntax            -xterm_save
+ex_extra          -mouse_netterm     +tag_binary
+extra_search      +mouse_sgr         -tag_old_static
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H   -DMACOS_X_UNIX  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc   -L/usr/local/lib -o vim        -lm -lncurses  -liconv -framework Cocoa

I believed patch-8.1.0360 was the right one to check. Perhaps not?

Originally added to Vim here: vim/vim#2732

@agude agude added the bug label Apr 21, 2020
@agude agude self-assigned this Apr 21, 2020
@chaoren
Copy link

chaoren commented May 18, 2021

Hi, found this after searching for the same issue. I'll write down my findings here for anyone else searching about this problem.

patch-8.1.0360 is indeed the right patch for has(), but the problem is that Apple actually removed xdiff while compiling a version of vim that's supposed to include the patch.

If you look at :h diffexpr, you'll see that they actually have the changes from patch-8.1.0360.
If you look at :h diffopt, you'll see that they do not have the changes from patch-8.1.0360.

This other issue I found has the same root cause:

In short: stock vim on Catalina does not support diffopt=internal even though the default options include internal.

Apple removed the internal option item from diffopt (probably while trying to remove xdiff), but didn't remove internal from the default value of diffopt.

Now why would Apple want to remove xdiff? Because of https://github.com/vim/vim/blob/master/src/xdiff/COPYING:

		  GNU LESSER GENERAL PUBLIC LICENSE
		       Version 2.1, February 1999

 Copyright (C) 1991, 1999 Free Software Foundation, Inc.
     59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 Everyone is permitted to copy and distribute verbatim copies
 of this license document, but changing it is not allowed.

What's the solution then?

I have this in my vimrc now. Since this issue is specific to the default vim distributed on Mac, I've decided to just hard code that condition. Also handles the issue of internal preventing other option items being added or removed.

if has('mac') && $VIM == '/usr/share/vim'
	set diffopt-=internal
elseif has('patch-8.1.0360')
	set diffopt+=algorithm:patience
endif

I only ran into this issue while using sudo -e, since I usually use Homebrew vim. Apparently sudo -e uses the system vim.

@agude
Copy link
Owner Author

agude commented May 19, 2021

@chaoren Thanks a ton for the research! 😄

This will fix an annoyance that has been bugging me for over a year now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants