Bug 1657367

Summary: strange behaviour of alternatives java
Product: [Fedora] Fedora Reporter: Frank Ansari <mail>
Component: chkconfigAssignee: Lukáš Nykrýn <lnykryn>
Status: CLOSED CANTFIX QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 29CC: cglombek, jsynacek, lnykryn, msekleta, odubaj, walters
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-01-31 13:35:30 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Bug Depends On:    
Bug Blocks: 1352154    

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 https://pagure.io/fedora-silverblue/issues

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 https://github.com/fedora-sysv/chkconfig/issues/27 for better visibility upstream.