2

I need to freeze two gems and make my project refer to those gems from its project folder.

I know many ways to do it in Rails, but how do I do it manually in Ruby?

I am using jeweler based on advice from my previous question "Starting a Ruby project: github + build tool".

Community
  • 1
  • 1
zengr
  • 38,346
  • 37
  • 130
  • 192
  • I think, my next question should be "Is Ruby == Ruby on Rails these days?". No one uses Ruby alone, but use Ruby with Rails for web apps. – zengr Aug 03 '10 at 08:22

3 Answers3

2

You could use them independently of the rubygems infrastructure by first unpacking each gem into vendor/gems (or whatever path within your project):

cd yourapp
mkdir -p vendor/gems
cd vendor/gems
gem unpack gem1
gem unpack gem2
[etc.]

... and then adding all the frozen gems' lib directories into your load path:

$:.unshift(*Dir[File.dirname(__FILE__) + "/vendor/gems/**/lib"])
Daniel Vandersluis
  • 91,582
  • 23
  • 169
  • 153
0

What about using Bundler? You could simply lock your application gems with it.

tbuehlmann
  • 9,032
  • 5
  • 27
  • 33
  • yea, Bundler is an option, but this wont make a desktop app truely portable. In rails we have an option for rake freezen:gems. Can we replicate a similar functionality? How? – zengr Aug 03 '10 at 09:43
0

My first suggestion would also be to use Bundler and lock your bundle. You can even put the bundle inside your application directory if you want to distribute the gems with it, though this might lead to problems if a gem contains an extension with native code and you're distributing it to a different platform.

By the way, Rails 3 uses Bundler for gem management exclusively. There will be no rake rails:freeze:gems in Rails 3 anymore.

As another option, if you don't want to use Bundler for some reason, you could manually put the lib dir of a gem to some subdirectory of the lib dir in your app, add it to your load path and require it manually. If a gem contains pure Ruby code without any extension this might do well but it would be hard to maintain since you'd need to do updates manually.

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
Zargony
  • 9,615
  • 3
  • 44
  • 44