diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb
index ed60452b36..20875f7175 100644
--- a/test/ruby/test_io.rb
+++ b/test/ruby/test_io.rb
@@ -2003,6 +2003,8 @@ class TestIO < Test::Unit::TestCase
       end
     end
     false
+  rescue LoadError
+    raise File.read("ext/-test-/file/mkmf.log")
   end
 
   def test_seek