Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

failed to require a local gem

Tags:

ruby

rubygems

created a demo gem built it :

gem build control.gemspec
  Successfully built RubyGem
  Name: process_controller
  Version: 0.0.1
  File: process_controller-0.0.1.gem

installed it:

gem install --local process_controller-0.0.1.gem
Successfully installed process_controller-0.0.1
1 gem installed

but I can't seem to require it :

irb (from the installed directory)
2.1.5 :001 > require 'process_controller'
LoadError: cannot load such file -- process_controller
    from /Users/partuck/.rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /Users/partuck/.rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from (irb):1
    from /Users/partuck/.rvm/rubies/ruby-2.1.5/bin/irb:11:in `<main>'

also tried

require 'control' # since it's in the control directory

bundle show output:

bundle show
Gems included by the bundle:
  * bundler (1.7.9)
  * process_controller (0.0.1)

here is a screen shot of the directory structure http://cl.ly/image/2t1s331e273u

like image 950
WebQube Avatar asked Sep 14 '25 02:09

WebQube


1 Answers

turns out you can't require the gem, you have to require the main file name. in my case its:

require 'control'

thanks a lot @matt

like image 119
WebQube Avatar answered Sep 17 '25 19:09

WebQube



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!