How to handle different ruby version requirements between chef 10.28.0 and ohai 8.0.1 - ruby

I'm trying to build a server on rackspace using chef 10.28.0, building the exact same configuration that I've built three times before without any changes. The only difference is that chef installed ohai 7.4.0 on the previous runs and this time it is installing ohai 8.0.1.
The problem is that chef 10.28.0 installs ruby 1.9.3, whereas ohai 8.0.1 requires ruby 2.0.0 or greater. From my googling I have found that chef 10 supports ruby 2.0 but installs ruby 1.9 by default. Is there any way to get chef 10 to install ruby 2.0 instead? Barring that, is there any way to get chef 10 to install ohai 7.4 instead of 8.0?
Thanks in advance.

Please use the omnibus installer packages. These include Ruby, Chef, Ohai, and all the other dependencies in a working configuration. You can download older versions of the omnibus installers from the download page:
Or you can use the -v option to the bootstrap scripts.

The answer was in the bootstrap scripts. We are using custom bootstrap scripts and the versions for ruby, chef and ohai are all in there.

Related

Cookbook's deep dependency requires an unavailable Ruby version. How to circumvent via chef for Amazon Linux?

I'm a non-Ruby developer using Chef 11.10 on Amazon Linux AMI 2018.03, OpsWorks Agent v.3451.
My Route53 cookbook requires fog which requires fog-brightbox which requires an unspecified version of dry-inflector whose most recent version requires Ruby version 2.4 in its gemspec.
fog is installed via chef_gem which uses a separate version of Ruby reserved for use by the Chef client only, and it is not recommended to update this Ruby version as it may disable the Opsworks Agent.
Is the only way to get around this issue to fork and host each dependency in the chain, then force an earlier version of the deep dependency?
Version 0.1.2 of the dry-inflector gem doesn't require a specific version of Ruby.
Just install the gem with that specific version as soon as possible on your machine.

How to use the gems of Ruby 2.1 in Ruby 1.9 in batch

I have both Ruby 1.9 and 2.1 installed in my computer. Now I am wanting to use several of the gems installed for Ruby 2.1 in Ruby 1.9. However, Ruby 1.9 can't find them.
I tried to solve this problem by setting the environmental variable RUBYLIB but since there were so many gems that needed to be used I can't do it one by one. Is there an easier way?
For example, one of the packages I would like to use in Ruby 1.9 is pango.
Its path is ~/ruby/lib/ruby/gems/2.1.0/gems/pango-2.2.0/
All of the packages installed for Ruby 2.1 can be found at ~/ruby/lib/ruby/gems/2.1.0/gems
Thanks you.
I'd suggest you use a manager like rvm (https://rvm.io/) or rbenv (https://github.com/sstephenson/rbenv) to avoid manually configuring your environment. I use rvm even when I have only one Ruby version installed.

Installing a ruby app on a machine with multiple users

When trying to install a ruby app via bundler, how does your system decide which version of Ruby to use?
Will I run into problems if i use a version of Ruby installed in a directory I do not have access to? If so, how do I ensure I use a version of Ruby installed in the correct directory.
For those voting to close, I am not looking for debugging help. I am looking for an understanding of how bundler decides which version of Ruby to use.
If your app has a Gemfile (most will) you can specify ruby version on Gemfile.
See this question Set ruby version in Gemfile

Is it possible to install and use a Ruby distribution alongside a PC with Opscode Chef Client without one affecting the other?

I'm running chef-client on Windows, and as it happens, the Ruby distribution (1.9.3) embedded in Chef-Client is available system-wide. I believe this is necessary in order to have chef-client function properly? I have tried installing another Ruby distribution (namely, v2.0) but that seems to break Chef-Client.
What I was hoping to achieve is to have chef-client install & configure a Ruby app written against v2.0, so that I can run that app with v2 but have chef-client continue to use the embedded Ruby distribution.
Would that not be possible?
Sure, that's why Opscode is using their Omnibus packages, which ships everything required to run Chef.
Use the "gem_binary" attribute to specify the ruby distro:
gem_package "somegem" do
gem_binary "/usr/bin/gem"
action :install
end
The documentation describe the parameter as follows:
gem_binary: An attribute for the gem_package provider that is used to specify a gems binary. This attribute is useful when installing Ruby 1.9 gems while running in Ruby 1.8. By default, the same version of Ruby that is used by the chef-client will be installed.

Upgrade from ruby 1.8.6 to 1.8.7 in Ubuntu 9.10?

Our server has ruby 1.8.7 and i have 1.8.6 locally. I want to upgrade my local machine (which has ubuntu 9.10) to ruby 1.8.7 - NOT to 1.9 or any later versions. I tried sudo apt-get install ruby1.8.7 but there's no package for that.
Have you tried RVM? There is also a system-wide installation available for servers.
http://rvm.io/
http://rvm.io/deployment/system-wide/
I would highly recommend using RVM.
RVM is a system wide or user wide service (depending on your preference) that allows you to install multiple versions of Ruby without causing problems. Installation is very easy to get started with and since it allows for different versions of Ruby to be installed, you could easily continue programming in 1.8.6 for one project and seamlessly switch to 1.8.7 to program for the server you are working with. You can even set different users to have different versions of Ruby set as their default if you go the user-wide way.
Make sure you have git and curl installed.
https://rvm.io
https://rvm.io/rvm/install/
It does take a little getting used to but it is a very powerful tool for developing with different versions of Ruby and even different versions of the Rails Gem. This is great too, you can have multiple Gemsets as well. So, for instance, if you need to test a new Gem or version of a Gem without mucking up a stable one you already have installed, you can create a separate Gemset and play around with it and switch back at your convenience.
Has saved me from having a lot of headaches in the past.

Resources