From 5bd765a9c86cf0e5bc8602bc292c59f29f83ae98 Mon Sep 17 00:00:00 2001 From: ignisf Date: Sun, 13 Jan 2013 16:58:45 +0200 Subject: [PATCH] Ensure libv8 is required when rubygems is not installed Do not break the build process if rubygems cannot be required. Instread try to require libv8 without selecting a version with gem and warn the user about it. This is necessary as ruby 1.8 does not ship with rubygems by default. --- ext/v8/extconf.rb | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/ext/v8/extconf.rb b/ext/v8/extconf.rb index 1854a39..5dd3902 100644 --- a/ext/v8/extconf.rb +++ b/ext/v8/extconf.rb @@ -16,9 +16,18 @@ if enable_config('debug') $CFLAGS += " -O0 -ggdb3" end -require 'rubygems' -gem 'libv8', '~> 3.15.11' -require 'libv8' +LIBV8_COMPATIBILITY = '~> 3.15.11' + +begin + require 'rubygems' + gem 'libv8', LIBV8_COMPATIBILITY +rescue Gem::LoadError + warn "Warning! Selecting libv8 #{LIBV8_COMPATIBILITY} failed. Has it been added to the gemspec?" +rescue LoadError + warn "Warning! Could not load rubygems. Please make sure you have libv8 #{LIBV8_COMPATIBILITY} installed." +ensure + require 'libv8' +end Libv8.configure_makefile