未能要求本地 gem

failed to require a local gem

创建了一个演示 gem 建造它:

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

已安装:

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

但我似乎不需要它:

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>'

也试过

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

捆绑显示输出:

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

这是目录结构的屏幕截图 http://cl.ly/image/2t1s331e273u

原来你不能要求 gem,你必须要求主文件名。 在我的例子中是:

require 'control'

非常感谢@matt