Skip to content

Commit 28611be

Browse files
committed
Merge RubyGems/Bundler master from ee2f8398324af4bc1b95f7565ce2fda98126e026
1 parent de159c5 commit 28611be

File tree

10 files changed

+79
-14
lines changed

10 files changed

+79
-14
lines changed

lib/bundler/definition.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ def ensure_equivalent_gemfile_and_lockfile(explicit_flag = false)
357357
"bundle config unset deployment"
358358
end
359359
msg << "\n\nIf this is a development machine, remove the #{Bundler.default_gemfile} " \
360-
"freeze \nby running `#{suggested_command}`."
360+
"freeze \nby running `#{suggested_command}`." if suggested_command
361361
end
362362

363363
added = []

lib/bundler/lazy_specification.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,7 @@ def materialize_for_installation
7979
candidates = if source.is_a?(Source::Path) || !ruby_platform_materializes_to_ruby_platform?
8080
target_platform = ruby_platform_materializes_to_ruby_platform? ? platform : local_platform
8181

82-
source.specs.search(Dependency.new(name, version)).select do |spec|
83-
MatchPlatform.platforms_match?(spec.platform, target_platform)
84-
end
82+
GemHelpers.select_best_platform_match(source.specs.search(Dependency.new(name, version)), target_platform)
8583
else
8684
source.specs.search(self)
8785
end

lib/rubygems/ext/cargo_builder.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ def build_crate(dest_path, results, args, cargo_dir)
3737
def build_env
3838
build_env = rb_config_env
3939
build_env["RUBY_STATIC"] = "true" if ruby_static? && ENV.key?("RUBY_STATIC")
40+
build_env["RUSTFLAGS"] = "#{ENV["RUSTFLAGS"]} --cfg=rb_sys_gem".strip
4041
build_env
4142
end
4243

@@ -92,6 +93,9 @@ def platform_specific_rustc_args(dest_dir, flags = [])
9293
# run on one that isn't the missing libraries will cause the extension
9394
# to fail on start.
9495
flags += ["-C", "link-arg=-static-libgcc"]
96+
elsif darwin_target?
97+
# Ventura does not always have this flag enabled
98+
flags += ["-C", "link-arg=-Wl,-undefined,dynamic_lookup"]
9599
end
96100

97101
flags

spec/bundler/commands/update_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,12 @@
613613
expect(err).to match(/You are trying to install in deployment mode after changing.your Gemfile/m).
614614
and match(/freeze \nby running `bundle config unset deployment`./m)
615615
end
616+
617+
it "should not suggest any command to unfreeze bundler if frozen is set through ENV" do
618+
bundle "update", :all => true, :raise_on_error => false, :env => { "BUNDLE_FROZEN" => "true" }
619+
expect(err).to match(/You are trying to install in deployment mode after changing.your Gemfile/m)
620+
expect(err).not_to match(/by running/)
621+
end
616622
end
617623

618624
describe "with --source option" do

spec/bundler/install/gemfile/specific_platform_spec.rb

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,38 @@
148148
expect(out).to include("Using libv8 8.4.255.0 (universal-darwin)")
149149
end
150150

151+
it "chooses platform specific gems even when resolving upon materialization and the API returns more specific plaforms first" do
152+
build_repo4 do
153+
build_gem("grpc", "1.50.0")
154+
build_gem("grpc", "1.50.0") {|s| s.platform = "universal-darwin" }
155+
end
156+
157+
gemfile <<-G
158+
source "https://localgemserver.test"
159+
gem "grpc"
160+
G
161+
162+
# simulate lockfile created with old bundler, which only locks for ruby platform
163+
lockfile <<-L
164+
GEM
165+
remote: https://localgemserver.test/
166+
specs:
167+
grpc (1.50.0)
168+
169+
PLATFORMS
170+
ruby
171+
172+
DEPENDENCIES
173+
grpc
174+
175+
BUNDLED WITH
176+
#{Bundler::VERSION}
177+
L
178+
179+
bundle "install --verbose", :artifice => "compact_index_precompiled_before", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo4.to_s }
180+
expect(out).to include("Installing grpc 1.50.0 (universal-darwin)")
181+
end
182+
151183
it "caches the universal-darwin gem when --all-platforms is passed and properly picks it up on further bundler invocations" do
152184
setup_multiplatform_gem
153185
gemfile(google_protobuf)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# frozen_string_literal: true
2+
3+
require_relative "compact_index"
4+
5+
Artifice.deactivate
6+
7+
class CompactIndexPrecompiledBefore < CompactIndexAPI
8+
get "/info/:name" do
9+
etag_response do
10+
gem = gems.find {|g| g.name == params[:name] }
11+
move_ruby_variant_to_the_end(CompactIndex.info(gem ? gem.versions : []))
12+
end
13+
end
14+
15+
private
16+
17+
def move_ruby_variant_to_the_end(response)
18+
lines = response.split("\n")
19+
ruby = lines.find {|line| /\A\d+\.\d+\.\d* \|/.match(line) }
20+
lines.delete(ruby)
21+
lines.push(ruby).join("\n")
22+
end
23+
end
24+
25+
Artifice.activate_with(CompactIndexPrecompiledBefore)

test/rubygems/test_gem_ext_cargo_builder/custom_name/Cargo.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/rubygems/test_gem_ext_cargo_builder/custom_name/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ edition = "2021"
77
crate-type = ["cdylib"]
88

99
[dependencies]
10-
rb-sys = { version = "0.9.35", features = ["gem"] }
10+
rb-sys = "0.9.37"

test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/Cargo.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ edition = "2021"
77
crate-type = ["cdylib"]
88

99
[dependencies]
10-
rb-sys = { version = "0.9.35", features = ["gem"] }
10+
rb-sys = "0.9.37"

0 commit comments

Comments
 (0)