RubyGems load path

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

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 :wink:

HTH,

···

On Nov 19, 10:47 pm, Rodrigo Kochenburger <div...@gmail.com> wrote:

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.

--
Luis Lavena

Sweet! Thanks :slight_smile:

···

On Nov 20, 1:23 am, Luis Lavena <luislav...@gmail.com> wrote:

On Nov 19, 10:47 pm, Rodrigo Kochenburger <div...@gmail.com> wrote:

> 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 :wink:

HTH,
--
Luis Lavena

Rodrigo Kochenburger wrote in post #751168:

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 :wink:

HTH,
--
Luis Lavena

Sweet! Thanks :slight_smile:

Hi, i have problem ruby load path. I couldn't load image file in my
codes. Why? My project file tree is
lib/editor.rb
lib/images/image.jpg
lib/lang.rb
lib/messages.rb
lib/utils.rb
myproject.gemspec
and image.jpg is neccesary in my code. But i couldn't add :frowning: why? It
gives me error
GLib::FileError: Failed to open file 'images/images.jpg': No such file
or directory
        from
/var/lib/gems/1.9.1/gems/MyPorject-1.0.0/lib/editor.rb:21:in `set_icon'
And my project gemspec like this
s.files = ['lib/editor.rb', 'lib/utils.rb', 'lib/messages.rb',
'lib/lang.rb','lib/images/images.jpg]
s.require_paths = ["lib"]

···

On Nov 20, 1:23 am, Luis Lavena <luislav...@gmail.com> wrote:

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

You say image.jpg is the file
But the error shows images.jpg
Delete the s

···

On Feb 8, 2013 2:55 AM, "Ebru Akagunduz" <lists@ruby-forum.com> wrote:

Rodrigo Kochenburger wrote in post #751168:
> On Nov 20, 1:23 am, Luis Lavena <luislav...@gmail.com> wrote:
>>
>> 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 :wink:
>>
>> HTH,
>> --
>> Luis Lavena
>
> Sweet! Thanks :slight_smile:

Hi, i have problem ruby load path. I couldn't load image file in my
codes. Why? My project file tree is
lib/editor.rb
lib/images/image.jpg
lib/lang.rb
lib/messages.rb
lib/utils.rb
myproject.gemspec
and image.jpg is neccesary in my code. But i couldn't add :frowning: why? It
gives me error
GLib::FileError: Failed to open file 'images/images.jpg': No such file
or directory
        from
/var/lib/gems/1.9.1/gems/MyPorject-1.0.0/lib/editor.rb:21:in `set_icon'
And my project gemspec like this
s.files = ['lib/editor.rb', 'lib/utils.rb', 'lib/messages.rb',
'lib/lang.rb','lib/images/images.jpg]
s.require_paths = ["lib"]

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

may i suggest also spell check
MyPorject-1.0.0/
usually spelled as MyProject

···

On Fri, Feb 8, 2013 at 11:21 PM, Chris Hulan <chris.hulan@gmail.com> wrote:

You say image.jpg is the file
But the error shows images.jpg
Delete the s
On Feb 8, 2013 2:55 AM, "Ebru Akagunduz" <lists@ruby-forum.com> wrote:

Rodrigo Kochenburger wrote in post #751168:
> On Nov 20, 1:23 am, Luis Lavena <luislav...@gmail.com> wrote:
>>
>> 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 :wink:
>>
>> HTH,
>> --
>> Luis Lavena
>
> Sweet! Thanks :slight_smile:

Hi, i have problem ruby load path. I couldn't load image file in my
codes. Why? My project file tree is
lib/editor.rb
lib/images/image.jpg
lib/lang.rb
lib/messages.rb
lib/utils.rb
myproject.gemspec
and image.jpg is neccesary in my code. But i couldn't add :frowning: why? It
gives me error
GLib::FileError: Failed to open file 'images/images.jpg': No such file
or directory
        from
/var/lib/gems/1.9.1/gems/MyPorject-1.0.0/lib/editor.rb:21:in `set_icon'
And my project gemspec like this
s.files = ['lib/editor.rb', 'lib/utils.rb', 'lib/messages.rb',
'lib/lang.rb','lib/images/images.jpg]
s.require_paths = ["lib"]

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