3

I am now on OS X 10.9, and I am not sure whether this issue also occurs on other versions.

So, I have many symlinks in my file system (created by ln -s). Today I modified one of them with ln -f -s (see detailed steps below). The symlink is working without problem, but the icon of the symlink in Finder changed from folder icon (with alias badge) to file icon (with alias badge). Namely, the icon should be

folder icon with alias badge

(since the symlink is pointing to a folder) but it is now

file icon with alias badge

The steps I took to modify the link were as follows (say I had the symlink ~/links/folder linking to ~/folder before, and I want to move ~/folder to ~/renamed-folder while updating the symlink to ~/links/renamed-folder):

  1. mv ~/links/folder ~/links/wrongly-renamed-folder, the link is active but renamed (happen to be wrongly renamed in my specific case, revealed by my zsh history).

  2. mv ~/folder ~/renamed-folder, here the link became dead. After this step the link icon should be a file icon (that is the default behavior when link is dead).

  3. mv ~/links/wrongly-renamed-folder ~/links/renamed-folder, I corrected the wrong link name (I don't whether this contributed to the final behavior, so I record it here faithfully).

  4. ln -f -s ~/renamed-folder ~/renamed-folder, the link is working again, and ideally the icon of the symlink should be back to a folder icon. But in my case the icon is still a file icon.

I took some measures to fix this problem but failed. The things I've tried:

  1. Remove the link completely and reconstruct a new one with ln -s. No use. The icon is still a file icon. Strangely enough, if I create another link with the same destination (but a different name), the icon will be a folder icon as expected. Only that one single name (~/links/renamed-folder in the above example) is "reserved."

  2. Try to paste the correct icns file into the Info panel. No use. And I didn't expect this to work actually, since Unix symlinks do not have their own associated icons, unlike OS X aliases.

  3. Relaunch finder, or even log out and log back in. I know this is dumb, but people do this when desperate. And it sometimes does work like a charm; but not this time, unfortunately.

Then I did an experiment that actually kind of revealed a bug in Finder. Steps:

  1. ln -s ~/Downloads ~/tmp. The icon of tmp is the aliased download folder icon download folder with alias badge as expected.

  2. rm ~/tmp.

  3. ln -s ~/other-folder ~/tmp. The icon of tmp, however, is still the aliased download folder icon, though the folder linked to is not the download folder anymore.

So there seems to be some kind of "cache" going on behind the scenes that controls the icons of symlinks, and Finder sometimes fails to update the cache when symlink is modified.

So, my question is, where is the "cache" that controls icons of symlinks? Thanks.

1 Answer 1

10

I had the same problem, and it seems the problem in LaunchService in OS X. To clear it "cache" try this command in terminal

/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user ;

and then

killall Finder; killall Dock;

In Mavericks it should work without reboot or re-login.

1
  • This is so obscure that every time I need to regenerate those symlink thumbnails I have to refer to this again... (And I always mistakenly go to my Super User profile first...)
    – 4ae1e1
    Commented Nov 16, 2014 at 22:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .