Fall back to open/write when atomic_write fails

Fixes #28190.
Always resolve one symlink when loading formula files

This means that tapped formula will always have the correct path, and we
can stop calling realpath everywhere.
Remove now unnecessary realpath calls
Rework make_relative_symlink error handling and move it into keg
Raise useful errors from make_relative_symlink
Only unlink after a LinkError
Raise AlreadyLinkedError when a keg is already linked
Adjust link command for updated error handling
Adjust installer for updated link error handling