bundler 1.3.3 crashes on install with YAML with "undefined method `dump' for YAML:Module" #2394

Closed
smerritt opened this Issue Mar 13, 2013 · 9 comments

Projects

None yet

6 participants

@smerritt

Command:

bundle install --deployment --binstubs=/home/vagrant/deploy-gems/bin --path=/home/vagrant/deploy-gems

Stack trace:

vagrant@graphite2:/vagrant/ssman/install$ bundle install --deployment --binstubs=/home/vagrant/deploy-gems/bin --path=/home/vagrant/deploy-gems
  Unfortunately, a fatal error has occurred. Please see the Bundler
  troubleshooting documentation at http://bit.ly/bundler-issues. Thanks!
/var/lib/gems/1.9.1/gems/bundler-1.3.3/lib/bundler/settings.rb:129:in `block in set_key': undefined method `dump' for YAML:Module (NoMethodError)
from /var/lib/gems/1.9.1/gems/bundler-1.3.3/lib/bundler/settings.rb:129:in `open'
from /var/lib/gems/1.9.1/gems/bundler-1.3.3/lib/bundler/settings.rb:129:in `set_key'
from /var/lib/gems/1.9.1/gems/bundler-1.3.3/lib/bundler/settings.rb:17:in `[]='
from /var/lib/gems/1.9.1/gems/bundler-1.3.3/lib/bundler/cli.rb:218:in `install'
from /var/lib/gems/1.9.1/gems/bundler-1.3.3/lib/bundler/vendor/thor/task.rb:27:in `run'
from /var/lib/gems/1.9.1/gems/bundler-1.3.3/lib/bundler/vendor/thor/invocation.rb:120:in `invoke_task'
from /var/lib/gems/1.9.1/gems/bundler-1.3.3/lib/bundler/vendor/thor.rb:344:in `dispatch'
from /var/lib/gems/1.9.1/gems/bundler-1.3.3/lib/bundler/vendor/thor/base.rb:434:in `start'
from /var/lib/gems/1.9.1/gems/bundler-1.3.3/bin/bundle:20:in `block in <top (required)>'
from /var/lib/gems/1.9.1/gems/bundler-1.3.3/lib/bundler/friendly_errors.rb:3:in `with_friendly_errors'
from /var/lib/gems/1.9.1/gems/bundler-1.3.3/bin/bundle:20:in `<top (required)>'
from /usr/local/bin/bundle:19:in `load'
from /usr/local/bin/bundle:19:in `<main>'

The command works just fine in bundler 1.3.2.

The directory "/home/vagrant/deploy-gems" does not exist, but creating it makes no difference.

I followed the troubleshooting steps in ISSUES.md, but they didn't help.

This is on Ubuntu 12.04, using the distro's ruby1.9.1-full package, version 1.9.3.0-1ubuntu2.5.

Output of bundle env:

Bundler 1.3.3
Ruby 1.9.3 (2011-10-30 patchlevel 0) [x86_64-linux]
Rubygems 1.8.11
GEM_HOME 


Gemfile
source "https://rubygems.org"

gem 'net-ssh', '~>2.2.2'
gem 'net-ssh-multi', '=1.1'
gem 'chef', '10.16.4'


Gemfile.lock
GEM
  remote: http://rubygems.org/
  specs:
    bunny (0.7.9)
    chef (10.16.4)
      bunny (>= 0.6.0, < 0.8.0)
      erubis
      highline (>= 1.6.9)
      json (>= 1.4.4, <= 1.6.1)
      mixlib-authentication (>= 1.3.0)
      mixlib-cli (>= 1.1.0)
      mixlib-config (>= 1.1.2)
      mixlib-log (>= 1.3.0)
      mixlib-shellout
      moneta (< 0.7.0)
      net-ssh (~> 2.2.2)
      net-ssh-multi (~> 1.1.0)
      ohai (>= 0.6.0)
      rest-client (>= 1.0.4, < 1.7.0)
      treetop (~> 1.4.9)
      uuidtools
      yajl-ruby (~> 1.1)
    erubis (2.7.0)
    highline (1.6.15)
    ipaddress (0.8.0)
    json (1.6.1)
    mime-types (1.21)
    mixlib-authentication (1.3.0)
      mixlib-log
    mixlib-cli (1.3.0)
    mixlib-config (1.1.2)
    mixlib-log (1.4.1)
    mixlib-shellout (1.1.0)
    moneta (0.6.0)
    net-ssh (2.2.2)
    net-ssh-gateway (1.1.0)
      net-ssh (>= 1.99.1)
    net-ssh-multi (1.1)
      net-ssh (>= 2.1.4)
      net-ssh-gateway (>= 0.99.0)
    ohai (6.16.0)
      ipaddress
      mixlib-cli
      mixlib-config
      mixlib-log
      mixlib-shellout
      systemu
      yajl-ruby
    polyglot (0.3.3)
    rest-client (1.6.7)
      mime-types (>= 1.16)
    systemu (2.5.2)
    treetop (1.4.12)
      polyglot
      polyglot (>= 0.3.1)
    uuidtools (2.1.3)
    yajl-ruby (1.1.0)

PLATFORMS
  ruby

DEPENDENCIES
  chef (= 10.16.4)
  net-ssh (~> 2.2.2)
  net-ssh-multi (= 1.1)
@smerritt

Looks like someone beat me to it while I was typing all this crap in: #2393

@Sjeanpierre

I only have this issue when doing bundle install with the "--deployment" argument. the standard bundle install method still works. Will revert to 1.3.2 until it is fixed.

@rainchen

Got a similar after upgraded bundler to 1.3.3:

$ bundle config build.pg --with-pg-config=which pg_config

      Unfortunately, a fatal error has occurred. Please see the Bundler
      troubleshooting documentation at http://bit.ly/bundler-issues. Thanks!
~/.gems/gems/bundler-1.3.3/lib/bundler/settings.rb:129:in `block in set_key': undefined method `dump' for YAML:Module (NoMethodError)
     from ~/.gems/gems/bundler-1.3.3/lib/bundler/settings.rb:129:in `open'
     from ~/.gems/gems/bundler-1.3.3/lib/bundler/settings.rb:129:in `set_key'
     from ~/.gems/gems/bundler-1.3.3/lib/bundler/settings.rb:27:in `set_global'
     from ~/.gems/gems/bundler-1.3.3/lib/bundler/cli.rb:590:in `config'
     from ~/.gems/gems/bundler-1.3.3/lib/bundler/vendor/thor/task.rb:27:in `run'
     from ~/.gems/gems/bundler-1.3.3/lib/bundler/vendor/thor/invocation.rb:120:in `invoke_task'
     from ~/.gems/gems/bundler-1.3.3/lib/bundler/vendor/thor.rb:344:in `dispatch'
     from ~/.gems/gems/bundler-1.3.3/lib/bundler/vendor/thor/base.rb:434:in `start'
     from ~/.gems/gems/bundler-1.3.3/bin/bundle:20:in `block in <top (required)>'
     from ~/.gems/gems/bundler-1.3.3/lib/bundler/friendly_errors.rb:3:in `with_friendly_errors'
     from ~/.gems/gems/bundler-1.3.3/bin/bundle:20:in `<top (required)>'
     from ~/.gems//bin/bundle:19:in `load'
     from ~/.gems//bin/bundle:19:in `<main>'

@jagregory

Ditto, same issue here with 1.3.3 (and only with --deployment).

@pehlert
pehlert commented Mar 14, 2013

The problem was introduced in 405edfe and is due to bundler checking whether the YAML constant is defined, before requiring it.

Older versions of rubygems (1.8.11 in my case, which is the Ubuntu 12.04 system default) define this class on load for compatibility reasons (see https://github.com/rubygems/rubygems/blob/11ba6639d4b30d805a08af26c01a61dbaf380b73/lib/rubygems/requirement.rb).

This has been changed later, as visible in the commit history: https://github.com/rubygems/rubygems/commits/master/lib/rubygems/requirement.rb

The solution would be as simple as to remove the safeguard from bundler's psyched.yaml.rb: https://github.com/carlhuda/bundler/blob/master/lib/bundler/psyched_yaml.rb#L16

@indirect
Member

@pehlert the check was added because of problems that I don't totally remember right now, but I believe it had something to do with a double load that caused exceptions.

Could you guys try this patch and see if it fixes things? If it does, I'll get 1.3.4 out today.

diff --git a/lib/bundler/psyched_yaml.rb b/lib/bundler/psyched_yaml.rb
index 9c878f1..7ce3bb9 100644
--- a/lib/bundler/psyched_yaml.rb
+++ b/lib/bundler/psyched_yaml.rb
@@ -13,7 +13,7 @@ rescue LoadError
 end

 # At least load the YAML stdlib, whatever that may be
-require 'yaml' unless defined?(YAML)
+require 'yaml' unless defined?(YAML.dump)

 module Bundler
   # On encountering invalid YAML,
@indirect
Member

Closing this as a dupe of #2393, but I'll keep an eye out for success reports.

@indirect indirect closed this Mar 14, 2013
@pehlert
pehlert commented Mar 14, 2013

@indirect Confirmed, this fixes the issue for me. In lack of better ideas (rubygems version checking would hardly be more reliable), I'd go with this as well.

Many thanks for the quick response!

@smerritt

@indirect Confirmed fix here as well.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment