Skip to content

Commit b146cd4

Browse files
authored
Merge pull request rails#47492 from Shopify/bundle-add-platform
rails new: add x86_64-linux and aarch64-linux platforms by default
2 parents 6eb882e + b1a1ed1 commit b146cd4

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

railties/lib/rails/generators/app_base.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,17 @@ def target_rails_prerelease(self_command = "new")
644644
end
645645

646646
def run_bundle
647-
bundle_command("install", "BUNDLE_IGNORE_MESSAGES" => "1") if bundle_install?
647+
if bundle_install?
648+
bundle_command("install", "BUNDLE_IGNORE_MESSAGES" => "1")
649+
650+
# The vast majority of Rails apps will be deployed on `x86_64-linux`.
651+
platform = ["--add-platform=x86_64-linux"]
652+
653+
# Users that develop on M1 mac may use docker and would need `aarch64-linux` as well.
654+
platform << "--add-platform=aarch64-linux" if RUBY_PLATFORM.start_with?("arm64")
655+
656+
bundle_command("lock #{platform.join(" ")}", "BUNDLE_IGNORE_MESSAGES" => "1")
657+
end
648658
end
649659

650660
def run_javascript

railties/test/generators/shared_generator_tests.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,9 +366,11 @@ def run_generator_using_prerelease(args)
366366

367367
assert_file File.expand_path("Gemfile", project_path) do |gemfile|
368368
assert_equal "install", @bundle_commands[0]
369+
assert_match "lock --add-platform", @bundle_commands[1]
370+
369371
assert_equal gemfile[rails_gem_pattern], bundle_command_rails_gems[0]
370372

371-
assert_match %r"^exec rails (?:plugin )?new #{Regexp.escape Shellwords.join(expected_args)}", @bundle_commands[1]
373+
assert_match %r"^exec rails (?:plugin )?new #{Regexp.escape Shellwords.join(expected_args)}", @bundle_commands[2]
372374
assert_equal gemfile[rails_gem_pattern], bundle_command_rails_gems[1]
373375
end
374376
end

0 commit comments

Comments
 (0)