Bundle Install to Development

Bundle install to development

The explanation to that is in in the bundler manual. Read the heading Grouping Your Dependencies. Specifically

Bundler will remember that you installed the gems using --without production. For curious readers, bundler stores the flag in APP_ROOT/.bundle/config. You can see all of the settings that bundler saved there by running bundle config, which will also print out global settings (stored in ~/.bundle/config), and settings set via environment variables. For more information on configuring bundler, please see Advanced Usage: Configuring Bundler.

And the solution is to pass a different value for the property or remove the file APP_ROOT/.bundle/config.

Rails bundle install production only

THIS ANSWER IS OUTDATED


Take a look at --without option:

bundle install --without development test

By default Bundler installs all gems and your application uses the gems that it needs. Bundler itself knows nothing about Rails and the current environment.

What does bundle install --without production do?

If you have a group inside your Gemfile like

group :production do
gem 'whatever'
end

Then when you run your bundle command on your development machine, it won't install the gems intended for use in your production environment. Basically only installing the gems you need in development on your development machine.

bundler incorrectly trying to install development and test group gems in production

After a lot of digging I found the fix for this issue. All I had to do was run bundle install --without development test before starting the server. This adds a .bundle/config file in the rails root with the line BUNDLE_WITHOUT: test:development . Now whenever you run bundle install or start the server it'll ignore those groups.

From the documentation

The Bundler CLI allows you to specify
a list of groups whose gems bundle
install should not install with the
--without option. To specify multiple groups to ignore, specify a list of
groups separated by spaces.

bundle install --without test bundle
install --without development test
After running bundle install --without
test, bundler will remember that you
excluded the test group in the last
installation. The next time you run
bundle install, without any --without
option, bundler will recall it.

Also, calling Bundler.setup with no
parameters, or calling require
"bundler/setup" will setup all groups
except for the ones you excluded via
--without (since they are obviously not available).

Is there a way to gem install to only the development environment, or test?

You can't do this via gem as the Gemfile is used by Bundler. However, since Bundler version 1.15.0 you can use bundle add:

bundle add web-console --group development

This will then add the following line to your Gemfile:

gem "web-console", "~> 3.6", :group => [:development]

how to include bundler itself when using bundle install --deployment

The reason this doesn't work is because Bundler.setup is the code that actually sets up your load path to find the vendored gems. If Bundler were vendored, it wouldn't be able to find it to do that setup.

You can do one of two things:

  1. Install Bundler as a system gem. This is the most common solution. You could build a separate RPM to install it (or maybe there's already one out there you can use) and depend on it in your app's RPM.

  2. Use Bundler's standalone mode. This will give you an application that does not depend on Bundler at all. In that case, you should remove the require 'bundler' and Bundler.setup lines from your application and instead add require_relative 'bundle/bundler/setup' (with the path adjusted if you're calling it from a file located somewhere other than the root directory of your project).

Bundler: You are trying to install in deployment mode after changing your Gemfile

The error message you're getting regarding Gemfile.lock may be because your Gemfile and Gemfile.lock don't agree with each other. It sounds like you've changed something in your Gemfile since you last ran bundle install (or update). When you bundle install, it updates your Gemfile.lock with any changes you've made to Gemfile.

Make sure you run bundle install locally, and check-in to source control your newly updated Gemfile.lock after that. Then try deploying.

Edit: As recognised in the comments, a conditional in the Gemfile resulted in a valid Gemfile.lock on one platform, invalid on another. Providing a :platform flag for these platform-dependent gems in the Gemfile should solve the asymmetry.

bundle install --without production remediates error, but why? ( Make sure that `gem install pg -v '0.18.1'` succeeds before bundling)

The best resource answering the "why" component of this question appears to be explained thusly by Michael Hartl's Ruby on Rails Tutorial:

"Heroku uses the PostgreSQL database...which means that we need to add the pg gem in the production environment to allow Rails to talk to Postgres...Generally speaking, it's a good idea for the development and production environments to match each other as closely as possible, which includes using the same database, however we'll use SQLite locally and PostgreSQL in production."

So, basically it appears that the issue is a matter of maintaining conventions between two different environments- production and development (local)- and more specifically, database types (Postgres vs SQLite), which is why bundle install --without production is required:

"To prepare the system for deployment to production, we run bundle install with a special flag to prevent the local installation of any production gems (which in this case consist of ph and rails_12factor)...Because the only gems added are restricted to a production environment, right now this command doesn't actually install any additional local gems, but it's needed to update Gemfile.lock with the pg and rails_12factor gems."

If the remediation for Heroku deployment bundle install --without production is an acceptable alternative to bundle install, it just seems too bad to be true; if so, is there another setting or file I can revise in order to achieve the same results effected by the regular bundle install? Thanks!



Related Topics



Leave a reply



Submit