В моем mygem.gemspec у меня есть следующий гем, который я хочу только для целей отладки моего рубинового камня -
Gem::Specification.new do |s|
...
s.add_development_dependency "pry"
...
end
Затем в моем файле генератора Rails у меня есть require "pry"
, однако я получаюследующая ошибка -
.rvm/gems/ruby-2.3.3/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `require': cannot load such file -- pry (LoadError)
Если я изменю add_development_dependency
на add_dependency
, это работает.Я что-то не так делаю?
Редактировать:
lib / generators / mygem / install_generator.rb
require "pry"
module MyGem
module Generators
class InstallGenerator < Rails::Generators::Base
namespace "mygem:install"
def process
binding.pry
end
end
end
end
трассировка полного стека
$ rails g mygem:install
Running via Spring preloader in process 99478
.rvm/gems/ruby-2.3.3/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `require': cannot load such file -- pry (LoadError)
from .rvm/gems/ruby-2.3.3/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `block in require'
from .rvm/gems/ruby-2.3.3/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:258:in `load_dependency'
from .rvm/gems/ruby-2.3.3/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `require'
from Projects/mygem/gem/mygem/lib/generators/cast/install_generator.rb:1:in `<top (required)>'
from .rvm/gems/ruby-2.3.3/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `require'
from .rvm/gems/ruby-2.3.3/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `block in require'
from .rvm/gems/ruby-2.3.3/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:258:in `load_dependency'
from .rvm/gems/ruby-2.3.3/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `require'
from .rvm/gems/ruby-2.3.3/gems/railties-5.1.6/lib/rails/command/behavior.rb:82:in `block (2 levels) in lookup'
from .rvm/gems/ruby-2.3.3/gems/railties-5.1.6/lib/rails/command/behavior.rb:78:in `each'
from .rvm/gems/ruby-2.3.3/gems/railties-5.1.6/lib/rails/command/behavior.rb:78:in `block in lookup'
from .rvm/gems/ruby-2.3.3/gems/railties-5.1.6/lib/rails/command/behavior.rb:77:in `each'
from .rvm/gems/ruby-2.3.3/gems/railties-5.1.6/lib/rails/command/behavior.rb:77:in `lookup'
from .rvm/gems/ruby-2.3.3/gems/railties-5.1.6/lib/rails/generators.rb:250:in `find_by_namespace'
from .rvm/gems/ruby-2.3.3/gems/railties-5.1.6/lib/rails/generators.rb:267:in `invoke'
from .rvm/gems/ruby-2.3.3/gems/railties-5.1.6/lib/rails/commands/generate/generate_command.rb:24:in `perform'
from .rvm/gems/ruby-2.3.3/gems/thor-0.20.0/lib/thor/command.rb:27:in `run'
from .rvm/gems/ruby-2.3.3/gems/thor-0.20.0/lib/thor/invocation.rb:126:in `invoke_command'
from .rvm/gems/ruby-2.3.3/gems/thor-0.20.0/lib/thor.rb:387:in `dispatch'
from .rvm/gems/ruby-2.3.3/gems/railties-5.1.6/lib/rails/command/base.rb:63:in `perform'
from .rvm/gems/ruby-2.3.3/gems/railties-5.1.6/lib/rails/command.rb:44:in `invoke'
from .rvm/gems/ruby-2.3.3/gems/railties-5.1.6/lib/rails/commands.rb:16:in `<top (required)>'
from .rvm/gems/ruby-2.3.3/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `require'
from .rvm/gems/ruby-2.3.3/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `block in require'
from .rvm/gems/ruby-2.3.3/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:258:in `load_dependency'
from .rvm/gems/ruby-2.3.3/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `require'
from Projects/mygem/themes/sample/bin/rails:9:in `<top (required)>'
from .rvm/gems/ruby-2.3.3/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:286:in `load'
from .rvm/gems/ruby-2.3.3/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:286:in `block in load'
from .rvm/gems/ruby-2.3.3/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:258:in `load_dependency'
from .rvm/gems/ruby-2.3.3/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:286:in `load'
from .rvm/rubies/ruby-2.3.3/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:59:in `require'
from .rvm/rubies/ruby-2.3.3/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:59:in `require'
from -e:1:in `<main>'
Редактировать:
Вот пример драгоценного камня с проблемой - https://github.com/ryangrush/stackoverflow_ruby_gem