Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix gems.rb lockfile for bundler version lookup in template #6413

Merged
merged 1 commit into from
Mar 2, 2023

Conversation

TonyCTHsu
Copy link
Contributor

@TonyCTHsu TonyCTHsu commented Feb 27, 2023

What was the end-user or developer problem that led to this PR?

When I create a rails 7 project with rails new my_app --minimal , there are a couple of files under bin provided from bundler. bin/bundle caught my attention with

  def lockfile
    lockfile =
      case File.basename(gemfile)
      when "gems.rb" then gemfile.sub(/\.rb$/, gemfile)
      else "#{gemfile}.lock"
      end
    File.expand_path(lockfile)
  end

This line: when "gems.rb" then gemfile.sub(/\.rb$/, gemfile)

When provided with gems.rb, the lockfile ends up become gemsgems.rb, which is very likely that the file is missing and this expression is returning false and prevent reading bundler version from the lockfile.

I noticed that the filename(Gemfile/gems.rb, Gemfile.lock/gems.locked) is probably not that important, since the content is the same, but Bundler has a specific mapping for gems.rb to gems.locked I think should be respected.

What is your fix for the problem, implemented in this PR?

The fix changes the lockfile lookup for gems.rb during bundler version lookup. Respect the bundler version specified in gems.locked.

Make sure the following tasks are checked

@welcome
Copy link

welcome bot commented Feb 27, 2023

Thanks for opening a pull request and helping make RubyGems and Bundler better! Someone from the RubyGems team will take a look at your pull request shortly and leave any feedback. Please make sure that your pull request has tests for any changes or added functionality.

We use GitHub Actions to test and make sure your change works functionally and uses acceptable conventions, you can review the current progress of GitHub Actions in the PR status window below.

If you have any questions or concerns that you wish to ask, feel free to leave a comment in this PR or join our #rubygems or #bundler channel on Slack.

For more information about contributing to the RubyGems project feel free to review our CONTRIBUTING guide

Copy link
Member

@deivid-rodriguez deivid-rodriguez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, nice catch!

Do you mind rebasing and squashing the commits into one. I like to have the fix and the test to illustrate/exercise it in the same commit.

@deivid-rodriguez deivid-rodriguez force-pushed the fix-gems.rb-lockfile-in-executable branch from ac73596 to 203f3e3 Compare March 2, 2023 10:55
@simi simi added this pull request to the merge queue Mar 2, 2023
Merged via the queue into rubygems:master with commit 5e3124e Mar 2, 2023
deivid-rodriguez pushed a commit that referenced this pull request Mar 8, 2023
…table

Fix `gems.rb` lockfile for bundler version lookup in template

(cherry picked from commit 5e3124e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants