[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

How to reload available rubygems in a long running process

Tom Werner

11/12/2007 6:48:00 PM

In my Ruby monitoring framework, god, I have the ability to load
configuration files into an already running god instance. This allows
the user to create new watches without having to restart god. There is a
problem, however, if the config file to be loaded requires a gem that
was installed *after* god was started. The rubygems system discovers and
caches the available gems when it is initially required, ignoring any
gems that are installed after that.

I have not been able to find an easy way to have rubygems reload its
cache of available gems from a running Ruby program. Does anyone know of
a decent way to accomplish this?

--
Tom Preston-Werner

* Libraries:
Chronic (chronic.rubyforge.org)
God (god.rubyforge.org)
Fuzed (fuzed.rubyforge.org)
* Site:
rubyisawesome.com


14 Answers

Eric Hodel

11/13/2007 7:37:00 PM

0

On Nov 12, 2007, at 10:48 , Tom Werner wrote:
> In my Ruby monitoring framework, god, I have the ability to load
> configuration files into an already running god instance. This
> allows the user to create new watches without having to restart
> god. There is a problem, however, if the config file to be loaded
> requires a gem that was installed *after* god was started. The
> rubygems system discovers and caches the available gems when it is
> initially required, ignoring any gems that are installed after that.
>
> I have not been able to find an easy way to have rubygems reload
> its cache of available gems from a running Ruby program. Does
> anyone know of a decent way to accomplish this?

Gem.clear_paths

--
Poor workers blame their tools. Good workers build better tools. The
best workers get their tools to do the work for them. -- Syndicate Wars



Tom Werner

11/14/2007 7:40:00 AM

0

Note: parts of this message were removed by the gateway to make it a legal Usenet post.

On 11/13/07, Eric Hodel <drbrain@segment7.net> wrote:
>
> On Nov 12, 2007, at 10:48 , Tom Werner wrote:
> > In my Ruby monitoring framework, god, I have the ability to load
> > configuration files into an already running god instance. This
> > allows the user to create new watches without having to restart
> > god. There is a problem, however, if the config file to be loaded
> > requires a gem that was installed *after* god was started. The
> > rubygems system discovers and caches the available gems when it is
> > initially required, ignoring any gems that are installed after that.
> >
> > I have not been able to find an easy way to have rubygems reload
> > its cache of available gems from a running Ruby program. Does
> > anyone know of a decent way to accomplish this?
>
> Gem.clear_paths
>
>
This does not appear to work. Here is my test procedure:

# --> cheat gem is NOT installed

require 'rubygems'

begin
require 'cheat'
rescue LoadError
# --> so this gets executed
puts 'fail'
end

gets

# --> program pauses and I install cheat gem
# sudo gem install cheat

Gem.clear_paths

begin
require 'cheat'
rescue LoadError
# --> require STILL fails even though Gem:all_load_paths
# now contains the cheat gem's directory
puts 'fail'
end

--
Tom Preston-Werner

* Libraries:
Chronic (chronic.rubyforge.org)
God (god.rubyforge.org)
Fuzed (fuzed.rubyforge.org)
* Site:
rubyisawesome.com

Eric Hodel

11/14/2007 7:53:00 AM

0

On Nov 13, 2007, at 23:39 , Tom Werner wrote:
> On 11/13/07, Eric Hodel <drbrain@segment7.net> wrote:
>> On Nov 12, 2007, at 10:48 , Tom Werner wrote:
>>> I have not been able to find an easy way to have rubygems reload
>>> its cache of available gems from a running Ruby program. Does
>>> anyone know of a decent way to accomplish this?
>>
>> Gem.clear_paths
>
> This does not appear to work. Here is my test procedure:
>
> [...]

Hrm, with RubyGems 0.9.4.7 I ran your script and I get one fail, not
two.

--
Poor workers blame their tools. Good workers build better tools. The
best workers get their tools to do the work for them. -- Syndicate Wars



Tom Werner

11/14/2007 8:05:00 AM

0

Note: parts of this message were removed by the gateway to make it a legal Usenet post.

On 11/13/07, Eric Hodel <drbrain@segment7.net> wrote:
>
> On Nov 13, 2007, at 23:39 , Tom Werner wrote:
> > On 11/13/07, Eric Hodel <drbrain@segment7.net> wrote:
> >> On Nov 12, 2007, at 10:48 , Tom Werner wrote:
> >>> I have not been able to find an easy way to have rubygems reload
> >>> its cache of available gems from a running Ruby program. Does
> >>> anyone know of a decent way to accomplish this?
> >>
> >> Gem.clear_paths
> >
> > This does not appear to work. Here is my test procedure:
> >
> > [...]
>
> Hrm, with RubyGems 0.9.4.7 I ran your script and I get one fail, not
> two.
>
>

Interesting. I've verified that it does indeed work with 0.9.4.7. I was
previously using 0.9.4. Thanks for your help!

--
Tom Preston-Werner

* Libraries:
Chronic (chronic.rubyforge.org)
God (god.rubyforge.org)
Fuzed (fuzed.rubyforge.org)
* Site:
rubyisawesome.com

Eric Hodel

11/14/2007 8:23:00 AM

0

On Nov 14, 2007, at 24:04 , Tom Werner wrote:
> On 11/13/07, Eric Hodel <drbrain@segment7.net> wrote:
>> Hrm, with RubyGems 0.9.4.7 I ran your script and I get one fail, not
>> two.
>
> Interesting. I've verified that it does indeed work with 0.9.4.7. I
> was
> previously using 0.9.4. Thanks for your help!

I think that 0.9.4 was resetting the wrong variable, but that's a dim
memory. The beta should become 0.9.5 next week.

--
Poor workers blame their tools. Good workers build better tools. The
best workers get their tools to do the work for them. -- Syndicate Wars



Deborah

5/20/2008 9:04:00 PM

0

On Tue, 20 May 2008 16:56:58 -0400, "carrie" <starchild1124@yahoo.com>
wrote:

>
>"Gene" <gene@chewbacca.org> wrote in message
>news:Xns9AA47C97978C8genewardsmithsbcglob@207.115.33.102...
>> "carrie" <starchild1124@yahoo.com> wrote in news:g0ugce$5uo$1
>> @aioe.org:
>>
>> * What is it?
>>
>> It's simply making the same point again, and underlining
>> something already said, to ensure it won't be missed.
>>
>>> If you don't agree with Ken W. that is is a correction
>> (which it clearly
>>> seems to be, Jesus says "I told you before... but that
>> doesn't mean do it if
>>> it will harm you, your brother someone else) what do YOU
>> think it is?
>>
>> It's not a correction, as it does not change what had already
>> been given. This is because the first passage starts by saying
>> "Recognize what does not matter." Hence all interpretations
>> which assume that you are asked to do something which would be
>> harmful are completely wrong, as that *does* matter.
>>
>
> You're interpretation of it.
> Which you are, of course, intitled to.
> I guess this is what maz meant by I had already been told this before
>(about it not being a correction). Even though, I would think Ken Wapnick
>would know what is or isn't in the course, at this point.

From what you said of what Ken said, I don't see him having supported
your belief that the later paragraph was "a correction". He simply
corrected your mistaken understanding of what the original paragraph
said, as did Gene.

> It was written one way, then referred to later on, and changed. This is a
>correction of the previous statement.

You keep insisting on this as if it were fact. Isn't it, by your own
logic, just your own interpretation? Or is there actually such a
thing as "facts", Carrie?

Deborah (BC)

Gene Ward Smith

5/20/2008 9:15:00 PM

0

"carrie" <starchild1124@yahoo.com> wrote in news:g0vdus$ver$1
@aioe.org:

> It was written one way, then referred to later on, and
changed. This is a
> correction of the previous statement.

You're interpretation of it. Which you are, of course, NOT
entitled to, as it's wrong.


Reality Scan

5/20/2008 9:18:00 PM

0

On May 20, 3:54 pm, "carrie" <starchild1...@yahoo.com> wrote:
> "maz" <m...@solcon.nl> wrote in message
>
> news:e0049b25-ef5a-47dc-b82b-a55f0cb03014@f63g2000hsf.googlegroups.com...
> On 20 mei, 15:03, "carrie" <starchild1...@yahoo.com> wrote:
>
>
>
>
>
>
>
> > "maz" <m...@solcon.nl> wrote in message
>
> >news:fe1437bc-985e-4f9d-84db-20a9765789d0@24g2000hsh.googlegroups.com...
>
> > >>... maybe I miss things here, but if I do, there are some, like you, who
> > >>make sure I'm aware of it. Maybe you could quote.... <<
>
> > Are you kidding? Pay attention for yourself,
> > if the discussion is of any real interest to you.
> > That in itself would be highly astonishing.
>
> > namazté
>
> > If you're going to say:
>
> > "This is NOT a correction, as pointed out to you already"
>
> > I'd like to know where else it was pointed out to me already.
>
> search on " gene" plus "foolish" plus " correction" .
>
> And, yes, you trashed people's believes on a daily basis.
>
> My tip: Quit playing innocent. Your baiting isn't working any more.
>
> Are you also saying I called John obscenities on a daily basis? Can you
> show me anywhere I "trashed" anyone's beliefs and it wasn't just saying how
> I honestly think, feel and believe, never making it NOT okay for them to
> think, feel and believe the way they do?

ROTFLMAO. I think you are quickly running out of people to annoy who
aren't totally convinced you are a raving loon.

It amazing how little conversation you, Ellen and Lotus Bulb actually
have with one another, while saving all your "honesty," for posters
outside your clique.

Too funny



Reality Scan

5/20/2008 9:26:00 PM

0

On May 20, 4:15 pm, Gene <g...@chewbacca.org> wrote:
> "carrie" <starchild1...@yahoo.com> wrote in news:g0vdus$ver$1
> @aioe.org:
>
>
>
> > It was written one way, then referred to later on, and
> changed. This is a
> > correction of the previous statement.
>
> You're interpretation of it. Which you are, of course, NOT
> entitled to, as it's wrong.

Carrie writes like this to a select audience to annoy. I doubt anyone
outside this newsgroup would put up with her Jerry Springer mentality
for very long.

Robin

5/20/2008 10:06:00 PM

0

On May 20, 3:52 pm, "carrie" <starchild1...@yahoo.com> wrote:
> "Robin" <miracle...@gmail.com> wrote in message
>
> news:2b4841a5-71bb-4037-8054-21998d237cf6@f63g2000hsf.googlegroups.com...
>
>
>
> > On May 19, 7:41 pm, "carrie" <starchild1...@yahoo.com> wrote:
>
> >> >>> >> >> - Show quoted text -
>
> >> >>> >> >But I can see it as for my benefit to grow into someone stronger.
>
> >> >>> >> Let's revisit that extreme hypothetical of hitler and the nazi
> >> >>> >> empire...
>
> >> >>> >> If the world had felt (read: believed) the way you do, the nazi
> >> >>> >> army
> >> >>> >> would have marched lock-step all across the world and, today, we
> >> >>> >> would
> >> >>> >> all be speaking German and saluting the swastika. The entirety of
> >> >>> >> the
> >> >>> >> Jewish population would have been deleted. Blacks would most
> >> >>> >> likely
> >> >>> >> have been put back into slavery along with slavs and other
> >> >>> >> "undesirables." Books like A Course in Miracles would never have
> >> >>> >> made
> >> >>> >> it from one pair of eyes to another much less into print. Hitler
> >> >>> >> would
> >> >>> >> have become the new god. And the "state religion" would have been
> >> >>> >> practiced at the altar of the ouija board.
>
> >> >>> >> How would this had benefited you when the only premissable book to
> >> >>> >> read would have been main kampf?
>
> >> >>> >> But this hypothetical didnt happen. Instead, the world defeated
> >> >>> >> the
> >> >>> >> nazi menace, and as a result enough relative peace returned to the
> >> >>> >> world, that has provided a platform for you to make the spiritual
> >> >>> >> gains you have made.
>
> >> >>> >> You can thank the bloody World War II for the inroads you have
> >> >>> >> made
> >> >>> >> in
> >> >>> >> your life.- Hide quoted text -
>
> >> >>> >> - Show quoted text -
>
> >> >>> >Do you want to justify
>
> >> ...
>
> > Yes Carrie, you are right about this, we do attract stuff, just as our
> > Loving thoughts attract Love our attack thoughts attract attack and we
> > also carry things on much longer that needs be with our stupid "What
> > if" thoughts...
>
> > People who ask these "What if" questions think of them selves as doing
> > so in total "innocences" but they are just thinking that they are not
> > responsible for the content of their thinking... Pretty silly isn't
> > it?
>
> I don't know who wrote what you responded to, but it wasn't me.
> The way the new posts come in it's not always clear who is responding to
> what.

Not sure either Carrie, but it doesn't matter... Does it?