:note

require_reloader.gemでLoadErrorになるgem

サーバの再起動無しにgemをリロードする require_reloader つかってみた

teohm/require_reloader

こういう↓名前空間つきのgemだとエラーになるっぽい

# name-space-test_foo/lib/name/space/test_foo.rb
# localgem
require "name/space/test_foo/version"

module Name
  module Space
    module TestFoo
      # Your code goes here...
      puts :Fooooo
    end
  end
end
# Gemfile
# ローカルgemを再起動なしにリロード
gem 'require_reloader', group: :development
gem 'name-space-test_foo', path: "../name-space-test_foo" # => localgem
# config/environments/development.rb
  RequireReloader.watch_local_gems!

railsサーバを起動するとエラーになる

% bundle exec rails s
Fooooo
=> Booting WEBrick
=> Rails 4.1.5 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Notice: server is listening on all interfaces (0.0.0.0). Consider using 127.0.0.1 (--binding option)
=> Ctrl-C to shutdown server
Exiting
/Users/milligramme/.rbenv/versions/2.0.0-p576/lib/ruby/gems/2.0.0/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:247:in `require': cannot load such file -- name-space-test_foo (LoadError)
  from /Users/milligramme/.rbenv/versions/2.0.0-p576/lib/ruby/gems/2.0.0/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:247:in `block in require'
  from /Users/milligramme/.rbenv/versions/2.0.0-p576/lib/ruby/gems/2.0.0/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:232:in `load_dependency'
  from /Users/milligramme/.rbenv/versions/2.0.0-p576/lib/ruby/gems/2.0.0/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:247:in `require'
  from /Users/milligramme/.rbenv/versions/2.0.0-p576/lib/ruby/gems/2.0.0/gems/require_reloader-0.2.0/lib/require_reloader.rb:56:in `block (2 levels) in watch'
  .....
 
comments powered by Disqus
back to top