Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion bundler/lib/bundler/stub_specification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ def ignored?
@ignored = missing_extensions?
return false unless @ignored

warn "Source #{source} is ignoring #{self} because it is missing extensions"
# If we share GEM_HOME for all of Ruby platform, the platform specific gem always warn that specification.
# ex `jruby-launcher` and CRuby
if (platform == Gem::Platform::RUBY || Gem::Platform.local === platform) && RUBY_ENGINE != "jruby"
warn "Source #{source} is ignoring #{self} because it is missing extensions"
end

true
end
Expand Down
22 changes: 22 additions & 0 deletions bundler/spec/bundler/stub_specification_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@
described_class.from_stub(gemspec)
end

let(:with_java_gem_stub_spec) do
gemspec = Gem::Specification.new do |s|
s.name = "gemname"
s.version = "1.0.0"
s.loaded_from = __FILE__
s.platform = "java"
end

described_class.from_stub(gemspec)
end

describe "#from_stub" do
it "returns the same stub if already a Bundler::StubSpecification" do
stub = described_class.from_stub(with_bundler_stub_spec)
Expand Down Expand Up @@ -43,6 +54,17 @@
end
end

describe "#ignored?" do
skip "This example is only for without JRuby" if RUBY_ENGINE == "jruby"

it "returns true if the gem is for different platform" do
stub = described_class.from_stub(with_java_gem_stub_spec)
allow(stub).to receive(:missing_extensions?).and_return(true)
expect(stub).to_not receive(:warn)
expect(stub.ignored?).to be true
end
end

describe "#missing_extensions?" do
it "returns false if manually_installed?" do
stub = described_class.from_stub(with_bundler_stub_spec)
Expand Down
8 changes: 6 additions & 2 deletions lib/rubygems/basic_specification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,12 @@ def base_dir
def contains_requirable_file?(file)
if ignored?
if platform == Gem::Platform::RUBY || Gem::Platform.local === platform
warn "Ignoring #{full_name} because its extensions are not built. " \
"Try: gem pristine #{name} --version #{version}"
# RubyGems warns gem specification of C extensions. But JRuby couldn't
# rebuild with `gem pristine` command. So, we skip the warning.
if RUBY_ENGINE != "jruby"
warn "Ignoring #{full_name} because its extensions are not built. " \
"Try: gem pristine #{name} --version #{version}"
end
end

return false
Expand Down
6 changes: 5 additions & 1 deletion test/rubygems/test_gem.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1308,8 +1308,12 @@ def test_self_try_activate_missing_extensions
refute Gem.try_activate "nonexistent"
end

expected = "Ignoring ext-1 because its extensions are not built. " \
expected = if RUBY_ENGINE == "jruby"
""
else
"Ignoring ext-1 because its extensions are not built. " \
"Try: gem pristine ext --version 1\n"
end

assert_equal expected, err
end
Expand Down
6 changes: 5 additions & 1 deletion test/rubygems/test_gem_specification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1557,8 +1557,12 @@ def test_contains_requirable_file_eh_extension
refute @ext.contains_requirable_file? "nonexistent"
end

expected = "Ignoring ext-1 because its extensions are not built. " \
expected = if RUBY_ENGINE == "jruby"
""
else
"Ignoring ext-1 because its extensions are not built. " \
"Try: gem pristine ext --version 1\n"
end

assert_equal expected, err
end
Expand Down
6 changes: 5 additions & 1 deletion test/rubygems/test_gem_stub_specification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,12 @@ def test_contains_requirable_file_eh_extension
refute stub.contains_requirable_file? "nonexistent"
end

expected = "Ignoring stub_e-2 because its extensions are not built. " \
expected = if RUBY_ENGINE == "jruby"
""
else
"Ignoring stub_e-2 because its extensions are not built. " \
"Try: gem pristine stub_e --version 2\n"
end

assert_equal expected, err
end
Expand Down