Skip to content

Setting backupdir with dirs that don't exist and linked files  #11349

@wspurgin

Description

@wspurgin
  • nvim --version:
NVIM v0.4.2
Build type: Release
LuaJIT 2.0.5
Compilation: /usr/local/Homebrew/Library/Homebrew/shims/mac/super/clang -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNDEBUG -DMIN_LOG_LEVEL=3 -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -I/tmp/neovim-20190916-88369-176iaxs/neovim-0.4.2/build/config -I/tmp/neovim-20190916-88369-176iaxs/neovim-0.4.2/src -I/usr/local/include -I/tmp/neovim-20190916-88369-176iaxs/neovim-0.4.2/deps-build/include -I/usr/local/opt/gettext/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include -I/tmp/neovim-20190916-88369-176iaxs/neovim-0.4.2/build/src/nvim/auto -I/tmp/neovim-20190916-88369-176iaxs/neovim-0.4.2/build/include
Compiled by brew@Mojave-2.local

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/local/Cellar/neovim/0.4.2/share/nvim"

Run :checkhealth for more info
  • vim -u DEFAULTS (version: 8.0) behaves differently? Yes. It writes the backup to /var/tmp for a symlinked file
  • Operating system/version: OS X 10.14.6
  • Terminal name/version: iTerm2 3.3.6
  • $TERM: xterm-256color

Relates (I think) to #10101 (since it's about backups for symlinks).

Having backupdir set to a list of dirs where (in order of appearance) the first one does not exist, writing backups for symlink files will fail with E506.

When setting the backupdir option, the help indicates that it will attempt to create the backup file in the

first directory in the list where this is possible

If one has this vimrc (only setting the backupdir):

set backupdir=~/.this-does-not-exist-tmp/,/var/tmp/

and the following files:

drwxr-xr-x  4 wspurgin  staff   128B Nov  7 10:17 .
drwxr-xr-x  7 wspurgin  staff   224B Nov  7 10:14 ..
lrwxr-xr-x  1 wspurgin  staff     7B Nov  7 10:14 bar.txt -> foo.txt
-rw-r--r--  1 wspurgin  staff    12B Nov  7 10:17 foo.txt

Attempt to edit bar.txt and then :w the file after it is open

Actual behaviour

A E506 Can't write backup file error occurs when attempting to write bar.txt. Note, that if you swap the order of the directory list in backupdir (where a directory that exists appears first), there's no E506.

Expected behaviour

I expect it to write the backup file to /var/tmp and not E506.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug-regressionwrong behavior that was introduced in a previous commit (please bisect)has:bisectedissue has been tracked to a specific commit

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions