【问题标题】:Require forked gem in bundle需要捆绑包中的分叉宝石
【发布时间】:2017-06-26 16:02:12
【问题描述】:

我不得不从 github 分叉一个 gem,并进行一些代码更改以满足我的需要。然后我使用this resource 将其放入我自己的github repo

现在,对于我的应用,我已将 gem 添加到我的 Gemfile

source 'https://rubygems.org'

gem 'openvas-omp', :git => 'git://github.com/godzilla74/openvas-omp-ruby.git'

运行bundle install,现在我正在尝试运行我的应用程序,但它抛出一个错误,说它无法加载我的 gem:

/Users/godzilla74/.rbenv/versions/2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- openvas-omp-ruby (LoadError)
    from /Users/godzilla74/.rbenv/versions/2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from omp.rb:7:in `<main>'

到目前为止,我的应用程序非常简单。只是一个文件omp.rb:

...some other requires....
require 'openvas-omp'

ov = OpenVASOMP::OpenVASOMP.new("host" => "10.10.10.200", "port" => "9390", "user" => 'admin', "password" => 'admin')
puts ov

这是我当前的 omp 应用文件夹树:

.
├── Gemfile
├── Gemfile.lock
├── omp.rb

我是否错误地实施了 gem?据我了解,我不能简单地运行命令gem install openvas-omp,因为这会在我分叉的原始 github 存储库中继续。

【问题讨论】:

  • 您是否使用 bundler exec 运行应用程序,即 bundle exec rails s
  • bundle exec omp.rb -> bundler: command not found: omp.rb

标签: ruby-on-rails ruby github rubygems


【解决方案1】:

您可以使用bundle exec ruby omp.rb 运行您的代码

或者您可以在代码顶部定义捆绑器:

# activate bundler
require 'bundler/setup'
# require all gems
Bundler.require

然后运行它ruby omp.rb

【讨论】:

  • cmets 中建议的解决方案...没有用:bundle exec omp.rb -&gt; bundler: command not found: omp.rb
  • 您在omp.rb 之前错过了ruby 命令。答案已更新为另一种解决方案。
猜你喜欢
  • 2015-09-02
  • 1970-01-01
  • 1970-01-01
  • 2015-07-17
  • 1970-01-01
  • 2013-01-18
  • 1970-01-01
  • 1970-01-01
  • 2017-12-17
相关资源
最近更新 更多