Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rbenv rehash error in conjunction with Ruby 2.3.0 #845

Closed
kaikuchn opened this issue Dec 27, 2015 · 5 comments
Closed

rbenv rehash error in conjunction with Ruby 2.3.0 #845

kaikuchn opened this issue Dec 27, 2015 · 5 comments

Comments

@kaikuchn
Copy link

Hi,

I just updated everything through homebrew to install Ruby 2.3.0 and noticed that rbenv rehash throws this error:

/Users/kaikuchn/.rbenv/versions/2.3.0/lib/ruby/2.3.0/ostruct.rb:176:in `respond_to_missing?': undefined method `key?' for nil:NilClass (NoMethodError)
  from /Users/kaikuchn/.rbenv/versions/2.3.0/lib/ruby/2.3.0/psych/visitors/to_ruby.rb:381:in `respond_to?'
  from /Users/kaikuchn/.rbenv/versions/2.3.0/lib/ruby/2.3.0/psych/visitors/to_ruby.rb:381:in `init_with'
  [ ... ]
  from /Users/kaikuchn/.rbenv/versions/2.3.0/lib/ruby/2.3.0/psych/visitors/to_ruby.rb:32:in `accept'
  from /Users/kaikuchn/.rbenv/versions/2.3.0/lib/ruby/2.3.0/psych/nodes/node.rb:38:in `to_ruby'
  from /Users/kaikuchn/.rbenv/versions/2.3.0/lib/ruby/2.3.0/psych.rb:253:in `load'
  from /Users/kaikuchn/.rbenv/plugins/bundler/etc/rbenv.d/bundler/rehash.rb:267:in `block in build_ruby_profiles'
  from /Users/kaikuchn/.rbenv/plugins/bundler/etc/rbenv.d/bundler/rehash.rb:266:in `open'
  from /Users/kaikuchn/.rbenv/plugins/bundler/etc/rbenv.d/bundler/rehash.rb:266:in `open'
  from /Users/kaikuchn/.rbenv/plugins/bundler/etc/rbenv.d/bundler/rehash.rb:266:in `build_ruby_profiles'
  from /Users/kaikuchn/.rbenv/plugins/bundler/etc/rbenv.d/bundler/rehash.rb:455:in `<main>'

rbenv version is 1.0.0 and ruby-build version 20151225

It looks like Ruby 2.3.0 has trouble loading OpenStructs from the ruby_profiles.yml file?
The implementation of OpenStruct changed, it now has a #respond_to_missing? method which references @table. That instance variable seems to be nil and causes the error.

As I now realize, this isn't a fault with rbenv, but rather with Psych.. Check this out:

irb(main):061:0> yaml = Psych.dump(OpenStruct.new(ruby_version: [2, 3, 0]))
=> "--- !ruby/object:OpenStruct\ntable:\n  :ruby_version:\n  - 2\n  - 3\n  - 0\n"
irb(main):062:0> Psych.load(yaml)
NoMethodError: undefined method `key?' for nil:NilClass
    from /Users/kkuchenbecker/.rbenv/versions/2.3.0/lib/ruby/2.3.0/ostruct.rb:176:in `respond_to_missing?'
    from /Users/kkuchenbecker/.rbenv/versions/2.3.0/lib/ruby/2.3.0/psych/visitors/to_ruby.rb:381:in `respond_to?'
    [ ... ]
    from /Users/kkuchenbecker/.rbenv/versions/2.3.0/lib/ruby/2.3.0/psych/visitors/to_ruby.rb:32:in `accept'
    from /Users/kkuchenbecker/.rbenv/versions/2.3.0/lib/ruby/2.3.0/psych/nodes/node.rb:38:in `to_ruby'
    from /Users/kkuchenbecker/.rbenv/versions/2.3.0/lib/ruby/2.3.0/psych.rb:253:in `load'
    from (irb):62
    from /Users/kkuchenbecker/.rbenv/versions/2.3.0/bin/irb:11:in `<main>'

I'll create this issue anyway since people are likely to report this here..

Edit: I've now reported this issue https://bugs.ruby-lang.org/issues/11884

@mislav
Copy link
Member

mislav commented Dec 27, 2015

Thanks for reporting, but rbenv doesn't have any code in Ruby, and thus can't generate Ruby stack traces. It's all bash script.

Your stack trace comes from rbenv-bundler plugin, which is a known culprit for many kinds of bugs. You should uninstall it, rm -r rbenv root/shims, and try rehash again.

@kaikuchn
Copy link
Author

Oh! Thanks for pointing that out.
I removed the plugin and I'm not missing it (nor the stack trace it produced 😄 ).

I'll then close this issue since it has nothing to do with rbenv. Thank you for your quick response and your awesome work!

@adamgeorgeson
Copy link

adamgeorgeson commented Jan 6, 2016

Just incase this issues comes up in search results for people having the same/similar issue, I also had this but had been installed through homebrew - stack trace included /usr/local/Cellar/rbenv-bundler/0.99/etc/rbenv.d/bundler/rehash.rb:267:in 'block in build_ruby_profiles' opposed to within .rbenv.

  • brew uninstall rbenv-bundler
  • rm -r rbenv root/shims
  • rbenv rehash

@dannysmith
Copy link

Ended up here via google. Thanks.

If you've got rbenv-bundler installed and don't want to remove it, you can switch it off with rbenv bundler off.

@tannerhodges
Copy link

@dannysmith Thanks for the rbenv bundler off tip.

For me, the fix was:

brew update && brew upgrade
rm -rf `rbenv root`/shims
rbenv bundler off
rbenv rehash

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants