Tuesday, December 28, 2010

Fixing Update-alternatives' No such file or directory Messages

I found out that if I get the message "failed to read link /usr/bin/: No such file or directory" removing and recreating the symlink helped.  Below are the steps that I followed, this was all by trial and error, reading the alternatives man page and looking at what people have posted on the web.
 

  1. When an error message in the form, failed to read link /usr/bin/: No such file or directory was sent by alternatives I would do an ls -l to see where the symlink was pointing. 
  2. Remove the symlink /usr/bin/ if it was pointing to /etc/alternatives.
  3. Create a new symlink in /usr/bin/ pointing to /usr/java/jdk1.6.0.21/bin/.
  4. Run /usr/sbin/update-alternatives –install /usr/bin/   $JAVA_HOME/bin/ $JAVA_ALTERNATIVE_PRIORITY 
  5. Do /usr/sbin/update-alternatives –auto

After I went through all the steps I did not get any complaints from Fedora and my Java seemed to be correct. 



Update

To see exactly where the ymlinks are pointing too use the ll command.  An example of its output is below.

$ ll /usr/bin/javasw
lrwxrwxrwx 1 root root 24 Dec 28 01:20 /usr/bin/javasw -> /etc/alternatives/javasw


Unfortunately running ll /usr/bin/jar gives a no such file or directory message.  Typing jar works but need to make sure its the right jar.  so that when I call on libraries they will be the right ones.

1 comment:

Unknown said...

I followed it through with strace, the link its referring to is missing in /etc/alternatives and not as the stupid error messages suggest. Do ls -l /etc/alternatives and you will see what I mean.