logicminds / rubyipmi

Command line wrapper for ipmitool and freeipmi
GNU Lesser General Public License v2.1
35 stars 32 forks source link

Fixing loading error on rbenv #1

Closed lzap closed 11 years ago

lzap commented 11 years ago

Hello,

when using rbenv (or when do you "rb" string within your path) the rubygem refused to load for obvious reasons:

[root@localhost smart-proxy]# ruby -rrubyipmi -e true
/root/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/rubyipmi-0.5.0/lib/rubyipmi/ipmitool/commands/bmc.rb
/root/
/root/.rbenv/versions/1.9.3-p392/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- /root/ (LoadError)
    from /root/.rbenv/versions/1.9.3-p392/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from /root/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/rubyipmi-0.5.0/lib/rubyipmi/ipmitool/connection.rb:9:in `block in <top (required)>'
    from /root/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/rubyipmi-0.5.0/lib/rubyipmi/ipmitool/connection.rb:6:in `each'
    from /root/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/rubyipmi-0.5.0/lib/rubyipmi/ipmitool/connection.rb:6:in `<top (required)>'
    from /root/.rbenv/versions/1.9.3-p392/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from /root/.rbenv/versions/1.9.3-p392/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from /root/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/rubyipmi-0.5.0/lib/rubyipmi.rb:1:in `<top (required)>'
    from /root/.rbenv/versions/1.9.3-p392/lib/ruby/1.9.1/rubygems/custom_require.rb:60:in `require'
    from /root/.rbenv/versions/1.9.3-p392/lib/ruby/1.9.1/rubygems/custom_require.rb:60:in `rescue in require'
    from /root/.rbenv/versions/1.9.3-p392/lib/ruby/1.9.1/rubygems/custom_require.rb:35:in `require'

I don't understand why do you split the string as Ruby 1.8-2.0 loads files with extensions fine. Thus sending the fix.

Take care!

lzap commented 11 years ago

Oh apologize for the name and body of the PR - rewritting.

logicminds commented 11 years ago

see article: http://stackoverflow.com/questions/735073/best-way-to-require-all-files-from-a-directory-in-ruby

I remember running into loading errors when I made this. However, I never tested with rbenv or rvm. I test this out today and merge your request if everything goes smoothly.

lzap commented 11 years ago

Ok thanks. If you run into issues, can you please just throw away .rb$ suffix using a regexp so we are sure it does not split any directory containing string "rb"? Would be great!