Forum: Ruby Can't load gems

Posted by Loran Kary (skylonder)
on 2013-02-14 01:37
I have installed rvm on my Mac OSX and Ruby 1.9.3 and I also installed
rails.

I created my own gem which is successfully installed with gem install.

If I enter the command "gem list", I get a long list of gems, mostly
rails and also my own installed gem.

But if I try to require any of these gems in my source code,
'actionmailer' for instance, I get a load error

in `require': cannot load such file -- actionmailer (LoadError)

Here is my source code:

puts $:

require 'actionmailer'


and here is the output:

/Users/kary/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/site_ruby/1.9.1
/Users/kary/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/site_ruby/1.9.1/x86_64-darwin12.2.0
/Users/kary/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/site_ruby
/Users/kary/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/vendor_ruby/1.9.1
/Users/kary/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/vendor_ruby/1.9.1/x86_64-darwin12.2.0
/Users/kary/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/vendor_ruby
/Users/kary/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1
/Users/kary/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/x86_64-darwin12.2.0
/Users/kary/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in
`require': cannot load such file -- actionmailer (LoadError)
  from
/Users/kary/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in
`require'
  from ../ruby-1.9.3/test_timecode.rb:3:in `<main>'


The gems are actually installed in
/Users/kary/.rvm/gems/ruby-1.9.3-p286/gems

bash-3.2$ rvm gemdir
/Users/kary/.rvm/gems/ruby-1.9.3-p286

Why can't Ruby find my gems when I require them?

Thanks in advance
Posted by Ryan Davis (Guest)
on 2013-02-14 02:05
(Received via mailing list)
On Feb 13, 2013, at 16:37 , Loran Kary <lists@ruby-forum.com> wrote:

> Why can't Ruby find my gems when I require them?

To start, make sure that `which gem` and `which ruby` are answering with 
the same install.
Posted by Loran Kary (skylonder)
on 2013-02-14 06:21
Ryan Davis wrote in post #1096802:
> On Feb 13, 2013, at 16:37 , Loran Kary <lists@ruby-forum.com> wrote:
>
>> Why can't Ruby find my gems when I require them?
>
> To start, make sure that `which gem` and `which ruby` are answering with
> the same install.

Sure, thanks.

bash-3.2$ which ruby
/Users/kary/.rvm/rubies/ruby-1.9.3-p286/bin/ruby
bash-3.2$ which gem
/Users/kary/.rvm/rubies/ruby-1.9.3-p286/bin/gem
bash-3.2$ gem list actionmailer

*** LOCAL GEMS ***

actionmailer (3.2.9)
bash-3.2$ gem which actionmailer
ERROR:  Can't find ruby library file or shared library actionmailer
Posted by Ryan Davis (Guest)
on 2013-02-14 09:00
(Received via mailing list)
On Feb 13, 2013, at 21:21 , Loran Kary <lists@ruby-forum.com> wrote:

> bash-3.2$ which ruby
> /Users/kary/.rvm/rubies/ruby-1.9.3-p286/bin/ruby
> bash-3.2$ which gem
> /Users/kary/.rvm/rubies/ruby-1.9.3-p286/bin/gem
> bash-3.2$ gem list actionmailer
>
> *** LOCAL GEMS ***
>
> actionmailer (3.2.9)
> bash-3.2$ gem which actionmailer
> ERROR:  Can't find ruby library file or shared library actionmailer

% gem which minitest
ERROR:  Can't find ruby library file or shared library minitest

% gem contents minitest | grep lib
/Library/Ruby/Gems/1.8/gems/minitest-4.6.0/lib/hoe/minitest.rb
/Library/Ruby/Gems/1.8/gems/minitest-4.6.0/lib/minitest/autorun.rb
/Library/Ruby/Gems/1.8/gems/minitest-4.6.0/lib/minitest/benchmark.rb
/Library/Ruby/Gems/1.8/gems/minitest-4.6.0/lib/minitest/hell.rb
/Library/Ruby/Gems/1.8/gems/minitest-4.6.0/lib/minitest/mock.rb
/Library/Ruby/Gems/1.8/gems/minitest-4.6.0/lib/minitest/parallel_each.rb
/Library/Ruby/Gems/1.8/gems/minitest-4.6.0/lib/minitest/pride.rb
/Library/Ruby/Gems/1.8/gems/minitest-4.6.0/lib/minitest/spec.rb
/Library/Ruby/Gems/1.8/gems/minitest-4.6.0/lib/minitest/unit.rb

% gem which minitest/unit
/Library/Ruby/Gems/1.8/gems/minitest-4.6.0/lib/minitest/unit.rb

There is no minitest.rb so it bitches. There is a minitest/unit.rb so it 
finds it. The easiest way to figure that out is to just look. I used 
`gem contents` to do that but I also often just go into the code and 
poke around.

In your case, there is no actionmailer.rb, however, there is an 
action_mailer.rb

10006 % pwd
/Users/ryan/Work/git/rails/actionmailer/
10007 % l lib
total 8
0 action_mailer/        8 action_mailer.rb      0 rails/
Posted by Ryan Davis (Guest)
on 2013-02-14 09:01
(Received via mailing list)
On Feb 13, 2013, at 23:59 , Ryan Davis <ryand-ruby@zenspider.com> wrote:

> In your case, there is no actionmailer.rb, however, there is an action_mailer.rb

P.S. Sorry I didn't see that sooner. I don't primarily do rails so I 
didn't notice.
Posted by Loran Kary (skylonder)
on 2013-02-14 19:46
Ryan Davis wrote in post #1096838:

>
> There is no minitest.rb so it bitches. There is a minitest/unit.rb so it
> finds it. The easiest way to figure that out is to just look. I used
> `gem contents` to do that but I also often just go into the code and
> poke around.
>
> In your case, there is no actionmailer.rb, however, there is an
> action_mailer.rb
>

Thanks Ryan, for that help.  Actually, I was just using actionmailer as
an example, because it came at the top of my list of installed gems.

My real problem is that I cannot load my own gem which I created and
installed myself.  I call it 'timecode.

bash-3.2$ gem list timecode

*** LOCAL GEMS ***

timecode (0.0.1)
bash-3.2$ gem contents timecode | grep lib
/Users/kary/.rvm/gems/ruby-1.9.3-p286/gems/timecode-0.0.1/lib/timecode.rb
bash-3.2$ gem which timecode
ERROR:  Can't find ruby library file or shared library timecode

As you can see, there is a lib/timecode.rb yet it won't load.

/Users/kary/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in
`require': cannot load such file -- timecode (LoadError)

Should I be concerned that I do not see any gems directory in my
LOAD_PATH?

/Users/kary/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/site_ruby/1.9.1
/Users/kary/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/site_ruby/1.9.1/x86_64-darwin12.2.0
/Users/kary/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/site_ruby
/Users/kary/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/vendor_ruby/1.9.1
/Users/kary/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/vendor_ruby/1.9.1/x86_64-darwin12.2.0
/Users/kary/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/vendor_ruby
/Users/kary/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1
/Users/kary/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/x86_64-darwin12.2.0

bash-3.2$ gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 1.8.24
  - RUBY VERSION: 1.9.3 (2012-10-12 patchlevel 286)
[x86_64-darwin12.2.0]
  - INSTALLATION DIRECTORY: /Users/kary/.rvm/gems/ruby-1.9.3-p286
  - RUBY EXECUTABLE: /Users/kary/.rvm/rubies/ruby-1.9.3-p286/bin/ruby
  - EXECUTABLE DIRECTORY: /Users/kary/.rvm/gems/ruby-1.9.3-p286/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-darwin-12
  - GEM PATHS:
     - /Users/kary/.rvm/gems/ruby-1.9.3-p286
     - /Users/kary/.rvm/gems/ruby-1.9.3-p286@global
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://rubygems.org/

bash-3.2$ echo $GEM_PATH
/Users/kary/.rvm/gems/ruby-1.9.3-p286:/Users/kary/.rvm/gems/ruby-1.9.3-p286@global
Posted by Ryan Davis (Guest)
on 2013-02-14 20:29
(Received via mailing list)
On Feb 14, 2013, at 10:46, Loran Kary <lists@ruby-forum.com> wrote:

> bash-3.2$ gem which timecode
> ERROR:  Can't find ruby library file or shared library timecode
>
> As you can see, there is a lib/timecode.rb yet it won't load.

Lets assume that your rubygems is not borked, yet.

Show me 'gem spec timecode'
Posted by Loran Kary (skylonder)
on 2013-02-14 21:07
Ryan Davis wrote in post #1096950:
> On Feb 14, 2013, at 10:46, Loran Kary <lists@ruby-forum.com> wrote:
>
>> bash-3.2$ gem which timecode
>> ERROR:  Can't find ruby library file or shared library timecode
>>
>> As you can see, there is a lib/timecode.rb yet it won't load.
>
> Lets assume that your rubygems is not borked, yet.
>
> Show me 'gem spec timecode'

borked ???

To avoid conflicts, I have renamed my gem fps-timecode.  But it behaves 
the same.

bash-3.2$ gem spec fps-timecode
--- !ruby/object:Gem::Specification
name: fps-timecode
version: !ruby/object:Gem::Version
  version: 0.0.1
  prerelease:
  segments:
  - 0
  - 0
  - 1
platform: ruby
authors:
- Loran Kary
autorequire:
bindir: bin
cert_chain: []
date: 2013-02-14 00:00:00.000000000 Z
dependencies: []
description: A library to support drop-frame and non-drop-frame 
timecodes
email: kary@focalpnt.com
executables: []
extensions: []
extra_rdoc_files: []
files: []
homepage:
licenses: []
post_install_message:
rdoc_options: []
require_paths:
- .
required_ruby_version: !ruby/object:Gem::Requirement
  none: false
  requirements:
  - - ! '>='
    - !ruby/object:Gem::Version
      version: '1.9'
required_rubygems_version: !ruby/object:Gem::Requirement
  none: false
  requirements:
  - - ! '>='
    - !ruby/object:Gem::Version
      version: '0'
requirements: []
rubyforge_project:
rubygems_version: 1.8.24
signing_key:
specification_version: 3
summary: Implements timecode class
test_files: []
Posted by Ryan Davis (Guest)
on 2013-02-15 00:36
(Received via mailing list)
On Feb 14, 2013, at 12:07 , Loran Kary <lists@ruby-forum.com> wrote:

>> Show me 'gem spec timecode'
>  version: 0.0.1
> cert_chain: []
> date: 2013-02-14 00:00:00.000000000 Z
> dependencies: []
> description: A library to support drop-frame and non-drop-frame
> timecodes
> email: kary@focalpnt.com
> executables: []
> extensions: []
> extra_rdoc_files: []
> files: []

BOOM. I suggest you use a tool like Hoe to manage your gem. It deals 
with all the gem/project minutia for you.
Posted by Loran Kary (skylonder)
on 2013-02-15 01:58
Ryan Davis wrote in post #1096979:
> On Feb 14, 2013, at 12:07 , Loran Kary <lists@ruby-forum.com> wrote:
>
>>> Show me 'gem spec timecode'
>>  version: 0.0.1
>> cert_chain: []
>> date: 2013-02-14 00:00:00.000000000 Z
>> dependencies: []
>> description: A library to support drop-frame and non-drop-frame
>> timecodes
>> email: kary@focalpnt.com
>> executables: []
>> extensions: []
>> extra_rdoc_files: []
>> files: []
>
> BOOM. I suggest you use a tool like Hoe to manage your gem. It deals
> with all the gem/project minutia for you.

I gather that you see something wrong with the gemspec, though you don't 
say what exactly.

I fiddled with it a little and now it works!  Thanks for your help in 
pointing me to the problem.  Most likely it was an incorrect 
require_path.
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.