2

Is it possible to add a custom link group to update-alternatives that is not already there by default?

For example, I want to add Scala and all its supporting binaries as a link group 'scala'. I'm trying using this script, but keep getting the error:

update-alternatives: error: unknown argument `'

I'm not sure what that means, but after troubleshooting the script a bit with no luck, I'm wondering if update-alternatives has a hard-coded list of link groups, that can't be added to, and that doesn't include scala.

chaskes
  • 15,246
bgibson
  • 4,787

2 Answers2

4

you can use:

update-alternatives --install <path-to-generic-binary> <generic-binary-name> <path-to-alternatives> <priority>

so that for installing scala of different versions, you could do like:

update-alternatives --install /usr/bin/scala scala /opt/scala-x.x.x/bin/scala 1200

Note:

this is an extracted version of the accepted answer, from the accepted answer's script link.

Added here so that the answer be here even if the link breaks in the future.

Avinash R
  • 179
  • I hava tried the same for scalac, but got the error: sudo update-alternatives --install /usr/bin/scalac scalac /home/alexandr/opt/scala-2.12.2/bin/scalac 1400 update-alternatives: error: alternative scalac can't be master: it is a slave of scala How can I solve it? Creating a direct link is not good for me. – Alexandr Aug 18 '17 at 13:06
  • @Alexandr I have not used Ubuntu for a while, but I think with the same command, slave commands can be added. Please check the man pages. – Avinash R Aug 18 '17 at 13:42
  • 1
    by mistake I configured in wrong way 'scala', it included both scala and scalac packages. I removed all configuration for 'scala': sudo update-alternatives --remove-all scala and then, configured them separately. It fixed the error. – Alexandr Aug 18 '17 at 13:46
1

Solved: Yes you can add custom link groups, they're not limited to anything hard-coded by Ubuntu.

My particular problem was a finicky error in the script - I had left spaces after the line continuation backslashes \ at the end of each line in the script, that broke it. Fixed that, it works now.

Dan
  • 13,119
bgibson
  • 4,787