Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I save whole package of Rails App including gems being used?

I'm using a lot of gems. They are really sensitive about dependencies each other.
Now, current combination of the gems is just perfect. I want to save this whole App, and re-use this when I'm going on next project.

As you know, the gems are not promised to exist in the future in rubygem.org
So I'd like to save whole package of both App and gems being used. Then I don't need to care about setting up gems unless I need new gem. All I need to care about is just coding in next project.

Someone told me to use this command and save whole App folder

bundle install --path=vendor/bundle

After this, my app got screwed :( jQuery came not to work anymore after recompile

So I did need to replace whole App folder with old one, which was reffering the gem in /usr/local/bin/ruby /usr/local/lib/ruby/gems/1.9.1

Now, jQuery works fine after recompile :)

For this situation, how can I save whole package of both App and gems being used for it?

What I wanna do is, I only want to set up Ruby's correct version and MySQL.
Then I'd like to put this package into it and start coding, not deploying environment about gems!!

Can anyone share idea about this, please?

like image 518
cat Avatar asked Apr 26 '13 02:04

cat


1 Answers

Answer to your question

Bundler's bundle package --all command will lock and cache all of your gem files into ./vendor/cache, and you can run bundle install --local so it won't check rubygems.org in the future.

Comments on your question

This question made me cringe because, while I understand the interest in having a "base image" that you know works, it sounds like a few problems will spill over to other projects.

  1. Overburdened applications
    • Does each project really need all the same dependencies?
    • If not, then you are bloating each install with unneeded dependencies.
  2. Brittle dependencies
    • You mention that your dependencies are very sensitive to each other, which sets off alarms.
    • I don't fully understand what you mean by that, but it sounds like you should consider finding dependencies with more stable interfaces.
    • Check out ruby-toolbox.com and keep an eye on the "Released" date.
  3. Outdated dependencies
    • Locking down versions means your new applications will not benefit from updates by the maintainers.
    • (example) if you locked your rails dependency to 3.2.8 and continue to use it, you open yourself (and customers) to several major security holes.
    • (possible fix) Look at pessimistic version constraints to allow your applications to receive non-breaking fixes.

Best of luck.

like image 105
jstim Avatar answered Nov 04 '22 21:11

jstim