diff --git a/bundler/lib/bundler/stub_specification.rb b/bundler/lib/bundler/stub_specification.rb index 026f753d411f..b353642b4062 100644 --- a/bundler/lib/bundler/stub_specification.rb +++ b/bundler/lib/bundler/stub_specification.rb @@ -52,6 +52,7 @@ def manually_installed? # This is defined directly to avoid having to loading the full spec def missing_extensions? + return false if RUBY_ENGINE == "jruby" return false if default_gem? return false if extensions.empty? return false if File.exist? gem_build_complete_path diff --git a/lib/rubygems/commands/pristine_command.rb b/lib/rubygems/commands/pristine_command.rb index 942b75fba172..10978c2af7cf 100644 --- a/lib/rubygems/commands/pristine_command.rb +++ b/lib/rubygems/commands/pristine_command.rb @@ -132,6 +132,11 @@ def execute specs = specs.select {|spec| spec.platform == RUBY_ENGINE || Gem::Platform.local === spec.platform || spec.platform == Gem::Platform::RUBY } if specs.to_a.empty? + if options[:only_missing_extensions] + say "No gems with missing extensions to restore" + return + end + raise Gem::Exception, "Failed to find gems #{options[:args]} #{options[:version]}" end diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb index cf9634862026..51729d755be3 100644 --- a/lib/rubygems/specification.rb +++ b/lib/rubygems/specification.rb @@ -2070,6 +2070,7 @@ def method_missing(sym, *a, &b) # :nodoc: # probably want to build_extensions def missing_extensions? + return false if RUBY_ENGINE == "jruby" return false if extensions.empty? return false if default_gem? return false if File.exist? gem_build_complete_path diff --git a/lib/rubygems/stub_specification.rb b/lib/rubygems/stub_specification.rb index 4f6a70ba4b4b..53b337ed8554 100644 --- a/lib/rubygems/stub_specification.rb +++ b/lib/rubygems/stub_specification.rb @@ -140,6 +140,7 @@ def raw_require_paths # :nodoc: end def missing_extensions? + return false if RUBY_ENGINE == "jruby" return false if default_gem? return false if extensions.empty? return false if File.exist? gem_build_complete_path diff --git a/spec/bundler/stub_specification_spec.rb b/spec/bundler/stub_specification_spec.rb index beb966b3ce8b..f2faa2ea6419 100644 --- a/spec/bundler/stub_specification_spec.rb +++ b/spec/bundler/stub_specification_spec.rb @@ -49,10 +49,14 @@ expect(stub.missing_extensions?).to be false end - it "returns true if not manually_installed?" do + it "returns #{RUBY_ENGINE == "jruby" ? "false" : "true"} if not manually_installed?" do stub = described_class.from_stub(with_bundler_stub_spec) stub.installed_by_version = Gem::Version.new(1) - expect(stub.missing_extensions?).to be true + if RUBY_ENGINE == "jruby" + expect(stub.missing_extensions?).to be false + else + expect(stub.missing_extensions?).to be true + end end end diff --git a/test/rubygems/test_gem.rb b/test/rubygems/test_gem.rb index de475d0891fd..f3d9ef95d69d 100644 --- a/test/rubygems/test_gem.rb +++ b/test/rubygems/test_gem.rb @@ -1304,10 +1304,14 @@ def test_self_try_activate_missing_extensions refute Gem.try_activate "nonexistent" end - expected = "Ignoring ext-1 because its extensions are not built. " \ - "Try: gem pristine ext --version 1\n" + if RUBY_ENGINE == "jruby" + assert_equal "", err + else + expected = "Ignoring ext-1 because its extensions are not built. " \ + "Try: gem pristine ext --version 1\n" - assert_equal expected, err + assert_equal expected, err + end end def test_self_use_paths_with_nils diff --git a/test/rubygems/test_gem_commands_pristine_command.rb b/test/rubygems/test_gem_commands_pristine_command.rb index e9c4d329450f..0ea140897ce1 100644 --- a/test/rubygems/test_gem_commands_pristine_command.rb +++ b/test/rubygems/test_gem_commands_pristine_command.rb @@ -248,7 +248,13 @@ def test_execute_extensions_only_missing_extensions end refute_includes @ui.output, "Restored #{a.full_name}" - assert_includes @ui.output, "Restored #{b.full_name}" + + if Gem.java_platform? + refute_includes @ui.output, "Restored #{b.full_name}" + assert_includes @ui.output, "No gems with missing extensions to restore" + else + assert_includes @ui.output, "Restored #{b.full_name}" + end end def test_execute_no_extension diff --git a/test/rubygems/test_gem_specification.rb b/test/rubygems/test_gem_specification.rb index 4d9661396f40..52ae9773131b 100644 --- a/test/rubygems/test_gem_specification.rb +++ b/test/rubygems/test_gem_specification.rb @@ -1578,13 +1578,21 @@ def test_contains_requirable_file_eh_extension ext_spec _, err = capture_output do - refute @ext.contains_requirable_file? "nonexistent" + if RUBY_ENGINE == "jruby" + refute @ext.ignored? + else + refute @ext.contains_requirable_file? "nonexistent" + end end - expected = "Ignoring ext-1 because its extensions are not built. " \ - "Try: gem pristine ext --version 1\n" + if RUBY_ENGINE == "jruby" + assert_equal "", err + else + expected = "Ignoring ext-1 because its extensions are not built. " \ + "Try: gem pristine ext --version 1\n" - assert_equal expected, err + assert_equal expected, err + end end def test_contains_requirable_file_eh_extension_java_platform @@ -4007,7 +4015,11 @@ def test_metadata_specs def test_missing_extensions_eh ext_spec - assert @ext.missing_extensions? + if RUBY_ENGINE == "jruby" + refute @ext.missing_extensions? + else + assert @ext.missing_extensions? + end extconf_rb = File.join @ext.gem_dir, @ext.extensions.first FileUtils.mkdir_p File.dirname extconf_rb diff --git a/test/rubygems/test_gem_stub_specification.rb b/test/rubygems/test_gem_stub_specification.rb index 4b2d4c570a13..f04b36dbf86c 100644 --- a/test/rubygems/test_gem_stub_specification.rb +++ b/test/rubygems/test_gem_stub_specification.rb @@ -68,13 +68,21 @@ def test_contains_requirable_file_eh def test_contains_requirable_file_eh_extension stub_with_extension do |stub| _, err = capture_output do - refute stub.contains_requirable_file? "nonexistent" + if RUBY_ENGINE == "jruby" + refute stub.ignored? + else + refute stub.contains_requirable_file? "nonexistent" + end end - expected = "Ignoring stub_e-2 because its extensions are not built. " \ - "Try: gem pristine stub_e --version 2\n" + if RUBY_ENGINE == "jruby" + assert_equal "", err + else + expected = "Ignoring stub_e-2 because its extensions are not built. " \ + "Try: gem pristine stub_e --version 2\n" - assert_equal expected, err + assert_equal expected, err + end end end @@ -137,7 +145,11 @@ def test_missing_extensions_eh end end - assert stub.missing_extensions? + if RUBY_ENGINE == "jruby" + refute stub.missing_extensions? + else + assert stub.missing_extensions? + end stub.build_extensions