How to make "Installing Cookbook Gems:" faster


Whenever I run ‘kitchen converge’, the “Installing Cookbook Gems:” part takes pretty long time to pass.
I tried using a proxy configuring .kitchen.yml as follow

name: chef_zero

and added following script in the to make embedded ruby gem refers that file after installing chef client.

sudo bash -c “cat << EOF > /opt/chef/embedded/etc/gemrc
gem: --no-ri --no-rdoc
benchmark: false
verbose: true
update_sources: true
backtrace: true
bulk_threshold: 1000

But after that, it still takes long time connecting the proxy server but downloading gem files using which doesn’t cache contents. I expect it will be faster when using http since the proxy(squid) caches contents when used with http.

Is there some way to configure ‘sources’ repos for embedded ruby gem to change the default one with ‘http’? or Is there someone who knows better approach to solve this problem?

Please help

While you can technically use the rubygems_url config option in your client.rb or solo.rb to change this, I should point out that like most websites, no longer allows non-HTTPS requests so you’ll just get redirected anyway. If you need to run an internal mirror, I would do that and then point rubygems_url at that instead.

That’s good to know that http request is being redirected. I guess I should probably setup a local mirror as you said.
Thank you for your advice!

How do you stop “Installing Cookbook Gems” running at all? If we know that then it’s possible to create a timestamp file that will restrict it to running eg once per day.

There isn’t really a way to disable the installing of gems if they are set in metadata.rb of a cookbook as this is an in-built feature of chef-client. At least nothing short of making sure that no cookbooks in a given dependency tree utilize this feature so that it would be effectively a no-op.

FYI: Using Vagrant + VMWare Fusion I have super slow DNS resolving for SRV records which are used by rubygems. As you are using test-kitchen, maybe you have the same issue? Details at - usually circumventing the VMWare Fusion DNS proxy by using Google DNS or any other speeds up any rubygems taks.