philnash / bitly

🗜 A Ruby wrapper for the bit.ly API
https://rubygems.org/gems/bitly
MIT License
451 stars 139 forks source link

'require "bitly"' yields pathname error #7

Closed johanbrook closed 12 years ago

johanbrook commented 13 years ago

Hi, just installed the gem and was going to try it out when I got this error message when requiring the gem:

/Users/Johan/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/site_ruby/1.9.1/rubygems.rb:1064:in `escape': can't convert Pathname to String (TypeError)
    from /Users/Johan/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/site_ruby/1.9.1/rubygems.rb:1064:in `block in loaded_path?'
    from /Users/Johan/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/site_ruby/1.9.1/rubygems.rb:1063:in `each'
    from /Users/Johan/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/site_ruby/1.9.1/rubygems.rb:1063:in `find'
    from /Users/Johan/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/site_ruby/1.9.1/rubygems.rb:1063:in `loaded_path?'
    from /Users/Johan/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:35:in `require'
    from /Users/Johan/.rvm/gems/ruby-1.9.2-p0/gems/httparty-0.7.4/lib/httparty.rb:10:in `<top (required)>'
    from /Users/Johan/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:54:in `require'
    from /Users/Johan/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:54:in `require'
    from /Users/Johan/.rvm/gems/ruby-1.9.2-p0/gems/bitly-0.6.1/lib/bitly/v3.rb:3:in `<top (required)>'
    from /Users/Johan/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:54:in `require'
    from /Users/Johan/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:54:in `require'
    from /Users/Johan/.rvm/gems/ruby-1.9.2-p0/gems/bitly-0.6.1/lib/bitly.rb:9:in `<top (required)>'
    from <internal:lib/rubygems/custom_require>:33:in `require'
    from <internal:lib/rubygems/custom_require>:33:in `rescue in require'
    from <internal:lib/rubygems/custom_require>:29:in `require'
    from bitly.rb:1:in `<main>'

Apparently it's something weird going on in the gem business – which bitly doesn't show me anything, and after a double-check in my gem dir (/Users/Johan/.rvm/gems/ruby-1.9.2-p0/bin) the bitly gem is nowhere to be found.

Would be really awesome if this could be fixed. I'm running Ruby 1.9.2 and RubyGems 1.6.2.

philnash commented 13 years ago

Hi Johan,

I can't replicate this issue I'm afraid. Here's what I did, installed a new ruby 1.9.2 with rvm, created a new gemset for it, installed bitly and opened irb and required it.

$ rvm gemset create bitly-test
'bitly-test' gemset created (/Users/philnash/.rvm/gems/ruby-1.9.2-p180@bitly-test).
$ rvm use 1.9.2@bitly-test
Using /Users/philnash/.rvm/gems/ruby-1.9.2-p180 with gemset bitly-test
$ gem -v
1.6.2
$ gem install bitly
9 gems installed
$ irb -rubygems
ruby-1.9.2-p180 :001 > require 'bitly'
 => true 
ruby-1.9.2-p180 :002 > exit
philnash@wkst-110:~$ rvm current
ruby-1.9.2-p180@bitly-test
philnash@wkst-110:~$ gem list bitly

*** LOCAL GEMS ***

bitly (0.6.1)

The only difference I can see between our systems is that your ruby 1.9.2 is at patch level 0. Perhaps getting the latest 1.9.2 will help? If not, could you please set out some steps to reliably reproduce the issue?

Also, bitly has no executables, so you are not expected to see anything when trying which bitly, gem list bitly should show you the installed gem though.

johanbrook commented 13 years ago

Hi Phil, thanks for the quick reply.

I can't really describe how to reproduce the error message in any other way that I followed the regular procedure: gem install bitly and required the gem in Ruby code. Really weird, but I guess it could be a local issue on my machine.

I downloaded and installed latest Ruby (1.9.2-p180) via RVM, and I since I'm a bit of a Ruby/RVM-newbie, I've got a quick question: all my gems are separated between different Ruby versions, I've understood, so how do I make use of my "old" gems in the new Ruby 1.9.2-p180? I've googled and scanned the RVM docs, but haven't really found a conclusion. Some kind of import? I'd like to avoid duplication of gems ..

Anyway, when switching back to Ruby 1.9.2-p0, the bitly gem shows up with gem list bitly:

*** LOCAL GEMS ***

bitly (0.6.1)

My RubyGems version got bumped up to 1.7.2 by the way.

philnash commented 13 years ago

Ah, ok, this is actually an issue between HTTParty and rubygems versions over 1.6 (or something like that). Could you try using rubygems 1.5 (rvm rubygems 1.5) and see if you still get the issue?

This has been discussed and a pull request added in HTTParty (https://github.com/jnunemaker/httparty/pull/80)

As for gems and switching rubies, when you install a fresh ruby it comes without gems (or with just rake, I think). You can set up some global gems to be installed when a ruby is installed though, check here for details: https://rvm.beginrescueend.com/gemsets/initial/. However, I think the idea of rvm is that each ruby stays completely separate, so duplication of gems is intentional. In fact, one of the best ways to work with rvm is to use a different gemset per project, meaning you only install the necessary gems for that project to the gemset for that version of ruby, causing even more duplication but ensuring that you have a consistent environment on a per project basis.

saturnflyer commented 13 years ago

https://github.com/jnunemaker/httparty/pull/80 has been closed. Is this still an issue?