Using gems without installing them (like jar files)

Hello,

Is it possible to use gem files without having to install them, like you
can with jar files in Java?

For instance, I have a gem/ directory containing various gems, and I
would like to add gem/ to the load path and simply require() the gem by
name:

  # add gem/ to load path
  $: << File.join(File.dirname(__FILE__), 'gem')

  # use the 'foo' gem
  require 'foo' # loads gem/foo-1.0.0.gem/lib/foo.rb

If gem files in the load path can be treated as a virtual file system
(VFS) then this should be possible, no?

Thanks for your consideration.

···

--
Posted via http://www.ruby-forum.com/.

Is it possible to use gem files without having to install them, like you
can with jar files in Java?

No.

For instance, I have a gem/ directory containing various gems, and I
would like to add gem/ to the load path and simply require() the gem by
name:

# add gem/ to load path
$: << File.join(File.dirname(__FILE__), 'gem')

# use the 'foo' gem
require 'foo' # loads gem/foo-1.0.0.gem/lib/foo.rb

Instead you can do:

gem install -i ~/tmp/gems foo
GEM_HOME=~/tmp/gems ruby my_foo_using_program.rb
rm -r ~/tmp/gems

If gem files in the load path can be treated as a virtual file system
(VFS) then this should be possible, no?

Somebody would need to write that code, but it would only work for gems without extensions to be compiled, and would not generate useful documentation.

···

On Jun 30, 2008, at 13:06 PM, Suraj Kurapati wrote:

Eric Hodel wrote:

Instead you can do:

gem install -i ~/tmp/gems foo
GEM_HOME=~/tmp/gems ruby my_foo_using_program.rb
rm -r ~/tmp/gems

Awesome! Did not know about GEM_HOME.

If gem files in the load path can be treated as a virtual file system
(VFS) then this should be possible, no?

Somebody would need to write that code, but it would only work for
gems without extensions to be compiled, and would not generate useful
documentation.

Those limitations are acceptable for me, as I'm trying to use pure-Ruby
gems anyway. I'll try to write the VFS code during this holiday weekend
and submit a patch next week.

Cheers.

···

--
Posted via http://www.ruby-forum.com/\.

Were I writing it, I would make a Kernel#require overlay that knows how to look inside a .gem file for the things it needs. No need to extend File.

···

On Jun 30, 2008, at 15:37 PM, Suraj Kurapati wrote:

Eric Hodel wrote:

Instead you can do:

gem install -i ~/tmp/gems foo
GEM_HOME=~/tmp/gems ruby my_foo_using_program.rb
rm -r ~/tmp/gems

Awesome! Did not know about GEM_HOME.

If gem files in the load path can be treated as a virtual file system
(VFS) then this should be possible, no?

Somebody would need to write that code, but it would only work for
gems without extensions to be compiled, and would not generate useful
documentation.

Those limitations are acceptable for me, as I'm trying to use pure-Ruby
gems anyway. I'll try to write the VFS code during this holiday weekend
and submit a patch next week.