[Rubygems-developers] Native Extensions and Pure Ruby Alternatives (again)

Trans transfire at gmail.com
Thu Nov 29 21:39:40 EST 2007

On Nov 29, 2007 1:03 AM, Mikel Lindsaar <raasdnil at gmail.com> wrote:
> Obviously I have a vested interest in this as I am part of the TMail
> maintenance team.
> I guess from my viewpoint, you want the install to be as smooth as possible
> and as optimistic as possible.
> Ideally I would like the following to occur as a default, and I don't think
> this is unreasonable.
> (1) try to compile the native extensions (going to be the best / fastest in
> pretty much every case)
> (2) if 1 fails then fall back to a plain ruby version - or at least (in the
> case of gems that don't have a ruby version) provide hooks for us to link
> into, like display a message that goes "We can't build, I can see you are
> running Windows from your environment, would you like to try to download and
> install the windows binary version?"
> If the user can't compile and wants the native extensions as a binary, then
> he/she can gem install name-win32 or name-linux or
> name-whatevergrabsyourfancy.

well, i think they way it works now is that it will automatically grab
the binary if it exists. --you'd have to download the non-binary
manually if you wated to try a compiling install. --which is fine I

> This would have the following benefits:
> 1) Your gem should basically work on anything WITHOUT user intervention.
> 2) You have a good chance of getting a native binary built first shot
> 3) The user can choose to download the native binary themselves if they know
> how to do it and need it (which implies a certain skill level).
> 4) You don't have to padd out your gem with a lot of inapplicable binaries
> for everyone to download.
>  5) It would be a lot friendlier and useful than throwing unable to find
> nmake messages in the console.
>  Trans, I think make the patch.  OpenSource is all about scratching your own
> itch.  If it is elegant and works then we would be accepted.  Until then,
> really, it is just talk without any concrete examples.

Welll. I have it. Its quite simple. This is how it works: if you set
'extensions_fallback' to true in the gemspec and an extension fails to
build on install then it says "Native extension failed to compile, but
this gem has a fallback option. Would you like to complete the install
without the native extensions or abort? [Y/n]

If the RubyGems team thinks this is acceptable I'll send it their
way... Honestly, I don't know how else it can be done. Without this
one is stuck with maintaning a secondary gem and trying to inform
potential users that there is a pure ruby option in case the native
extension one fails --but maybe that's what the RubyGems team
considers the better approach?


More information about the Rubygems-developers mailing list