Fix regression where some CLI commands break on Ruby 1.8 #7738
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes a regression where for example,
brew cask list
would break on Ruby 1.8.7.Cause
I feel the regression might have been introduced in the merge commit 62c1ce5, which adds code to
path_base.rb
which depends onGem::Version
, but doesn’t require therubygems
gem.A Google search showed that
rubygems
is built into 1.9 and later but not into 1.8 (I learn something new every day!). This seems to causebrew cask list
(and other commands) to break under Ruby 1.8 since 62c1ce5.Steps to reproduce
Assuming
rbenv
and Ruby 1.8.7-p375 are installed, follow these steps:brew cask list
under Ruby 1.8 like so:Result
CLI::Alfred
CLI::Alfred
class (since 0f664ca). That commit has been around since 0.41.1 so I guess it doesn’t cause any issues after all. I couldn’t produce any problem with this either but I added the missingrequire
here as well just in case.Test coverage
Given that
brew cask list
breaks, I would have expectedlist_test.rb
to break as well. However, for some strange reason all the unit tests are still green:Strangely, the result is:
Please review
Pinging one of @federicobond @ndr-qef @phinze @rolandwalker to please have a look. 😊
Thank you!