未能要求本地宝石

时间:2015-02-13 18:59:55

标签: ruby gem

创建了一个demo 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

捆绑show show:

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

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

1 个答案:

答案 0 :(得分:2)

原来你不能要求宝石,你必须要求主文件名。 就我而言:

require 'control'

非常感谢@matt