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

activesupport requires Ruby version >= 2.2.2 #182

Closed
simon3z opened this issue Aug 3, 2016 · 13 comments
Closed

activesupport requires Ruby version >= 2.2.2 #182

simon3z opened this issue Aug 3, 2016 · 13 comments
Labels

Comments

@simon3z
Copy link
Collaborator

simon3z commented Aug 3, 2016

The activesupport dependency kubeclient has:

# ...
Gem::Specification.new do |spec|
  # ...
  spec.add_dependency 'activesupport'
  # ...
end

is breaking travis jobs for Ruby < 2.2.2 on:

Gem::InstallError: activesupport requires Ruby version >= 2.2.2.
An error occurred while installing activesupport (5.0.0), and Bundler cannot
continue.
Make sure that `gem install activesupport -v '5.0.0'` succeeds before bundling.
The command "eval bundle install --jobs=3 --retry=3" failed. Retrying, 2 of 3.

The gem installation on Ruby < 2.2.2 fails as well (when activesupport is not installed yet):

$ ruby -v
ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux]
$ gem install kubeclient
ERROR:  Error installing kubeclient:
        activesupport requires Ruby version >= 2.2.2.

Unless there is a way to have a conditional dependency (activesupport < 5 for Ruby < 2.2.2) we should probably consider to drop support for Ruby < 2.2.2.

Other possible options and workarounds:

  • find out if activesupport has any suggestion on how other projects should specify the dependency
  • force a specific activesupport (< 5.0) version in the gem file (dependency issues with other projects)
  • find an alternative to activesupport
  • maybe have a specific workaround for travis (although it's not solving the gem installation issue):
  if ENV['TRAVIS'] == 'true' && RUBY_VERSION < '2.2.2'
    spec.add_dependency 'activesupport', '< 5'
  else
    spec.add_dependency 'activesupport'
  end

cc @zakiva @zeari @moolitayer @abonas @Fryguy @bdunne @jonmoter @jimmidyson

@simon3z simon3z added the bug label Aug 3, 2016
@Fryguy
Copy link
Member

Fryguy commented Aug 3, 2016

@bdunne has solved this problem in a number of gems... @bdunne, can you comment here?

@jonmoter
Copy link
Contributor

jonmoter commented Aug 3, 2016

Do you know off-hand how ActiveSupport is being used?

When possible, I prefer that gems keep their dependencies minimal, to avoid potential conflicts when including them. If it's used heavily, that's fine, but if it's only used for a few small functions, I'd suggest removing it.

@bdunne
Copy link
Member

bdunne commented Aug 4, 2016

You can use this hack to support older rubies...
https://github.com/ManageIQ/ansible_tower_client/blob/master/ansible_tower_client.gemspec#L22

On Aug 3, 2016 3:14 PM, "Jon Moter" notifications@github.com wrote:

Do you know off-hand how ActiveSupport is being used?

When possible, I prefer that gems keep their dependencies minimal, to
avoid potential conflicts when including them. If it's used heavily, that's
fine, but if it's only used for a few small functions, I'd suggest removing
it.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#182 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAnxi6qwCg5tBYwgbjhH3dhNXPmLITwQks5qcOiUgaJpZM4Jbw3M
.

@abonas
Copy link
Member

abonas commented Aug 4, 2016

Do you know off-hand how ActiveSupport is being used?

When possible, I prefer that gems keep their dependencies minimal, to avoid potential conflicts when including them. If it's used heavily, that's fine, but if it's only used for a few small functions, I'd suggest removing it.

iirc it is used for things like pluralize
https://github.com/abonas/kubeclient/blob/master/lib/kubeclient/common.rb#L131

@simon3z
Copy link
Collaborator Author

simon3z commented Aug 4, 2016

You can use this hack to support older rubies...
https://github.com/ManageIQ/ansible_tower_client/blob/master/ansible_tower_client.gemspec#L22

@bdunne @Fryguy I saw that around but that's evaluated at build-time... which means that depending on what Ruby you use, you build a gem with different dependencies.

If you build the gem on Ruby < 2.2.2 (and release) then you generate a dependency of activesupport < 5 which will break other projects (e.g. ManageIQ requiring activesupport 5).

If you build on Ruby >= 2.2.2 (and release) then you generate a dependency of activesupport which would result anyway in a breakage on Ruby < 2.2.2:

$ ruby -v
ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux]
$ gem install kubeclient
ERROR:  Error installing kubeclient:
        activesupport requires Ruby version >= 2.2.2.

@Fryguy
Copy link
Member

Fryguy commented Aug 8, 2016

Any project that requires Rails 5 can only use Ruby >= 2.2.2 since rails itself requires 2.2.2, so nothing should break. Most projects use bundler, and bundler would protect against your particular error.

@simon3z
Copy link
Collaborator Author

simon3z commented Aug 8, 2016

Requiring rails only for pluralization seems an overhead @Fryguy @bdunne @jonmoter do you have any alternative? (I saw the linguistics gem). I suppose that the process to extract inflections out of the activesupport gem would be long and controversial.

If no alternatives, then only solution is to drop support for Rails < 2.2.2.

@Fryguy
Copy link
Member

Fryguy commented Aug 8, 2016

I'm not following why @bdunne's thing doesn't work.

@simon3z
Copy link
Collaborator Author

simon3z commented Aug 8, 2016

I'm not following why @bdunne's thing doesn't work.

@Fryguy it would make it travis pass but it's not fixing the issue.
The proposed conditional is evaluated at kubeclient gem build-time. Based on which Ruby (>= 2.2.2 or < 2.2.2) you use to build/release then you would have different dependencies (and in both cases they would have an issue as described above).

@simon3z
Copy link
Collaborator Author

simon3z commented Aug 8, 2016

@Fryguy, to give you more information, with the change:

-  spec.add_dependency 'activesupport'
+  active_support_version = "< 5" if Gem::Version.new(RUBY_VERSION) <= Gem::Version.new("2.2.2")
+  spec.add_runtime_dependency "activesupport", active_support_version

suggested by @bdunne, the conditional is evaluated at gem build-time.

When you build with Ruby < 2.2.2:

$ rvm use 2.2.0
$ rake build
kubeclient 1.2.0 built to pkg/kubeclient-1.2.0.gem.
$ gem spec --yaml -l pkg/kubeclient-1.2.0.gem
...
- !ruby/object:Gem::Dependency
  name: activesupport
  requirement: !ruby/object:Gem::Requirement
    requirements:
    - - "<"
      - !ruby/object:Gem::Version
        version: '5'
  type: :runtime
  prerelease: false
  version_requirements: !ruby/object:Gem::Requirement
    requirements:
    - - "<"
      - !ruby/object:Gem::Version
        version: '5'
...

When you build with Ruby >= 2.2.2:

$ rvm use 2.2.2
$ rake build
$ gem spec --yaml -l pkg/kubeclient-1.2.0.gem
...
kubeclient 1.2.0 built to pkg/kubeclient-1.2.0.gem.
- !ruby/object:Gem::Dependency
  name: activesupport
  requirement: !ruby/object:Gem::Requirement
    requirements:
    - - ">="
      - !ruby/object:Gem::Version
        version: '0'
  type: :runtime
  prerelease: false
  version_requirements: !ruby/object:Gem::Requirement
    requirements:
    - - ">="
      - !ruby/object:Gem::Version
        version: '0'
...

@Fryguy @bdunne now which one would you release (and why)?
If we're releasing the second one, then why even bother trying to support Ruby < 2.2.2 in travis, we know that it won't work when using bundle/gem install commands.

@jonmoter
Copy link
Contributor

jonmoter commented Aug 9, 2016

FYI, I spent a few minutes experimenting with removing the ActiveSupport dependency and seeing what breaks. It appears we use these methods that are in ActiveSupport:

  • String#camelize
  • String#pluralize
  • String#underscore
  • Hash#slice

We could just include method definitions for each of those. Or for the first three, just create our own static mapping table for the entity types we support. We have a well-defined set of words we need to deal with here, not arbitrary text.

@simon3z
Copy link
Collaborator Author

simon3z commented Aug 9, 2016

FYI, I spent a few minutes experimenting with removing the ActiveSupport dependency and seeing what breaks. It appears we use these methods that are in ActiveSupport:

  • String#camelize
  • String#pluralize
  • String#underscore
  • Hash#slice

@moolitayer in your #181 are you dropping any of the requirements above? (cc @jonmoter)

@moolitayer
Copy link
Collaborator

#184 is dropping the dependency on activesupport:

@moolitayer in your #181 are you dropping any of the requirements above? (cc @jonmoter)

Afraid No. A different implementations might do so. We can deal with that later.

Hash#slice

appears to be stdlib

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

No branches or pull requests

6 participants