Gem.pre_install does not working as it named

dazuiba's Avatar


28 Oct, 2010 12:18 PM

I write a gem called 'gem-fast', I used curl , so I want to make sure 'curl' is installed before user install this gem.

I found that Gem.pre_installs only contains pre_install hooks of gems that already installed. It does not contains the current installing gem

I write my 'rubygems_plugin.rb' like this:

Gem.pre_install do
if curl not installed

raise Gem::InstallError, "Your should install curl before install this gem!"

end end

So I use Gem.pre_install to do this. But It doesn't work as I expected! the hook not run brefore the gem installed!

I check the code Of rubygems, found that the design of pre_install, post_install was not right.

  1. 1 Posted by John Barnette on 28 Oct, 2010 03:22 PM

    John Barnette's Avatar

    This is how pre_install and post_install are intended to work.

  2. John Barnette closed this discussion on 28 Oct, 2010 03:22 PM.

  3. dazuiba re-opened this discussion on 29 Oct, 2010 01:45 AM

  4. 2 Posted by dazuiba on 29 Oct, 2010 01:45 AM

    dazuiba's Avatar

    Hi John, thanks for your reply!

    Is there anyway I can do to run a script(or a piece of ruby code) before the installation?

  5. 3 Posted by Hedgehog on 01 Nov, 2010 07:22 AM

    Hedgehog's Avatar

    Ditto for dazuiba's use case.

  6. 4 Posted by John Barnette on 01 Nov, 2010 03:39 PM

    John Barnette's Avatar

    For external dependencies like this, it's really better to check when your library is required instead of during installation. This makes the check more reliable for people who may vendor your gem or use it unpacked.

    If you REALLY want to run something before your gem completely installs (and I wish you wouldn't), take a look at Gem::Specification's support for extensions.

  7. John Barnette closed this discussion on 01 Nov, 2010 03:39 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac