Question

I'm trying to install foreman hooks but I get There was an error in your Gemfile, and Bundler cannot continue. when running bundle install

foreman version 1.1

[root@foreman foreman]# bundle update
/usr/share/foreman/config/settings.rb:2: undefined method `load_file' for YAML:Module (NoMethodError)
    /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
    /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
    /usr/share/foreman/Gemfile:1:in `eval_gemfile'
    /usr/lib/ruby/gems/1.8/gems/bundler-1.3.5/lib/bundler/dsl.rb:9:in `evaluate'
    /usr/lib/ruby/gems/1.8/gems/bundler-1.3.5/lib/bundler/definition.rb:19:in `build'
    /usr/lib/ruby/gems/1.8/gems/bundler-1.3.5/lib/bundler.rb:148:in `definition'
    /usr/lib/ruby/gems/1.8/gems/bundler-1.3.5/lib/bundler/cli.rb:301:in `update'
    /usr/lib/ruby/gems/1.8/gems/bundler-1.3.5/lib/bundler/vendor/thor/task.rb:27:in `__send__'
    /usr/lib/ruby/gems/1.8/gems/bundler-1.3.5/lib/bundler/vendor/thor/task.rb:27:in `run'
    /usr/lib/ruby/gems/1.8/gems/bundler-1.3.5/lib/bundler/vendor/thor/invocation.rb:120:in `invoke_task'
    /usr/lib/ruby/gems/1.8/gems/bundler-1.3.5/lib/bundler/vendor/thor.rb:344:in `dispatch'
    /usr/lib/ruby/gems/1.8/gems/bundler-1.3.5/lib/bundler/vendor/thor/base.rb:434:in `start'
    /usr/lib/ruby/gems/1.8/gems/bundler-1.3.5/bin/bundle:20
    /usr/lib/ruby/gems/1.8/gems/bundler-1.3.5/lib/bundler/friendly_errors.rb:3:in `with_friendly_errors'
    /usr/lib/ruby/gems/1.8/gems/bundler-1.3.5/bin/bundle:20
    /usr/bin/bundle:19:in `load'
    /usr/bin/bundle:19
There was an error in your Gemfile, and Bundler cannot continue.

Gemfile:

[root@foreman foreman]# cat Gemfile
require File.expand_path('../config/settings', __FILE__)
source 'http://rubygems.org'

gem 'rails'
gem "jquery-rails"
gem 'json'
gem 'rest-client'
gem "audited-activerecord"
gem "will_paginate"
gem "ancestry"
gem 'scoped_search'
gem 'net-ldap'
gem "safemode"
gem 'ruby_parser'
gem 'uuidtools'
gem "apipie-rails"
gem 'rabl'
gem 'oauth'

Dir["#{File.dirname(__FILE__)}/bundler.d/*.rb"].each do |bundle|
 # puts "adding custom gem file #{bundle}"
  self.instance_eval(Bundler.read_file(bundle))
end

And Gemlock.file

[root@foreman foreman]# cat Gemfile.lock 
GEM
  remote: http://rubygems.org/
  specs:
    abstract (1.0.0)
    actionmailer (3.0.20)
      actionpack (= 3.0.20)
      mail (~> 2.3.0)
    actionpack (3.0.20)
      activemodel (= 3.0.20)
      activesupport (= 3.0.20)
      builder (~> 2.1.2)
      erubis (~> 2.6.6)
      i18n (~> 0.5.0)
      rack (~> 1.2.5)
      rack-mount (~> 0.6.14)
      rack-test (~> 0.5.7)
      tzinfo (~> 0.3.23)
    activemodel (3.0.20)
      activesupport (= 3.0.20)
      builder (~> 2.1.2)
      i18n (~> 0.5.0)
    activerecord (3.0.20)
      activemodel (= 3.0.20)
      activesupport (= 3.0.20)
      arel (~> 2.0.10)
      tzinfo (~> 0.3.23)
    activeresource (3.0.20)
      activemodel (= 3.0.20)
      activesupport (= 3.0.20)
    activesupport (3.0.20)
    ancestry (1.3.0)
      activerecord (>= 2.3.14)
    apipie-rails (0.0.13)
    arel (2.0.10)
    audited (3.0.0.rc1)
    audited-activerecord (3.0.0.rc1)
      activerecord (~> 3.0)
      audited (= 3.0.0.rc1)
    builder (2.1.2)
    erubis (2.6.6)
      abstract (>= 1.0.0)
    excon (0.14.0)
    fog (1.9.0)
      builder
      excon (~> 0.14)
      formatador (~> 0.2.0)
      mime-types
      multi_json (~> 1.0)
      net-scp (~> 1.0.4)
      net-ssh (>= 2.1.3)
      nokogiri (~> 1.5.0)
      ruby-hmac
    foreman_hooks (0.3.1)
    formatador (0.2.1)
    i18n (0.5.0)
    jquery-rails (1.0.19)
      railties (~> 3.0)
      thor (~> 0.14)
    json (1.6.8)
    mail (2.3.3)
      i18n (>= 0.4.0)
      mime-types (~> 1.16)
      treetop (~> 1.4.8)
    mime-types (1.18)
    multi_json (1.2.0)
    net-ldap (0.3.1)
    net-scp (1.0.4)
      net-ssh (>= 1.99.1)
    net-ssh (2.3.0)
    nokogiri (1.5.2)
    oauth (0.4.7)
    polyglot (0.3.3)
    rabl (0.7.5)
      activesupport (>= 2.3.14)
      multi_json (~> 1.0)
    rack (1.2.5)
    rack-mount (0.6.14)
      rack (>= 1.0.0)
    rack-test (0.5.7)
      rack (>= 1.0)
    rails (3.0.20)
      actionmailer (= 3.0.20)
      actionpack (= 3.0.20)
      activerecord (= 3.0.20)
      activeresource (= 3.0.20)
      activesupport (= 3.0.20)
      bundler (~> 1.0)
      railties (= 3.0.20)
    railties (3.0.20)
      actionpack (= 3.0.20)
      activesupport (= 3.0.20)
      rake (>= 0.8.7)
      rdoc (~> 3.4)
      thor (~> 0.14.4)
    rake (0.9.2.2)
    rbvmomi (1.5.1)
      builder
      nokogiri (>= 1.4.1)
      trollop
    rdoc (3.12)
      json (~> 1.4)
    rest-client (1.6.7)
      mime-types (>= 1.16)
    ruby-hmac (0.4.0)
    ruby-libvirt (0.4.0)
    ruby2ruby (2.0.1)
      ruby_parser (~> 3.0.0)
      sexp_processor (~> 4.0)
    ruby_parser (3.0.1)
      sexp_processor (~> 4.1)
    safemode (1.2.0)
      ruby2ruby (>= 2.0.1)
      ruby_parser (>= 3.0.1)
      sexp_processor (>= 4.1.2)
    scoped_search (2.4.0)
      activerecord (>= 2.1.0)
    sexp_processor (4.1.2)
    sqlite3 (1.3.5)
    thor (0.14.6)
    treetop (1.4.10)
      polyglot
      polyglot (>= 0.3.1)
    trollop (1.16.2)
    tzinfo (0.3.32)
    uuidtools (2.1.1)
    will_paginate (3.0.3)

PLATFORMS
  ruby

DEPENDENCIES
  ancestry
  apipie-rails
  audited-activerecord
  fog (>= 1.9)
  foreman_hooks
  jquery-rails
  json
  net-ldap
  oauth
  rabl
  rails
  rbvmomi
  rest-client
  ruby-libvirt
  ruby_parser
  safemode
  scoped_search
  sqlite3
  uuidtools
  will_paginate
Was it helpful?

Solution

This has started happening recently, I think due to a change in bundler or possibly rvm that means YAML doesn't get loaded before the Gemfile's parsed. As such it highlights a bug in Foreman that was fixed in develop (for 1.2), but hasn't been backported to the 1.1 stable branch.

To fix it, add the following line to the very top of config/settings.rb in the Foreman installation:

require 'yaml'
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top