0

I moved all of my dot files out of ~/ in to ~/data/dotfiles

I then did ln -s ~/data/dotfiles/[filename] ~/

My intention was ln -s ~/data/dotfiles/[filename] ~/[filename]

This included my .vimrc , .bashrc And others

Now when I open a terminal session or open vim I get too many levels of symbolic links.

I'm unsure if I delete the symbolic link from my home directory or from the directory the files live in.

Any help would be appreciated.

As per request: jsw:dotfiles jsw$ ls -l ~/.vimrc ~/data/dotfiles/.vimrc lrwxr-xr-x 1 jsw staff 6 1 Aug 13:54 /Users/jsw/.vimrc -> .vimrc -rw-r--r-- 1 jsw staff 11044 31 Jul 10:51 /Users/jsw/data/dotfiles/.vimrc

  • Why do you want to do this? – frostschutz Aug 1 '14 at 17:57
  • 3
    Can you show us the output of ls -l ~/.vimrc ~/data/dotfiles/.vimrc ? – Mark Plotnick Aug 1 '14 at 18:00
  • @frostschutz if you are asking why I want to remove the links it's because I made a mistake and given I'm getting too many levels of symbolic links I need to resolve the issue. If you are referring to why I'd want to move my dotfiles out of my home directory in the first place and then link them back it's because I was putting them into a git repo to prepare for setting up another machine. – Ravenous Aug 1 '14 at 18:03
  • @MarkPlotnick Updated my question with the result. Thank you. – Ravenous Aug 1 '14 at 18:09
2

lrwxr-xr-x 1 jsw staff 6 1 Aug 13:54 /Users/jsw/.vimrc -> .vimrc

You've made a mistake; this was produced by the equivalent of:

ln -s .vimrc .vimrc

You could have done something more convoluted than that (ln -s foo/../.vimrc .vimrc), but in any case, as long as there isn't an actual .vimrc file, ln will create the link, but it will be a dud. If you try and access it you will get:

foobar: ./.vimrc:
Too many levels of symbolic links

Where "foobar" is the name of the application that tried the access. Just delete the link and try again. Besides ls, stat .vimrc will show you what a file points to. The output for this one would start:

File: ‘.vimrc’ -> ‘.vimrc’

Whoops! readlink is even simpler:

> readlink .vimrc
.vimrc

Giving just the path the link points to. If that's the exact same path as the file, it's a circular link. You want to see:

> readlink .vimrc
data/dotfiles/.vimrc

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.