Skip to content

Commit

Permalink
[rubygems/rubygems] Revert "Improve default gem handling"
Browse files Browse the repository at this point in the history
  • Loading branch information
deivid-rodriguez authored and hsbt committed Dec 14, 2023
1 parent a10c11a commit b300f5a
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/bundler/rubygems_integration.rb
Expand Up @@ -509,7 +509,7 @@ def path_separator
end

def all_specs
Gem::Specification.stubs.reject(&:default_gem?).map do |stub|
Gem::Specification.stubs.map do |stub|
StubSpecification.from_stub(stub)
end
end
Expand Down
6 changes: 5 additions & 1 deletion lib/bundler/source/rubygems.rb
Expand Up @@ -225,7 +225,11 @@ def cached_built_in_gem(spec)
cached_path = cached_path(spec)
if cached_path.nil?
remote_spec = remote_specs.search(spec).first
cached_path = fetch_gem(remote_spec)
if remote_spec
cached_path = fetch_gem(remote_spec)
else
Bundler.ui.warn "#{spec.full_name} is built in to Ruby, and can't be cached because your Gemfile doesn't have any sources that contain it."
end
end
cached_path
end
Expand Down
17 changes: 15 additions & 2 deletions spec/bundler/cache/gems_spec.rb
Expand Up @@ -102,8 +102,8 @@

it "uses builtin gems when installing to system gems" do
bundle "config set path.system true"
install_gemfile %(source "#{file_uri_for(gem_repo2)}"; gem 'json', '#{default_json_version}'), verbose: true
expect(out).to include("Installing json #{default_json_version}")
install_gemfile %(source "#{file_uri_for(gem_repo1)}"; gem 'json', '#{default_json_version}'), verbose: true
expect(out).to include("Using json #{default_json_version}")
end

it "caches remote and builtin gems" do
Expand Down Expand Up @@ -143,6 +143,19 @@
bundle "install --local"
expect(the_bundle).to include_gems("builtin_gem_2 1.0.2")
end

it "errors if the builtin gem isn't available to cache" do
bundle "config set path.system true"

install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem 'json', '#{default_json_version}'
G

bundle :cache, raise_on_error: false
expect(exitstatus).to_not eq(0)
expect(err).to include("json-#{default_json_version} is built in to Ruby, and can't be cached")
end
end

describe "when there are also git sources" do
Expand Down
1 change: 1 addition & 0 deletions spec/bundler/commands/open_spec.rb
Expand Up @@ -164,6 +164,7 @@

install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem "json"
G
end

Expand Down
6 changes: 1 addition & 5 deletions spec/bundler/runtime/setup_spec.rb
Expand Up @@ -1281,10 +1281,6 @@ def lock_with(ruby_version = nil)

describe "with gemified standard libraries" do
it "does not load Digest", :ruby_repo do
build_repo2 do
build_gem "digest"
end

build_git "bar", gemspec: false do |s|
s.write "lib/bar/version.rb", %(BAR_VERSION = '1.0')
s.write "bar.gemspec", <<-G
Expand All @@ -1303,7 +1299,7 @@ def lock_with(ruby_version = nil)
end

gemfile <<-G
source "#{file_uri_for(gem_repo2)}"
source "#{file_uri_for(gem_repo1)}"
gem "bar", :git => "#{lib_path("bar-1.0")}"
G

Expand Down

0 comments on commit b300f5a

Please sign in to comment.