How to upgrade Ruby Bundle version in AWS Opsworks
Asked Answered
E

1

6

I have a project running on AWS Opsworks, which has current bundler version of 1.5.3 on Ruby 2.2.2.

i want to upgrade the bundle version to 1.17.3

but when i try to do it i am getting this error

Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '1'
---- Begin output of /usr/local/bin/gem install bundler -q --no-rdoc --no-ri -v "1.11.2" ----
STDOUT: 
STDERR: ERROR:  Error installing bundler:
"bundle" from bundler conflicts with /usr/local/bin/bundle
---- End output of /usr/local/bin/gem install bundler -q --no-rdoc --no-ri -v "1.11.2" ----
Ran /usr/local/bin/gem install bundler -q --no-rdoc --no-ri -v "1.11.2" returned 1


Resource Declaration:
---------------------
# In /var/lib/aws/opsworks/cache.stage2/cookbooks/opsworks_bundler/recipes/default.rb

2:   gem_package "Installing Bundler #{node[:opsworks_bundler][:version]}" do
3:     gem_binary node[:dependencies][:gem_binary]
4:     retries 2
5:     package_name "bundler"
6:     action :install
7:     version node[:opsworks_bundler][:version]
8:     if Gem::Version.new(node[:opsworks_rubygems][:version]) > Gem::Version.new("2.6.14")
9:       options "--force"
10:     end
11:   end



Compiled Resource:
------------------
# Declared in /var/lib/aws/opsworks/cache.stage2/cookbooks/opsworks_bundler/recipes/default.rb:2:in `from_file'

gem_package("Installing Bundler 1.11.2") do
provider Chef::Provider::Package::Rubygems
action [:install]
retries 0
retry_delay 2
package_name "bundler"
version "1.11.2"
cookbook_name "opsworks_bundler"
recipe_name "default"
gem_binary "/usr/local/bin/gem"
end



[2019-12-04T04:42:03+00:00] INFO: Running queued delayed notifications before re-raising exception
[2019-12-04T04:42:03+00:00] ERROR: Running exception handlers
[2019-12-04T04:42:03+00:00] ERROR: Exception handlers complete
[2019-12-04T04:42:03+00:00] FATAL: Stacktrace dumped to /var/lib/aws/opsworks/cache.stage2/chef-stacktrace.out
[2019-12-04T04:42:03+00:00] ERROR: gem_package[Installing Bundler 1.11.2] (opsworks_bundler::default line 2) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of /usr/local/bin/gem install bundler -q --no-rdoc --no-ri -v "1.11.2" ----
STDOUT: 
STDERR: ERROR:  Error installing bundler:
"bundle" from bundler conflicts with /usr/local/bin/bundle
---- End output of /usr/local/bin/gem install bundler -q --no-rdoc --no-ri -v "1.11.2" ----
Ran /usr/local/bin/gem install bundler -q --no-rdoc --no-ri -v "1.11.2" returned 1
[2019-12-04T04:42:03+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

enter image description here

enter image description here

when i run bundle -v on the server i am getting bundler version as 1.5.3. what ever i do i cannot change the bundle version from that.

root@hades:/srv/www/app_unicorn/current# which gem
/usr/local/bin/gem

root@hades:/srv/www/app_unicorn/current# which ruby
/usr/local/bin/ruby

root@hades:/srv/www/app_unicorn/current# which bundle
/usr/local/bin/bundle

root@hades:/srv/www/app_unicorn/current# gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 2.2.2
  - RUBY VERSION: 2.1.9 (2016-03-30 patchlevel 490) [x86_64-linux]
  - INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/2.1.0
  - RUBY EXECUTABLE: /usr/local/bin/ruby
  - EXECUTABLE DIRECTORY: /usr/local/bin
  - SPEC CACHE DIRECTORY: /root/.gem/specs
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-linux
  - GEM PATHS:
     - /usr/local/lib/ruby/gems/2.1.0
     - /root/.gem/ruby/2.1.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /usr/local/sbin
     - /usr/local/bin
     - /usr/sbin
     - /usr/bin
     - /sbin
     - /bin
     - /usr/games
     - /usr/local/games

root@hades:/srv/www/app_unicorn/current# bundle env
Bundler 1.5.3
Ruby 2.1.9 (2016-03-30 patchlevel 490) [x86_64-linux]
Rubygems 2.2.2
GEM_HOME

Bundler settings
  path
    Set for your local app (/srv/www/app_unicorn/releases/20061825/.bundle/config): "/home/deploy/.bundler/app_unicorn"
  without
    Set for your local app (/srv/www/app_unicorn/releases/20061825/.bundle/config): "test:development"
  disable_shared_gems
    Set for your local app (/srv/www/app_unicorn/releases/20061825/.bundle/config): "1"

someone asked me to look into this issue. but i dont know what to do with this https://github.com/chef/chef-dk/issues/536

how to add configuration in either the chef recipe or anywhere else to update the bundle version ?

my cook book :- https://gist.github.com/nijeeshjoshy/90ef2dfc693c869205bad589ef1b0e23

enter image description here

I have ssh access and i can manually reinstall bunder without any issues. but i have to do it via chef. If i do it manually every time it defeats the purpose of using opsworks

Exhibit answered 4/12, 2019 at 6:33 Comment(6)
not sure about how opsworks do as I never used it, but if you can install new version of bundler, then why not append it to the searchable path before requiring it? if it's the executable, then add it to PATH variableUnlawful
What does head -1 `which bundle` return?Merovingian
Also why not just delete /usr/local/bin/bundle?Merovingian
And even better, why not uninstall the original bundler first, and then reinstall? I think this warning is by design; it is telling you the new bundle binary will not be compatible with the old bundle gem. Hence you need to delete the old gem before installing the new one.Merovingian
Btw. if you are afraid of deleting /usr/local/bin/bundle, just rename it to something else, like bundle_old. That way you can test and see if it works before committing.Merovingian
Thanks @Casper, but i do have the ssh access and i can directly go an manually install the bundler with out any problem. My problem is i have to do it via chef. because when the server gets autoscaled i want the same behavior on the newly spun server too. i cannot just ssh into all the instances and manually install the bundler. That defeats the purpose of using opsworks in the firstplace.Exhibit
O
1

I would strongly suggest you not use Ruby 2.2.2 for security, compatibility, performance, support, quicker bug fixes, and better compatibility with other frameworks/libraries. Using an outdated version like 2.2 you're going to be fighting against all of these areas of software development.

Ruby 3+ has the latest stable versions with long-term support (LTS) that may fit your existing setup. Try those out.

At minimum, upgrade to Ruby 2.7 with Bundler 2.4. That will solve your issue.

Occidental answered 20/10, 2023 at 14:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.