Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with providers/alternatives.rb #134

Closed
cosenmarco opened this issue Feb 7, 2014 · 6 comments
Closed

Problem with providers/alternatives.rb #134

cosenmarco opened this issue Feb 7, 2014 · 6 comments

Comments

@cosenmarco
Copy link

Hi,
I'm having problems with alternatives on my vagrant box.

The VM is taken from here: "http://opscode-vagrant-boxes.s3.amazonaws.com/centos5-gems.box" (also had the same problem with another centos 5 image). I'm using chef_solo.

    chef.json = { :run_list => [ "recipe[java]" ],
     :java => {
       :jdk_version => 6,
       :install_flavor => "openjdk"
     }

How to reproduce:
1 - vagrant up
2 - vagrant provision

The second time provisioning runs you'll get this error:

...
[2014-02-07T11:11:30+00:00] DEBUG: Adding alternative for appletviewer
[2014-02-07T11:11:30+00:00] DEBUG: Setting alternative for appletviewer                                                                                                                                
[2014-02-07T11:11:30+00:00] FATAL:  set alternative failed
================================================================================                                                                                                                       
Error executing action `set` on resource 'java_alternatives[set-java-alternatives]'                                                                                                                    
================================================================================
...

I think the problem is due to the way "alternatives" behave when using "--install":

[vagrant@vagrant-c5-x86_64 ~]$ /usr/sbin/alternatives --version
alternatives version 1.3.30.2
[vagrant@vagrant-c5-x86_64 ~]$ sudo su -
[root@vagrant-c5-x86_64 ~]# /usr/sbin/alternatives --install /usr/bin/appletviewer appletviewer /usr/lib/jvm/java-1.6.0/bin/appletviewer 1061 
failed to read link /usr/bin/appletviewer: No such file or directory
[root@vagrant-c5-x86_64 ~]# echo $?
0
@damacus
Copy link
Member

damacus commented Feb 7, 2014

I'm also having this problem. With alternatives on redhat 6.4. The current
work around is to remove the sym links, horrible hack I know...

Haven't had time to debug that particular cookbook yet. If anyone does fix
this. It'll be worth writing some tests to cover this case off.
On 7 Feb 2014 11:15, "Marco Cosentino" notifications@github.com wrote:

Hi,
I'm having problems with alternatives on my vagrant box.

The VM is taken from here: "
http://opscode-vagrant-boxes.s3.amazonaws.com/centos5-gems.box" (also had
the same problem with another centos 5 image). I'm using chef_solo.

chef.json = { :run_list => [ "recipe[java]" ],
 :java => {
   :jdk_version => 6,
   :install_flavor => "openjdk"
 }

How to reproduce:
1 - vagrant up
2 - vagrant provision

The second time you'll get this error:

...
[2014-02-07T11:11:30+00:00] DEBUG: Setting alternative for appletviewer
[2014-02-07T11:11:30+00:00] FATAL: set alternative failed

Error executing action set on resource 'java_alternatives[set-java-alternatives]'

...

I think the problem is due to the way "alternatives" behave when using
"--install":

[vagrant@vagrant-c5-x86_64 ~]$ /usr/sbin/alternatives --version
alternatives version 1.3.30.2
[vagrant@vagrant-c5-x86_64 ~]$ sudo su -
[root@vagrant-c5-x86_64 ~]# /usr/sbin/alternatives --install /usr/bin/appletviewer appletviewer /usr/lib/jvm/java-1.6.0/bin/appletviewer 1061
failed to read link /usr/bin/appletviewer: No such file or directory
[root@vagrant-c5-x86_64 ~]# echo $?
0


Reply to this email directly or view it on GitHubhttps://github.com//issues/134
.

@rsiwal
Copy link

rsiwal commented Feb 12, 2014

We had to create symlinks from /usr/lib/jvm/java/bin/* -> /etc/alternatives/
After the Soft links were created. The recipe worked fine.

carmstrong added a commit that referenced this issue Mar 15, 2014
Issue #134 Remove /var/lib/alternatives/#{cmd} before calling alternatives.
@carmstrong
Copy link
Contributor

I just merged #144 and released cookbook version 1.21.0. Could you please update to the latest and see if this is fixed?

@carmstrong
Copy link
Contributor

Closing - please reopen if this is still an issue.

@davedcusack
Copy link

Deleting the symlink before doing the --install for alternatives means that you can only ever manage one version of java using alternatives, because before installing a second version it will wipe /var/lib/alternatives/java https://github.com/agileorbit-cookbooks/java/blob/master/providers/alternatives.rb#L41

And only the most recently installed version will be configured to use alternatives. Is this a conscious decision?

@lock
Copy link

lock bot commented May 3, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators May 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants