3

I had yadr installed on my laptop, and I decided to get rid of it by running rm -rf ~/.yadr as instructed by its author. However after I did that weirdness commenced: If I try to edit my vimrc and type

$ vi .vim

auto complete will show me the following files:

.vim@     .viminfo  .vimrc@

So what is this @ at the end of .vimrc? If I just type vi .vimrc it claims that it is a new file. Then if I try to save that edited file I get this error:

.vimrc" E166: Can't open linked file for writing

Any ideas?

Arjan
  • 31,511
abbood
  • 1,354

2 Answers2

6

Generally, @ represents a symbolic link. There are certain relatively standard format indicators often appended to a filename when displaying it in a list of files, to let you quickly have some idea what it is; I'm not sure if they originated with ls, but ls -F has a nice list of them: / is a directory, @ is a symbolic link (meaning the file is really pointing to a file elsewhere), and |, >, and = are different special "files" used for interprocess communication. Also, files with the execute bit are often displayed with a trailing *.

These aren't actually part of the file name; they're shown to the user to let them quickly categorize the file as a regular file, a program, a directory, a symlink, or something else.

In this case, looking through yadr's install script, it appears that it puts all configuration files in non-hidden files in the .yadr directory, presumably to make managing them easier. Because nothing else is looking for dotfiles there, it then by default creates symlinks from your home directory to the directory it is installed in (look starting at line 301 in yadr's Rakefile; file_operation normally symlinks ~/.file to $PWD/file). In install.sh, we can see that yadr normally runs its rakefile in ~/.yadr, so a default install will replace many dotfiles with symlinks into ~/.yadr. On line 24 of the rakefile, we see that that's what's happening: file_operation is called on vim and vimrc, meaning ~/.vim and ~/.vimrc are symlinked to ~/.yadr/vim and ~/.yadr/vimrc, respectively. The previous ~/.vimrc was moved to ~/.vimrc.backup.

So, what happened here is that yadr's installation moved your .vimrc to .vimrc.backup, and replaced it with a link to its own file, located in ~/.yadr. When you deleted ~/.yadr, the link now points inside a nonexistent directory; vim can create a file when it doesn't exist, but it can't save in a nonexistent directory. To edit .vimrc, you'll have to delete the current symlink and either start over from the auto-created backup (if it exists), or from scratch (if it doesn't).

cpast
  • 2,513
0

From arimo's comments I did this:

$ readlink .vim
/Users/abdallah/.yadr/vim

also

$ ls -l .vim*
lrwxr-xr-x  1 abdallah  staff     25 Apr 23  2014 .vim -> /Users/abdallah/.yadr/vim
-rw-------  1 abdallah  staff  12602 Dec 24 07:27 .viminfo
lrwxr-xr-x  1 abdallah  staff     27 Apr 23  2014 .vimrc -> /Users/abdallah/.yadr/vimrc

the tricky part was that I knew that typing ls -l will show symlinks.. I just didn't know how to show the symlinks of dot files. Also I was always trying to delete the files with the @ at the end of it.. ie

$ rm .vim@
rm: .vim@: No such file or directory

but then I based on the above output.. I simply removed the .vim file directly:

$ ls -l .vim*
lrwxr-xr-x  1 abdallah  staff     25 Apr 23  2014 .vim -> /Users/abdallah/.yadr/vim
-rw-------  1 abdallah  staff  12602 Dec 24 07:27 .viminfo
lrwxr-xr-x  1 abdallah  staff     27 Apr 23  2014 .vimrc -> /Users/abdallah/.yadr/vimrc

$ rm .vim

$ ls -l .vim*
-rw-------  1 abdallah  staff  12602 Dec 24 07:27 .viminfo
lrwxr-xr-x  1 abdallah  staff     27 Apr 23  2014 .vimrc -> /Users/abdallah/.yadr/vimrc

and that's it!

abbood
  • 1,354