Skip to content

Commit

Permalink
Revert "Merge pull request #49360 from skipkayhil/hm-gemfile-ruby-file"
Browse files Browse the repository at this point in the history
This reverts commit 6985c3b, reversing
changes made to 3163bb7.

Reason: While we want to apply this change, it make bundle being more
strict about the ruby version. This is particularly problematic for
the devcontainer images that don't support defining which patch
version of ruby to install.

Right now, you can only say you want Ruby 3.2, which could mean
3.2.3 or 3.2.0. If for some reason the devcontainer image doesn't
match the patch version on `.ruby-version` it will fail to install.

We are planning to solve this problem by publishing our own
ruby images that allow defining the patch level, but until that
we can't apply this change.
  • Loading branch information
rafaelfranca committed Feb 14, 2024
1 parent 53deefa commit 707b5cb
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 27 deletions.
4 changes: 0 additions & 4 deletions railties/CHANGELOG.md
@@ -1,7 +1,3 @@
* Use `ruby file: ".ruby-version"` in generated Gemfile if supported.

*Hartley McGuire*

* `bin/rails test` will no longer load files named `*_test.rb` if they are located in the `fixtures` folder.

*Edouard Chin*
Expand Down
14 changes: 1 addition & 13 deletions railties/lib/rails/generators/app_base.rb
Expand Up @@ -436,20 +436,8 @@ def to_s
end
end

def gem_ruby_entry
if Gem::Version.new(Bundler::VERSION) >= Gem::Version.new("2.4.20") # add file: option to #ruby
'ruby file: ".ruby-version"'
else
"ruby \"#{gem_ruby_version}\""
end
end

def gem_ruby_version
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new("3.3.13") # patch level removed from Gem.ruby_version
Gem.ruby_version
else
RUBY_VERSION
end
Gem::Version.new(Gem::VERSION) >= Gem::Version.new("3.3.13") ? Gem.ruby_version : RUBY_VERSION
end

def rails_prerelease?
Expand Down
Expand Up @@ -42,7 +42,7 @@ RUN curl -fsSL https://bun.sh/install | bash -s -- "bun-v${BUN_VERSION}"

<% end -%>
# Install application gems
COPY .ruby-version Gemfile Gemfile.lock ./
COPY Gemfile Gemfile.lock ./
RUN bundle install && \
rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git<% if depend_on_bootsnap? -%> && \
bundle exec bootsnap precompile --gemfile<% end %>
Expand Down
@@ -1,6 +1,6 @@
source "https://rubygems.org"

<%= gem_ruby_entry %>
ruby <%= "\"#{gem_ruby_version}\"" -%>

<% gemfile_entries.each do |gemfile_entry| -%>
<%= gemfile_entry %>
Expand Down
8 changes: 1 addition & 7 deletions railties/test/generators/app_generator_test.rb
Expand Up @@ -1006,13 +1006,7 @@ def test_inclusion_of_ruby_version
run_generator

assert_file "Gemfile" do |content|
if Gem::Version.new(Bundler::VERSION) >= Gem::Version.new("2.4.20") # add file: option to #ruby
assert_match('ruby file: ".ruby-version"', content)
elsif Gem::Version.new(Gem::VERSION) >= Gem::Version.new("3.3.13") # patch level removed from Gem.ruby_version
assert_match("ruby \"#{Gem.ruby_version}\"", content)
else
assert_match("ruby \"#{RUBY_VERSION}\"", content)
end
assert_match(/ruby "#{Gem::Version.new(Gem::VERSION) >= Gem::Version.new("3.3.13") ? Gem.ruby_version : RUBY_VERSION}"/, content)
end
assert_file "Dockerfile" do |content|
assert_match(/ARG RUBY_VERSION=#{Gem::Version.new(Gem::VERSION) >= Gem::Version.new("3.3.13") ? Gem.ruby_version : RUBY_VERSION}/, content)
Expand Down
2 changes: 1 addition & 1 deletion railties/test/generators/generators_test_helper.rb
Expand Up @@ -100,7 +100,7 @@ def evaluate_template_docker(file)
private
def gemfile_locals
{
gem_ruby_entry: "ruby \"#{RUBY_VERSION}\"",
gem_ruby_version: RUBY_VERSION,
rails_prerelease: false,
skip_active_storage: true,
depend_on_bootsnap: false,
Expand Down

0 comments on commit 707b5cb

Please sign in to comment.