Permalink
Browse files

Reset RUBYOPT when unlinking siteconf

The rice gem uses an unconventional extconf.rb during its build.
Instead of using mkmf it gathers configuration information from RbConfig
and runs a configure script which creates a Makefile.  The Makefile
invokes ruby during the build process.

When running the Makefile the RUBYOPT environment variable required the
siteconf file which had been removed.  This would cause ruby to raise an
exception.

Now RUBYOPT is reset when the siteconf file is removed which Fixes this
bug.

Fixes #582
  • Loading branch information...
drbrain committed Jul 10, 2013
1 parent 441e1fc commit 472ccf3be24e684134b8cebc8bfdc9100db3bb7f
Showing with 37 additions and 0 deletions.
  1. +1 −0 lib/rubygems/ext/ext_conf_builder.rb
  2. +36 −0 test/rubygems/test_gem_ext_ext_conf_builder.rb
@@ -35,6 +35,7 @@ def self.build(extension, directory, dest_path, results)
run cmd, results
ENV["DESTDIR"] = nil
+ ENV["RUBYOPT"] = rubyopt
siteconf.unlink
make dest_path, results
@@ -108,6 +108,42 @@ def test_class_build_extconf_fail
assert_equal("#{Gem.ruby} extconf.rb", output[0])
end
+ def test_class_build_unconventional
+ if vc_windows? && !nmake_found?
+ skip("test_class_build skipped - nmake not found")
+ end
+
+ File.open File.join(@ext, 'extconf.rb'), 'w' do |extconf|
+ extconf.puts <<-'EXTCONF'
+include RbConfig
+
+ruby_exe = "#{CONFIG['RUBY_INSTALL_NAME']}#{CONFIG['EXEEXT']}"
+ruby = File.join CONFIG['bindir'], ruby_exe
+
+open 'Makefile', 'w' do |io|
+ io.write <<-Makefile
+all: ruby
+install: ruby
+
+ruby:
+\t#{ruby} -e0
+
+ Makefile
+end
+ EXTCONF
+ end
+
+ output = []
+
+ Dir.chdir @ext do
+ Gem::Ext::ExtConfBuilder.build 'extconf.rb', nil, @dest_path, output
+ end
+
+ assert_contains_make_command '', output[2]
+ assert_contains_make_command 'install', output[4]
+ assert_empty Dir.glob(File.join(@ext, 'siteconf*.rb'))
+ end
+
def test_class_make
if vc_windows? && !nmake_found?
skip("test_class_make skipped - nmake not found")

0 comments on commit 472ccf3

Please sign in to comment.