I can't understand from the update-alternatives
documentation how the priorities system works.
Suppose that I want /usr/bin/node
to point to nodejs
for nodejs applications and to an amateur radio program, called node
, in other cases. I have to say:
update-alternatives --install /usr/bin/node nodejs /usr/bin/nodejs 100 --slave /usr/share/man/...
Suppose I have 2 programs that expect /usr/bin/node
to be different things, first – nodejs, second – amateur radio. How would they determine which one to use?
What's the role of priority in this process?
ADDITION: Note, that npm
, nodejs package manager, expects nodejs command to be called node
, thus I have to install nodejs as node
.
Best Answer
At any time,
/usr/bin/node
can only be one of the programs. The alternatives mechanism is a way to choose which one it is.Priorities control which one is the default when both are installed. They don't offer a way to somehow have both and select between the two based on what other program called this one.
When programs call each other by name, there can only be a single program by a given name that comes first on the search path. You should disambiguate the
node
command in your programs. Following Debian, usenodejs
for Node.js andax25-node
for the HAM program. If there's one that it would be really annoying to change, install either thenode
package (which makes/usr/bin/node
an alias forax25-node
) or thenodejs-legacy
package (which makes/usr/bin/node
an alias fornodejs
).If you really have a lot of programs that call
node
and that can't be changed easily, run them with differentPATH
variables, one containing a directory containing a symbolic link toax25-node
and one containing a directory containing a symbolic link tonodejs
: