How do I freeze gems into a Rails 3 application?

后端 未结 13 2002
遇见更好的自我
遇见更好的自我 2020-12-08 16:30

I want to freeze a specific gem into my Rails application.

In rails 2 there was this command:

rake gems:unpack

I can\'t find that c

相关标签:
13条回答
  • 2020-12-08 17:25

    Assuming you already have bundler gem installed:

    • $ bundle lock
    • $ git add Gemfile.lock
    0 讨论(0)
  • 2020-12-08 17:27

    I haven't had to do this yet, but I believe it's all handled by bundler.

    When you create a new rails3 app, the rails dependencies are put into your Gemfile. You can run bundle install to install them. By default, they are installed into your BUNDLE_PATH.

    If you want to install them within your app, you can specify where: bundle install vendor/gems.

    0 讨论(0)
  • 2020-12-08 17:27

    I think what you are looking for is

    bundle package
    

    checkout the man pages here: http://gembundler.com/man/bundle-package.1.html

    0 讨论(0)
  • 2020-12-08 17:29

    DO NOT USE THE "RECOMMENDED" ANSWER BY NFM!

    Instead, review the Bundler site, particularly the page on deployments: http://gembundler.com/deploying.html

    The short summary is to use specific versions in your Gemfile and run bundle install --deployment on each target system where you need the exact gem versions.

    Using the --path option will install the gems, but it's not really what you want to do. As Matt Enright said, you just bloat your SCM with stuff that bundler can handle smartly on each target environment.

    0 讨论(0)
  • 2020-12-08 17:34

    The command that you want is bundle package which just unpacks the gems and dependencies at vendor/cache folder.

    But just a notice, the :git => .... kind of gems wont get packaged. You have to hack a way out for :git => ... related gems to get packed.

    0 讨论(0)
  • 2020-12-08 17:36

    A lot of comments are somewhat saying that it's not useful to use the bundle install --path vendor/gems, but those people who are using Dreamhost, it should note that you cannot use bundle install in Dreamhost.

    The solution is to get all the gems into the vendor folder and upload the whole thing to the Dreamhost directory.

    There are other solutions to turn around this, but it's much more complicated to do.

    0 讨论(0)
提交回复
热议问题