Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Bug#1007007: vim: defaults.vim items should not override those in vimrc.local and home/.vimrc

220 views
Skip to first unread message

Otheus

unread,
Mar 10, 2022, 9:00:04 AM3/10/22
to
Package: vim
Version: 2:8.1.0875-5
Severity: important

Dear Maintainer,

*** Reporter, please consider answering these questions, where appropriate ***

The load-order indicated by :version

Note: $VIM/vimrc is /usr/share/vim/vimrc which is a soft-link to /etc/vim/vimrc.

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"

This is a generalization of https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=864074
That bug report complains rightly about the behavior mentioned in patch 7.4.2111 which
loads defaults.vim if no .vimrc is found. However, it loads this even if
/etc/vim/vimrc *is* found. A new method has been proposed, but the ticket is still open:
https://github.com/vim/vim/issues/2917

The "defaults file" really makes no sense here. Defaults implies a default configuration --
items that are set which are only set if not previously set. To load defaults after
/etc/vimrc and $HOME/.vimrc etc makes absolutely no sense. The vim devs know this, but for
some hilarious reason are afraid reverting to the long-standing behavior will
break things for new users *facepalm* since that patch release.

Expected behavior can be achieved by (solution 1) the following at the top
of /etc/vim/vimrc (suggested by "cheater" in the bug 2042 thread ref'd below):

:if ! filereadable(expand('~/.vimrc')) && ! filereadable(expand('~/.vim/vimrc'))
: source $VIMRUNTIME/defaults.vim
: let skip_defaults_vim=1
:endif

This ensures the defaults are loaded as before, but can be overridden in
/etc/vim/vimrc. However, it also checks to make sure that individuals with
a .vimrc file of their own will NOT read the defaults file, as is current
behavior.


Solution 2 is as follows:

1. Copy the contents of defaults.vim to /etc/vim/defaults.vim.
2. Truncate /usr/share/vim/.../defaults.vim. Make it a 0-length file.
3. in /etc/vim/vimrc, source /etc/vim/defaults.vim file as above:

:if ! filereadable(expand('~/.vimrc')) && ! filereadable(expand('~/.vim/vimrc'))
: source /etc/vim/defaults.vim
:endif

The benefit of this solution is that admins can modify default.vim.

Solution 3 is to reverse-patch vim with the 7.4.2111 patch. Users who want the
newer features will need to explicitly load them, as has always been the case
before the patch.

For more reading on this topic, see the thread at
https://github.com/vim/vim/issues/2042 should be helpful. Long thread but insightful.

*** End of the template - remove these template lines ***


-- Package-specific info:

--- real paths of main Vim binaries ---
/usr/bin/vi is /usr/bin/vim.basic
/usr/bin/vim is /usr/bin/vim.basic

-- System Information:
Debian Release: 10.11
APT prefers oldstable-updates
APT policy: (500, 'oldstable-updates'), (500, 'oldstable')
Architecture: amd64 (x86_64)

Kernel: Linux 4.19.0-18-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages vim depends on:
ii libacl1 2.2.53-4
ii libc6 2.28-10
ii libgpm2 1.20.7-5
ii libselinux1 2.8-1+b1
ii libtinfo6 6.1+20181013-2+deb10u2
ii vim-common 2:8.1.0875-5
ii vim-runtime 2:8.1.0875-5

vim recommends no packages.

Versions of packages vim suggests:
pn ctags <none>
pn vim-doc <none>
pn vim-scripts <none>

-- no debconf information

Shelling, Otheus

unread,
Mar 13, 2022, 7:40:03 PM3/13/22
to
Hello James,

I am disappointed in your dismissal of these two tickets. Allow me to make the case why you should reconsider. I will point out that firstly, it actually is the responsibility of Debian's package-maintainer to make this change, and secondly, that my proposed solution will not interfere with most of the user base, while certainly enhancing the experience for a small but significant minority. If done right, and upstream makes a reasonable modification, say in vim 8.2, you simply do not need to include the proposed addition and everything should work fine. Together these arguments should effectively undermine your stated response as to why no action will be taken.

First, a distribution packager's primary responsibility is to ensure that upstream software is compatible with the other components compiled and installed for that distribution. Of close secondary consideration is to ensure that newer versions are configured or customized in a way that does not disrupt the user experience, and if possible, enhances it. After all, we hope software upgrades also upgrade stability, user-experience, etc. There are also prerequisites of course, such as the software being open-source, and that the build process itself is open. If your view of what packages is at significance variance with the above, then please point out to me some document or blog which you follow as your guiding principles.

Second point is that software vendors provide software configured for what they consider are typical use-cases, but by no means do they expect downstream packagers to keep the settings as-is. Indeed, they often expect packagers and site-administrators to fine-tune the settings for their audience. It is the **domain of configuring defaults and system configuration files is that of the packager and not the software provider**. This is true, whether it be Apache httpd, the gnu compiler, the dhcp daemon, the linux kernel. Vim provides software to all platforms, and it is up to each distribution to individualize and configure the package for their users' best interests. Sometime, such settings are incorporated into the original distribution. Is Debian.vim one of those or are these customized by the packager? Either way, the case is clear that a Debian installation of vim is not the same as the general distribution of vim.

Therefore, it is clear, that the Debian packagers are to set and configure vim's settings so that its users have a satisfying user-experience with those default settings. And it is this very point that you have two complainants saying very clearly, this is not the status quo, and are therefore begging you to change it. Believe me, there are many more of us, but you won't notice them as much for reasons I will point out below.

It is further the case that at least some settings in debian.vim are overridden by those in defaults.vim. This is clearly against the design and wishes of prior packagers!

So before I re-present the solution, let's talk about the use cases. Your dismissal of our tickets suggests you know only one or typical use-cases of the vim package. I suspect the most common use-case for this Debian-vim package is to be installed as an upgrade an existing, Debian installation, for which the user is already familiar with vim and has already created their own .vimrc for customization. For such a user, an X-based interface is almost a given, which means vim might very well run not in a terminal but in an X Window. Most of these users are unaffected by the very annoying "mouse" setting because either they have their own .vimrc or they are using vim within X-Windows. And in these vast majority of such cases, there will be very little need to override system-wide defaults in something like a /etc/vimrc or /etc/vimrc.local file. From that point of view, I understand your dismissal.

However, quite a few of us need to install and support Debian workstations across an organization, or multi-user servers, For us and for the sake of our users, we need the ability to make a system-wide setting. We would naturally put those changes in either /etc/vim/vimrc or as suggested in that file /etc/vim/vimrc.local. In fact, we may already have put those settings there. And expect them to work. Or as is often my case, I must modify a Docker container which runs Debian but has been stripped of all but essential packages, and which I must try out a few ad hoc changes before updating the Dockerfile. For that case, I must install vim, and then I must make some setting changes in /etc/vim/vimrc and lo and behold, those changes don't work. Well, some of them might, others not, who knows? And it will take tons of digging around as I and many others have done to fix that.

Thus, the provided /usr/share/vim/vimrc is *plainly incorrect* in one of two ways. First the opening comment, it suggests that "all system-wide defaults" are set in the Debian.vim file. But now we know this is incorrect, as the new upstream version loads defaults.vim after processing this file, clobbering those defaults from Debian.vim and those set in this file. Second, it indicates that "this file" is where you should make system-wide setttings that override those in Debian.vim. However, "this file" is actually a softlink to /etc/vim/vimrc. (Why? I don't understand why it's a softlink when it does at the end a "source /etc/vim/vimrc.local". Will this file get replaced on an update? I'm guessing it will be replaced unless that file is changed, so why have a vimrc.local? It would have been better to leave this as is in /usr/share/vim/vimrc and include /etc/vim/vimrc. However, this is not something I am requesting or suggesting at this time -- but it may be the better route to take, see below.)

And so it is for the sake of your future users, and my future self and my fellow devops engineers and system admins that this load-order should be corrected to go along with long-established software norms and established vim behavior: defaults should not override package- and site-settings. And yeah, I think vim devs should effectively undo that "feature" which reads defaults.vim last, but we cannot count on them, we don't have to wait for it, and this is ultimately the packager's responsibility anyway.

I hope this conclusively motivates you to make the change to the debian vim package.
---

The solution I proposed will not affect existing users.

Apparently to convince you of that, I must first refute your rebuttal to my assertion that :version represents the order of files loaded. In fact, :version does show that order! Perhaps it is circumstance, but I do not think so. I have used strace in varying conditions to prove that (provided at the end of this email). The defaults.vim file are read *last* _unless_ a user has an existing $HOME/.vimrc or $HOME/.vim/vimrc, even an empty one. The existence of /usr/share/vim/vimrc (or the sourced vimrc.local from it) has no impact on that read-order, as that file is always read first. In reading that file, debian.vim is read. If there are any settings made there, but the user has no .vimrc file, then they are overridden by defaults.vim.

I originally proposed that you modify /etc/vim/vimrc. However, that was based off the vim bug report, and is not IMO correct here. The problem is that the ill-conceived behavior will continue despite a (minor) upgrade of the package. Instead, therefore, I believe it should be made in the vim81/debian.vim file. Alternatively, you could make /usr/share/vim/vimrc be a real file which sources /etc/vim/vimrc as is the norm, and include this proposed change early in the /usr/share/vim/vimrc file.

The change I propose is thus the following, near the top of the file, _before_ the "runtime debian.vim" line.

:if ! filereadable(expand('~/.vimrc')) && ! filereadable(expand('~/.vim/vimrc'))
: source $VIMRUNTIME/defaults.vim
: let g:skip_defaults_vim = 1
:endif

For users with a .vimrc, nothing will change.

For users without a .vimrc file, the defaults file will be read. However, now, it will be read _first_ before the rest of this file and the other site-wide vimrc files (eg, vim.local) are processed. The defaults file will _not_ be read again.

Thus, for users who are happy with the system defaults and have no .vimrc, nothing will change UNLESS those defaults were overridden by settings in debian.vim, as now the debian.vim settings will have the intended effect. It is very likely users already noticed this change with the latest upgrade, and reapplied desired changes to their .vimrc files. So, again, nothing will change that those users cared about.

For users who made changes in /etc/vim/vimrc or /etc/vim/vimrc.local, thos changes may suddenly have an effect where they didn't before. This could be a pleasant surprise.

For users who already made a similar work-around for this problem, it will also not have an effect. Once the skip_defaults_vim is set, it won't get re-set.

For first-time installers, vim will operate exactly as it does without the modification -- until the installer decides to change something in a side-wide vimrc. And that is how it should be.

So, you see, it's win-win for nearly every conceivable scenario.


=== Appendix : strace of stat calls with vim ====

A. As the root user, which has no .vimrc file, vim attempted to load the files in the following order:

/usr/share/vim/vimrc
(With !runtime debian.vim)
/root/.vim/debian.vim [ENOENT]
/etc/vim/debian.vim [ENOENT]
/usr/share/vim/vimfiles/debian.vim [ENOENT]
/usr/share/vim/vim81/debian.vim
/usr/share/vim/vimfiles/after/debian.vim [ENOENT]
/etc/vim/after/debian.vim [ENOENT]
/root/.vim/after/debian.vim [ENOENT]
/etc/vim/vimrc.local
<local directory check>
/root/.vimrc [ENOENT]
/root/.vim/vimrc [ENOENT]
/root/.exrc [ENOENT]
/usr/share/vim/vim81/defaults.vim <--- BOO HISSS
...
(then syntax, and more)

Note: debian.vim is read from vim81, but no "after" from vim81 is processed. That's weird. That looks to be an error of the runtimepath.

Notice how that order exactly aligns with the output in :version.
system vimrc file: "$VIM/vimrc"
^-- /usr/share/vim/vimrc, which explicitly loads /etc/vim/vimrc.local
user vimrc file: "$HOME/.vimrc"
^-- ie, /root/.vimrc above
2nd user vimrc file: "~/.vim/vimrc"
^-- ie, /root/.vim/vimrc above
user exrc file: "$HOME/.exrc"
^-- ie, /root/.exec as above,
defaults file: "$VIMRUNTIME/defaults.vim"
^-- as shown, /usr/share/vim/vim81/defaults.vim
fall-back for $VIM: "/usr/share/vim"

output of :se:


display=truncate
helplang=en
history=200
incsearch
langnoremap
nolangremap
nomodeline
mouse=a
nrformats=bin,hex
ruler
scroll=34
scrolloff=5
showcmd
ttimeout
ttimeoutlen=100
ttyfast
ttymouse=xterm
wildmenu
backspace=indent,eol,start
fileencodings=ucs-bom,utf-8,default,latin1
printoptions=paper:letter
runtimepath=~/.vim,
/var/lib/vim/addons,
/usr/share/vim/vimfiles,
/usr/share/vim/vim81,
/usr/share/vim/vimfiles/after,
/var/lib/vim/addons/after,~/.vim/after
suffixes=.bak,~,.swp,.o,.info,.aux,.log,.dvi,.bbl,.blg,.brf,.cb,.ind,.idx,.ilg,.inx,.out,.toc


B. As the root user with a .vimrc file:


Output of :se

helplang=en
nomodeline
ruler
scroll=34
ttyfast
ttymouse=xterm
backspace=indent,eol,start
fileencodings=ucs-bom,utf-8,default,latin1
printoptions=paper:letter
runtimepath=~/.vim,
/var/lib/vim/addons,
/usr/share/vim/vimfiles,
/usr/share/vim/vim81,
/usr/share/vim/vimfiles/after,
/var/lib/vim/addons/after,
~/.vim/after
suffixes=.bak,~,.swp,.o,.info,.aux,.log,.dvi,.bbl,.blg,.brf,.cb,.ind,.idx,.ilg,.inx,.out,.toc


C. The load order for proposed changes in /etc/vim/debian.vim, root user without .vimrc:

/usr/share/vim/vimrc
/root/.vim/debian.vim
/etc/vim/debian.vim
/root/.vimrc [if exists: open-noblock, ie, only checked]
/root/.vim/vimrc [if above does not exist and this exists: open-noblock, ie, only checked]
/usr/share/vim/vim81/defaults.vim
/usr/share/vim/vimfiles/debian.vim
/usr/share/vim/vim81/debian.vim
/usr/share/vim/vimfiles/after/debian.vim
/etc/vim/after/debian.vim
/root/.vim/after/debian.vim
/root/.vimrc
/root/.vim/vimrc
/etc/vim/vimrc.local

Output of :se

display=truncate
helplang=en
history=200
incsearch
langnoremap
nolangremap
nomodeline
mouse=a
nrformats=bin,hex
ruler
scroll=34
scrolloff=5
showcmd
ttimeout
ttimeoutlen=100
ttyfast
ttymouse=xterm
wildmenu
backspace=indent,eol,start
fileencodings=ucs-bom,utf-8,default,latin1
printoptions=paper:letter
runtimepath=~/.vim,
/var/lib/vim/addons,
/usr/share/vim/vimfiles,
/usr/share/vim/vim81,
/usr/share/vim/vimfiles/after,
/var/lib/vim/addons/after,~/.vim/after
suffixes=.bak,~,.swp,.o,.info,.aux,.log,.dvi,.bbl,.blg,.brf,.cb,.ind,.idx,.ilg,.inx,.out,.toc

(no difference compared to C)

D. Load order for propose changes in /etc/vim/debian.vim, root user with .vimrc:

/usr/share/vim/vimrc
/root/.vim/debian.vim
/etc/vim/debian.vim
/root/.vimrc [if exists: open-noblock, ie, only checked]
/root/.vim/vimrc [if above does not exist and this exists: open-noblock, ie, only checked]
/usr/share/vim/vimfiles/debian.vim
/usr/share/vim/vim81/debian.vim
/usr/share/vim/vimfiles/after/debian.vim
/etc/vim/after/debian.vim
/root/.vim/after/debian.vim
/root/.vimrc
/root/.vim/vimrc
/etc/vim/vimrc.local


Output of :se

helplang=en
nomodeline
ruler
scroll=34
ttyfast
ttymouse=xterm
backspace=indent,eol,start
fileencodings=ucs-bom,utf-8,default,latin1
printoptions=paper:letter
runtimepath=~/.vim,
/var/lib/vim/addons,
/usr/share/vim/vimfiles,
/usr/share/vim/vim81,
/usr/share/vim/vimfiles/after,
/var/lib/vim/addons/after,
~/.vim/after
suffixes=.bak,~,.swp,.o,.info,.aux,.log,.dvi,.bbl,.blg,.brf,.cb,.ind,.idx,.ilg,.inx,.out,.toc

(no difference here than with B)

========================================================================

On 220311.., 01:24, "Debian Bug Tracking System" <ow...@bugs.debian.org> wrote:

This is an automatic notification regarding your Bug report
which was filed against the vim package:

#1007007: vim: defaults.vim items should not override those in vimrc.local and home/.vimrc

It has been closed by James McCoy <jame...@debian.org>.

Their explanation is attached below along with your original report.
If this explanation is unsatisfactory and you have not received a
better one in a separate message then please contact James McCoy <jame...@debian.org> by
replying to this email.


--
1007007: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1007007
Debian Bug Tracking System
Contact ow...@bugs.debian.org with problems

James McCoy

unread,
Mar 14, 2022, 8:40:03 PM3/14/22
to
On Sun, Mar 13, 2022 at 11:21:48PM +0000, Shelling, Otheus wrote:
> Therefore, it is clear, that the Debian packagers are to set and
> configure vim's settings so that its users have a satisfying
> user-experience with those default settings. And it is this very point
> that you have two complainants saying very clearly, this is not the
> status quo, and are therefore begging you to change it. Believe me,
> there are many more of us, but you won't notice them as much for
> reasons I will point out below.

I very well notice and have argued multiple times with Bram about this.
I'm "jamessan" in the very tickets you referenced.

> It is further the case that at least some settings in debian.vim are
> overridden by those in defaults.vim. This is clearly against the
> design and wishes of prior packagers!

Thanks for reminding me that I can remove some of the settings from
debian.vim. I've been maintaining the package for 17 years. I've been
involved in most of the changes you're referring to.

> For that
> case, I must install vim, and then I must make some setting changes in
> /etc/vim/vimrc and lo and behold, those changes don't work. Well,
> some of them might, others not, who knows? And it will take tons of
> digging around as I and many others have done to fix that.

Yes, this is exactly what I've tried to convince Bram is wrong. He's
disagreed and therefore making Debian's Vim behave differently to
upstream *introduces* discrepancies with upstream behavior.

This is exactly why I've documented the approach that upstream has
advocated (see ":help defaults.vim") in /etc/vim/vimrc and
/usr/share/doc/vim/NEWS.Debian.gz. I'll also add it to README.Debian,
as I said I would in #856273, and mention the explicit sourcing of
defaults.vim to get its settings.

Cheers,
--
James
GPG Key: 4096R/91BF BF4D 6956 BD5D F7B7 2D23 DFE6 91AE 331B A3DB
0 new messages