RubyGems load path

  • Thread starter Rodrigo Kochenburger
  • Start date
R

Rodrigo Kochenburger

Hi Guys,

How can i change the RubyGem load path, so that requiring a gem from
within my application loads it from a custom path instead of the
system-wide repository?

I've tried setting Gem.path and overriding Gem.default_path but none
worked.

Cheers
 
L

Luis Lavena

Hi Guys,

How can i change the RubyGem load path, so that requiring a gem from
within my application loads it from a custom path instead of the
system-wide repository?

I've tried setting Gem.path and overriding Gem.default_path but none
worked.

You should look into GEM_PATH and GEM_HOME environment variables.

Merb is doing something similar, making their bundled gems first in
the search of GEM_PATH.

You can do something like this:

require 'rubygems'
Gem.clear_paths
ENV['GEM_HOME'] = File.join(Dir.pwd, 'gems')
ENV['GEM_PATH'] = File.join(Dir.pwd, 'gems')
puts Gem.dir
puts Gem.path

Now you can do your show adding or removing gems from there ;-)

HTH,
 
R

Rodrigo Kochenburger

How can i change the RubyGem load path, so that requiring a gem from
within my application loads it from a custom path instead of the
system-wide repository?
I've tried setting Gem.path and overriding Gem.default_path but none
worked.

You should look into GEM_PATH and GEM_HOME environment variables.

Merb is doing something similar, making their bundled gems first in
the search of GEM_PATH.

You can do something like this:

require 'rubygems'
Gem.clear_paths
ENV['GEM_HOME'] = File.join(Dir.pwd, 'gems')
ENV['GEM_PATH'] = File.join(Dir.pwd, 'gems')
puts Gem.dir
puts Gem.path

Now you can do your show adding or removing gems from there ;-)

HTH,

Sweet! Thanks :)
 

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