using gems without installing them (like jar files)

S

Suraj Kurapati

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.
 
E

Eric Hodel

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.
 
S

Suraj Kurapati

Eric said:
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.
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.
 
E

Eric Hodel

Awesome! Did not know about GEM_HOME.


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.

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top