how to load new installed gems after server started in development mode

11 views
Skip to first unread message

Jeremy Li

unread,
Dec 19, 2014, 9:48:17 PM12/19/14
to ruby-b...@googlegroups.com
in development mode, changes to my codes will work immediately. 
 when i  add 'gem "qiniu"' to Gemfile and run 'bundle install', and then create a initialize  file(config/initializers/qiniu_sdk.rb)
i expect that the new installed gem is loaded
but, when i call methods in the new  gem, it will go wrong like this "uninitialized constant OtherController::Qiniu"
and i don't want to restart the web  server,  how to achieve that?

Tim Moore

unread,
Dec 21, 2014, 5:41:40 PM12/21/14
to ruby-b...@googlegroups.com
This isn't possible. The load path is set and initializers are run when the server starts up. Code reloading is meant to be for the classes in your app directory.
--
You received this message because you are subscribed to the Google Groups "ruby-bundler" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-bundler...@googlegroups.com.
To post to this group, send email to ruby-b...@googlegroups.com.
Visit this group at http://groups.google.com/group/ruby-bundler.
For more options, visit https://groups.google.com/d/optout.

Jeremy Li

unread,
Jan 4, 2015, 11:54:14 PM1/4/15
to ruby-b...@googlegroups.com
is it possible to change the default behavior of bundle install to load new installed gems?(we can get the list of loaded gems, and only load the new installed and not already loaded gems)

在 2014年12月22日星期一UTC+8上午6时41分40秒,Tim Moore写道:
This isn't possible. The load path is set and initializers are run when the server starts up. Code reloading is meant to be for the classes in your app directory.

On Saturday, 20 December 2014, Jeremy Li <beexp...@gmail.com> wrote:
in development mode, changes to my codes will work immediately. 
 when i  add 'gem "qiniu"' to Gemfile and run 'bundle install', and then create a initialize  file(config/initializers/qiniu_sdk.rb)
i expect that the new installed gem is loaded
but, when i call methods in the new  gem, it will go wrong like this "uninitialized constant OtherController::Qiniu"
and i don't want to restart the web  server,  how to achieve that?

--
You received this message because you are subscribed to the Google Groups "ruby-bundler" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-bundler+unsubscribe@googlegroups.com.

Tim Moore

unread,
Jan 5, 2015, 6:57:25 PM1/5/15
to ruby-b...@googlegroups.com
bundle install can't change what's loaded into your server process, but it would be possible in theory for Rails to call Bundler.require on every request in development mode.

I just did a Google search for "rails development reload" and this came up: https://github.com/teohm/require_reloader

I haven't used it, your milage may vary. I can think of lots of ways this could subtly fail (such as Rails engines, any persistent references to instances of classes loaded from a gem), and would recommend restarting your server when you change your Gemfile.

To unsubscribe from this group and stop receiving emails from it, send an email to ruby-bundler...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages