Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Psych-unfriendly env hates gem built in Psych-friendly env #13

dchelimsky opened this Issue Apr 18, 2011 · 16 comments


3 participants

We've got some code in rspec-mocks that uses Psych if available, and otherwise falls back to Syck. I built a release candidate gem (rspec-mocks-2.6.0.rc1) using Ruby 1.9.2 compiled with Psych, and released it. When I tried to install it, I got the error listed below.

I then built the gem (2.6.0.rc2) in a Ruby 1.8.7 environment and the release was successful (in as much as you can install it - we have yet to see if people like it).

I don't know if this is a Psych issue or if there is something else I can be doing, but I'd love to avoid avoiding building in a 1.9.2+Psych env.

ERROR:  While executing gem ... (NameError)
    uninitialized constant Psych::Syck
    /Users/david/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:198:in `load'
    /Users/david/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:198:in `_load'
    /Users/david/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/spec_fetcher.rb:133:in `load'
    /Users/david/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/spec_fetcher.rb:133:in `fetch_spec'
    /Users/david/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/spec_fetcher.rb:94:in `block in fetch_with_errors'
    /Users/david/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/spec_fetcher.rb:93:in `map'
    /Users/david/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/spec_fetcher.rb:93:in `fetch_with_errors'
    /Users/david/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/dependency_installer.rb:108:in `find_gems_with_sources'
    /Users/david/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/dependency_installer.rb:228:in `find_spec_by_name_and_version'
    /Users/david/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/dependency_installer.rb:260:in `install'
    /Users/david/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/commands/install_command.rb:120:in `block in execute'
    /Users/david/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/commands/install_command.rb:115:in `each'
    /Users/david/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/commands/install_command.rb:115:in `execute'
    /Users/david/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/command.rb:278:in `invoke'
    /Users/david/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/command_manager.rb:133:in `process_args'
    /Users/david/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/command_manager.rb:103:in `run'
    /Users/david/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/gem_runner.rb:64:in `run'
    /Users/david/.rvm/rubies/ruby-1.9.2-p180/bin/gem:21:in `'

tenderlove commented Apr 18, 2011

Hi David!

When you built the gem on 1.9.2, what version of rubygems were you using? (output of gem env)

1.6.2. I tried it again locally after upgrading to 1.7.2 as well. Same result.

I should add that I used bundler's build task. Not sure what that would mean, since it shells out to 'gem build', but one never knows.

On that last note, I will try building directly and see if I get the same result - but I won't be able to do this until tomorrow evening in all likelihood.

Oh - and one last thing:

Hi Aaron!

@ghost ghost assigned tenderlove Apr 18, 2011


tenderlove commented Apr 18, 2011

Hi David!!

What commands did you use to build the gem? I can't seem to figure out the right command to do packaging via bundler.

Also, I tried building the gem on 1.9.2 like this:

$ gem build rspec-mocks.gemspec

The resulting gem installed fine on 1.9.2 and 1.8.7. Did you have to upload your gem to rubygems.org before it would break?

Hi Aaron!!!

Bundler ships with some rake tasks that you can add to your Rake env like this:


One of the tasks is 'build'

rake build

This shells out to "gem build": https://github.com/carlhuda/bundler/blob/1-0-stable/lib/bundler/gem_helper.rb#L40

I did have to upload my gem to rubygems.org before it would break. That makes this debugging effort extra special.

I fear I'm pointing you down a rabbit hole here. Let me figure out how to reproduce the problem, and then we can go from there. Good?


tenderlove commented Apr 18, 2011

Hi David!!!! ❤️

Sounds good. Let me know what you find!

I am unable to reproduce this locally. It must have never happened and I must have been on crack. Closing this until the next time I'm on crack, only next time I'll take better notes.

@dchelimsky dchelimsky closed this Apr 19, 2011


tenderlove commented Apr 19, 2011

Hah! Okay. Let me know if you encounter this again!

Hey - guess what? I'm an idiot, and my idiocy has made it so you can see what's actually happening here. I pushed rspec-2.6.0.rc3, which I built with rubygems-1.6.2 in ruby-1.9.2-p180 (rvm). Try "gem install rspec -v 2.6.0.rc3" and you'll see the error this issue.

I will now release 2.6.0.rc4, built on 1.8.7 :)

@dchelimsky dchelimsky reopened this May 1, 2011

OK - I now have steps to reproduce.

- !ruby/object:Gem::Dependency
  name: rspec-mocks
  requirement: &2152509300 !ruby/object:Gem::Requirement
    none: false
    - - =
      - !ruby/object:Gem::Version
        version: 2.6.0.rc4
  type: :runtime
  prerelease: false
  version_requirements: *2152509300
  • Now switch to ruby 1.8.7 and run gem spec rspec-2.6.0.rc1 and you'll see gem dependencies that look like this:
- !ruby/object:Gem::Dependency 
  name: rspec-expectations
  prerelease: false
  requirement: &id002 !ruby/object:Gem::Requirement 
    none: false
    - - !ruby/object:YAML::Syck::DefaultKey {}

      - !ruby/object:Gem::Version 
        hash: 15424061
        - 2
        - 6
        - 0
        - rc
        - 4
        version: 2.6.0.rc4
  type: :runtime
  version_requirements: *id002

Same is true of rc3,which I am now going to yank.

If you want to really see this in action:

rvm 1.9.2@rspec-dev --create
git clone git://github.com/rspec/rspec-dev
cd rspec-dev
rake setup
# wait a while
rake gem:build
cd repos/rspec
rake clobber
rake build
gem spec pkg/rspec-2.6.0.rc4 # assuming you do this before the next release
rvm 1.8.7@rspec-dev --create
bundle install
gem spec pkg/rspec-2.6.0.rc4

Given the fact that psych is included (but not compiled into) ruby 1.9, I imagine it would be hard to ship a fix for 1.9.2 for this. And given the fact that pysch and syck have known differences, I'm not entirely sure what the solution will be.

Instead, I'm wondering if gemcutter should reject any gems that have a YAML gemspec file that is unparseable by Syck. It could be part of what runs on gem push my_gem.

Either what @myronmarston suggested or perhaps rubygems could warn when building a gem in an environment with Pysch compiled into it.

@dchelimsky dchelimsky closed this May 13, 2011

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