0
votes

I'm trying to create a Ubuntu machine with Vagrant and Chef Solo. So, I've created a simple Vagrantfile and a simple recipe, just to test it. But I'm facing with the following error message:

Recipe Compile Error in /tmp/vagrant-chef/f10d707023a689f28124f5dcfaadbc2a/cookbooks/homebrew/libraries/helpers.rb

==> default: NameError
==> default: uninitialized constant Chef::Mixin::HomebrewUser
==> default: Cookbook Trace:
==> default: /tmp/vagrant-chef/f10d707023a689f28124f5dcfaadbc2a/cookbooks/homebrew/libraries/helpers.rb:23:in
<class:Chef12HomebrewUser>'<br/> ==> default: /tmp/vagrant-chef/f10d707023a689f28124f5dcfaadbc2a/cookbooks/homebrew/libraries/helpers.rb:22:in<br/> '
==> default:
==> default: Relevant File Content:
==> default: /tmp/vagrant-chef/f10d707023a689f28124f5dcfaadbc2a/cookbooks/homebrew/libraries/helpers.rb:
==> default:
==> default: 16: # distributed under the License is distributed on an "AS IS" BASIS,
==> default: 17: # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
==> default: 18: # See the License for the specific language governing permissions and
==> default: 19: # limitations under the License.
==> default: 20: #
==> default: 21:
==> default: 22: class Chef12HomebrewUser
==> default: 23>> include Chef::Mixin::HomebrewUser
==> default: 24: end
==> default: 25:
==> default: 26: module Homebrew
==> default: 27: extend self # rubocop:disable ModuleFunction
==> default: 28:
==> default: 29: def exist?
==> default: 30: Chef::Log.debug('Checking to see if the homebrew binary exists')
==> default: 31: ::File.exist?('/usr/local/bin/brew')
==> default: 32: end
==> default:

Below there are my files:

Vagrantfile

Vagrant.configure(2) do |config|
  config.vm.box = "ubuntu/trusty64"

  config.berkshelf.enabled = true
  config.berkshelf.berksfile_path = "./cookbooks/teste/Berksfile"

  config.vm.provision "chef_solo" do |chef|
   chef.install = false
   chef.add_recipe "teste"
  end
end

Berksfile

source 'https://supermarket.chef.io'

metadata

default.rb

include_recipe 'apt::default'
include_recipe 'java::default'

attributes.rb

default['java']['install_flavor'] = 'openjdk'
default['java']['jdk_version'] = '8'
default['java']['accept_license_agreement'] = true

metadata.rb

name 'teste'
maintainer 'The Authors'
maintainer_email '[email protected]'
license 'All Rights Reserved'
description 'Installs/Configures teste'
long_description 'Installs/Configures teste'
version '0.1.0'
chef_version '>= 12.1' if respond_to?(:chef_version)

depends 'apt'
depends 'java'

About my configuration:

Chef Development Kit Version: 2.3.4
chef-client version: 13.4.19
berks version: 6.3.1
kitchen version: 1.17.0
inspec version: 1.36.1

Vagrant 2.0.1

macOS Sierra (10.12.6)
1
At the top of the Chef output it should show which version of chef-solo is being used. I would guess that's something earlier than 12.7 which is the minimum requirement for the current release of the homebrew cookbook. - coderanger
Yes, you're right, the message says Chef 11.8.2. But, chef-solo -v I returns Chef: 13.6.4 as Chef version. - brunno grillo
So you're using the default hashicorp Ubuntu image. You might have an older version of that box cached which still had chef pre-installed rather than letting Vagrant install it on the fly. If so, delete the box locally and allow it to re-download. - coderanger
I tried your way, without success. I ran vagrant box remove ubuntu/trusty64 to remove but Vagrant still use chef-solo 11.8. How is vagrant box related to chef-solo version? - brunno grillo

1 Answers

0
votes

I could fix that adding config.omnibus.chef_version = :latest on Vangratfile. It means Vagrant will use the latest version for chef everytime.