x-yuri x-yuri - 1 month ago 10
Ruby Question

How to install additional gems with bundler in production environment?

I have a staging server. And I've got some issue I'd like to investigate right there. But I forgot to add

byebug
to
Gemfile
. I can surely add it locally, run
bundle
, commit to repository, deploy. But isn't there an easier way?

When I try to change
Gemfile
remotely and run
bundle
I get:

You are trying to install in deployment mode after changing
your Gemfile. Run `bundle install` elsewhere and add the
updated Gemfile.lock to version control.

If this is a development machine, remove the /home/gccs/website-backend/releases/20161018143057/Gemfile freeze
by running `bundle install --no-deployment`.

You have added to the Gemfile:
* byebug


Gems are installed with
capistrano
, basically, like so:

bundle install --path /home/user/app/shared/bundle --without development test --deployment --quiet

Answer

Edit .bundle/config changing BUNDLE_FROZEN: '1' to '0' (or removing it) is enough in order to be allowed by Bundler to manage gems in a deployment environment. Then you can edit the Gemfile, run bundle, restart your application and the custom gems are ready to be used.

If you intend to use them outside of the application runtime (f.e. if you need pry in rails console) restarting the server is not needed.