Whats the difference between bundle install --deployment and bundle pack

21,589

Solution 1

Have a look at the description of the two on Bundler's site.

Running bundle install --deployment is to be run in the production environment, but will grab the gems from rubygems when run. Read more here under the 'Deploying Your Application' heading for the purpose of the --deployment flag.

bundle package is similar to the old rake rails:gems:freeze command from Rails 2.3. It grabs the gems and packages them in vendor/cache. From the bundler site here:

You can use this to avoid a dependency on rubygems.org at deploy time, or if you have private gems that are not in a public repository

Solution 2

I use bundle install --path vendor/bundle in development mode. bundle install --deployment will lock yor Gemfile.lock and will not update it when you change your Gemfile, so never use deployment option on development environment. bundle install --no-deployment will disable bundle deployment mode. You can read that post about bundle usage in right way.

Solution 3

I explained the reasoning behind the --deployment mode flag at pretty great length in a talk I gave at RailsConf 2011. This blog post contains my notes for that talk, and (I hope) covers all of the reasoning behind the way --deployment works: http://andre.arko.net/2011/06/11/deploying-with-bundler-notes/

Share:
21,589
concept47
Author by

concept47

Ruby/Rails/jQuery hacker. Elasticsearch enthusiast.

Updated on October 18, 2020

Comments

  • concept47
    concept47 over 3 years

    I know they both put the gems in your app in different locations but it seems as if bundle install --deployment does a more thorough job. Can I just add the vendor/bundle directory it creates to version control and be done?

  • concept47
    concept47 almost 13 years
    Great response helped me understand the above response better
  • concept47
    concept47 almost 13 years
    Thank you for that, it took me reading and re-reading the doc to get a full understanding of what you were saying ... had to wrap my head around the fact that you still have to run 'bundle install' on the production server, even if you use bundle pack and check the vendor/cache folder into source control
  • Ricardo Castañeda
    Ricardo Castañeda about 12 years
    Thanks, the --no-deployment explanation helped me to run in localhost a downloaded app from the server.
  • Mojo
    Mojo almost 12 years
    bundle --install deployment grabs the gems from rubygems. But what if you've done a bundle package and your vendor/cache is primed with gems? It looks to me like bundle install --deployment continues to hit rubygems to get gems.
  • Rick Smith
    Rick Smith over 8 years
    Thanks for the link. This post is now a few years old, are there any changes I should be aware of?