Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

use version operators for specifying ruby version in Gemfile #4064

Merged
merged 10 commits into from Dec 13, 2015

Conversation

jtarchie
Copy link
Contributor

Related to the original PR, we are adding the requested meta data to the Gemfile. So far we have a proposed RUBY VERSION that would store the meta information of the Ruby.

You'll be able to support version operators on the version of Ruby you'd like to support.

For example, if you wanted the latest patch release from Ruby 2.2.

$ cat Gemfile
ruby "~> 2.2.0"

This way the Ruby version selected could always be the latest stable. Especially useful for deployments on production environments that are constantly supporting the latest security release of Ruby (eg: Heroku and PWS).

* Use `Gem::Requirement` and `Gem::Version` to parse and check
  ruby version, engine_version and patchlevel requirements.
* Added new class `RubyVersionRequirement` to handle this functionality.
* Added tests that cover the `RubyVersionRequirement` class.
@@ -307,6 +307,11 @@ def to_lock
out << " #{p}\n"
end

if ruby_version
Copy link
Member

Choose a reason for hiding this comment

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

this will be backwards-incompatible with versions of bundler prior to 1.9.6, I believe

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean the Gemfile.lock will be incompatible? If so, what is the collision, because wouldn't BUNDLED WITH also be backwards incompatible too?

Copy link
Member

Choose a reason for hiding this comment

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

yes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@segiddins could you please clarify. If BUNDLED WITH is already backwards incompatible, what is stopping from adding of this feature then.

Signed-off-by: David Morhovich <dmorhovich@pivotal.io>
@jtarchie
Copy link
Contributor Author

@panthomakos we redid the pull request to merge your PR, so the commit history is maintained.

@segiddins
Copy link
Member

Bundled with took me three tries to make backwards compatible. To be honest, I feel like, if this is a road we want to go down, it should target the 2.0 branch, as I'm very nervous about changing the lock file for 1.x

@jtarchie
Copy link
Contributor Author

@segiddins, Please share what those issues were. If I can work around those problems, there are a series of use cases that this feature help us solve. Would a g-hangout be easier to discuss this?

We've only changed the lock file because the original PR have comments from @indirect. We care more about the version operators for the ruby directive in the Gemfile.

@indirect
Copy link
Member

I think it's possible to take the same approach we took in BUNDLED WITH, and lead with three spaces so old Bundlers will just ignore the line.

Keep in mind, though, that using this feature will require everyone on a team and all production boxes to have a version of Bundler that supports this.

@jtarchie
Copy link
Contributor Author

@indirect thanks for the input. We'll add the needed spacing to keep backwards compatible.

We'll investigate if we might be able to add integration tests for backwards compatibility too. That way if any future changes are made, it will blow up for someone in the test suite. I emphasize, maybe we can do this. :-)

@jtarchie jtarchie force-pushed the master branch 2 times, most recently from 1c71bf2 to 864e752 Compare October 21, 2015 21:30
@jtarchie jtarchie changed the title [WIP] use version operators for specifying ruby version in Gemfile use version operators for specifying ruby version in Gemfile Oct 23, 2015
@indirect
Copy link
Member

This looks good! One thing I'm not sure about is how you upgrade your locked Ruby version once it's in your lockfile... what if you're locked to 2.2.3 and the Gemfile changes to say "~> 2.3.0"?

@mavenraven
Copy link
Contributor

Hey @indirect, here are our thoughts on how that behavior would work. Let us know if something looks off. Thanks!

Given I am a Ruby developer,
and my Ruby version is 1.8.7,
when I put `ruby '~> 2.1'` in my Gemfile
and I run `bundle install` in my project folder
then I get an error [or warning].

Given I am a Ruby developer,
and my Ruby version is 2.1.3p100,
when I put `ruby '~> 2.1'` in my Gemfile
and I run `bundle install` in my project folder
then my Gemfile.lock will have Ruby version '2.1.3p100'.

Given I am a Ruby developer,
and my Ruby version is 2.1.3p100,
when I put `ruby '~> 2.1'` in my Gemfile
and I run `bundle install` in my project folder
and I switch my Ruby version to 2.1.4p222
and I run `bundle install` in my project folder
then my Gemfile.lock will have Ruby version '2.1.3p100'
and an error [or warning] is displayed.

Given I am a Ruby developer,
and my Ruby version is 2.1.3p100,
when I put `ruby '~> 2.1'` in my Gemfile
and I run `bundle install` in my project folder
and I switch my Ruby version to 2.1.4p222
and I run `bundle ruby-update` in my project folder
then my Gemfile.lock will have Ruby version '2.1.4p222'.

Given I am a Ruby developer,
and my Ruby version is 2.1.3p100,
when I put `ruby '~> 2.1.0'` in my Gemfile
and I run `bundle install` in my project folder
and I switch my Ruby version to 2.2.2p505
and I run `bundle ruby-update` in my project folder
then my Gemfile.lock will have Ruby version '2.1.3p100'
and an error [or warning] is displayed.

Given I am a Ruby developer,
and my Ruby version is 2.1.3p100,
when I put `ruby '~> 2.1.0'` in my Gemfile
and I run `bundle install` in my project folder
and I switch my Ruby version to 1.8.7p55
and I put `ruby '~> 1.8.0'`
and I run `bundle ruby-update` in my project folder
then my Gemfile.lock will have Ruby version '1.8.7p55'.

@indirect
Copy link
Member

@jtarchie @mavenraven that looks reasonable. I think I would prefer that the user run bundle update --ruby or bundle update ruby, and I'm happy to accept this pull once it implements either of those options.

@jtarchie jtarchie force-pushed the master branch 2 times, most recently from 0736729 to b6740f7 Compare October 27, 2015 17:38
* Adds support for `bundle update --ruby` command to allow for updating
  ruby version in Gemfile.lock.
* Adds support for `bundle install` to allow for adding ruby version in
  Gemfile.lock.

https://www.pivotaltracker.com/story/show/106008092

Signed-off-by: JT Archie <jtarchie@gmail.com>
@mavenraven
Copy link
Contributor

Hey @indirect, we've updated the PR with tests and implementation that cover the above use cases. We also added coverage that uses bundle update --ruby to update your locked Ruby version. Please let us know if there is anything else that needs to be done. Thanks!

@jtarchie
Copy link
Contributor Author

@indirect is there anything else you'd need in this pull request?

@kayline
Copy link

kayline commented Nov 2, 2015

+1 This would be very helpful. It's not easy to figure out what versions of the ruby buildpack support a specific Ruby version, and manually specifying the the Github url in our manifest has a tendency to break. I would much prefer specifying my Ruby version and not knowing the buildpack details.

@indirect
Copy link
Member

indirect commented Nov 2, 2015

@kayline this won't change the Ruby buildpack—Heroku's buildpack does not generally upgrade to new Bundler versions.

@indirect
Copy link
Member

indirect commented Nov 2, 2015

@homu r+

@homu
Copy link
Contributor

homu commented Nov 2, 2015

📌 Commit b4a52c3 has been approved by indirect

@jtarchie
Copy link
Contributor Author

jtarchie commented Nov 3, 2015

@indirect was @homu supposed to run the tests on that call @homu r+? Looking at previous pull requests, it looks like that was a pretty instantaneous operation. Just making sure. :-)

@homu
Copy link
Contributor

homu commented Nov 3, 2015

⌛ Testing commit b4a52c3 with merge 75ae375...

@@ -113,4 +97,32 @@ def patchlevel
RUBY_PATCHLEVEL.to_s
end
end

class RubyVersionRequirement < RubyVersion
Copy link
Member

Choose a reason for hiding this comment

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

requirement should not subclass version

Copy link
Contributor

Choose a reason for hiding this comment

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

@homu
Copy link
Contributor

homu commented Nov 18, 2015

☔ The latest upstream changes (presumably #4063) made this pull request unmergeable. Please resolve the merge conflicts.

@mavenraven
Copy link
Contributor

Hey @segiddins @indirect @jtarchie @homu We've added the changes that @segiddins suggested, and remerged into master. Can you retry homu when you get a chance please? Thank you!

@mavenraven
Copy link
Contributor

Hey @indirect, @segiddins can you please take a look at our changes when you get a chance? I'm afraid that they're going to fall out of date again.

cc @jtarchie @flavorjones

@homu
Copy link
Contributor

homu commented Nov 27, 2015

☔ The latest upstream changes (presumably #4124) made this pull request unmergeable. Please resolve the merge conflicts.

@segiddins
Copy link
Member

Don't worry about rebasing again, I believe @indirect said he'd handle getting this merged.

@mavenraven
Copy link
Contributor

thanks @segiddins! Let me know if you need anything @indirect.

@indirect
Copy link
Member

Merged this in the branch 4064, and will fast forward master once the build passes.

@indirect indirect merged commit 44cedcc into rubygems:master Dec 13, 2015
@indirect
Copy link
Member

Merged, will be released as part of 1.12. 🎉

@mavenraven
Copy link
Contributor

hurray!

@gsiener
Copy link

gsiener commented Dec 16, 2015

👍

@jtarchie
Copy link
Contributor Author

Thanks for the help @indirect and @segiddins

@blackjid
Copy link

Hey @indirect, any idea when 1.12 is going to be released??

@RochesterinNYC
Copy link
Contributor

@blackjid The Bundler v1.12.x series has been released with this functionality, with v1.12.3 as the latest patch.

@blackjid
Copy link

thanks @RochesterinNYC !

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet