Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby 无法要求本地gem_Ruby_Gem - Fatal编程技术网

Ruby 无法要求本地gem

Ruby 无法要求本地gem,ruby,gem,Ruby,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.

创建了一个演示宝石 建造它:

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>'
捆绑显示输出:

bundle show
Gems included by the bundle:
  * bundler (1.7.9)
  * process_controller (0.0.1)
下面是目录结构的屏幕截图

事实证明,您不需要gem,您需要的是主文件名。 就我而言,它是:

require 'control'

非常感谢@matt

您不需要gem,您需要一个文件–gem的lib dir中是否有名为
process\u controller.rb
的文件?另外:“因为它在控制目录中”——您在这里指的是什么,是gem本身还是文件?您可能只需要
require'control/process\u controller'
。谢谢,我使用了require'control'。约定是在其中有一个与gem同名的文件作为主文件,因此看起来您可能需要gem,但实际情况并非如此(也并非总是如此)。
require 'control'