Note: This is a public test instance of Red Hat Bugzilla. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback at
Bug 1657367 - strange behaviour of alternatives java
Summary: strange behaviour of alternatives java
Alias: None
Product: Fedora
Classification: Fedora
Component: chkconfig
Version: 29
Hardware: x86_64
OS: Linux
Target Milestone: ---
Assignee: Lukáš Nykrýn
QA Contact: Fedora Extras Quality Assurance
Depends On:
Blocks: 1352154
TreeView+ depends on / blocked
Reported: 2018-12-07 19:43 UTC by Frank Ansari
Modified: 2020-01-10 16:35 UTC (History)
6 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Last Closed: 2019-01-31 13:35:30 UTC
Type: Bug

Attachments (Terms of Use)

Description Frank Ansari 2018-12-07 19:43:50 UTC
Description of problem:
I cannot choose java with the alternatives command anymore.

If I want to choose the java version with the alternatives command there is an error message that the file exists. Of course the file exists - why is this a problem?

[root@bat alternatives]# alternatives --config java

There are 2 programs which provide 'java'.

  Selection    Command
*  1           /usr/lib/jvm/java-1.8.0-openjdk-
   2           /usr/lib/jvm/java-11-openjdk-

Enter to keep the current selection[+], or type selection number: 1
failed to link /usr/bin/java -> /etc/alternatives/java: File exists

When I remove /etc/alternative/java there is an error message that the file is missing.

root@bat alternatives]# rm java
[root@bat alternatives]# alternatives --config java
failed to read link /usr/bin/java: No such file or directory
[root@bat alternatives]# alternatives --config java
failed to read link /usr/bin/java: No such file or directory

To have a working java the only option I saw was to set the link manually.

ln -s /usr/lib/jvm/java-1.8.0-openjdk- /etc/alternatives/java

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:

Actual results:
I cannot use alternatives to set the java binary.

Expected results:
I should be able to choose my java with alternatives.

Additional info:
Fedora 29 Silverblue

Comment 1 Ondrej Dubaj 2018-12-18 10:47:37 UTC
The problem was in unlinking /usr/bin/java instead of /etc/alternatives/java and also bad path linking due to this problem. The bug will be probably fixed in the next release. We should wait what the maintainer will say about the fix.

Comment 2 Lukáš Nykrýn 2019-01-31 13:35:30 UTC
That part of code should be improved a bit but this is not the problem here. The way how the rpm-ostree in silver-blue work is incompatible with alternatives. The main issue is that the alternative database in /var is not created at all.

This can't be solved in the alternatives, you need to file an issue about this behaviour to silverblue directly

Comment 3 Colin Walters 2019-04-12 17:12:13 UTC
FWIW I think alternatives could fix this by storing state in /etc solely and not using /var.

As I noted on an internal mailing list, this isn't *just* an ostree issue; any system which tries to "snapshot" the OS or do offline updates, without capturing/snapshotting user data (i.e. /var) would trip over this too.

Comment 4 Christian Glombek 2020-01-10 16:35:35 UTC
I think Colin's proposed fix is the way to go with this; created for better visibility upstream.

Note You need to log in before you can comment on or make changes to this bug.