Avoid upgrading Ruby while installing gem

Hi All,

I am Ruby newbie, just started learning it as one of my projects need
it.

We have been installing em-http-request-1.1.1 with Ruby1.9.3 for last
1.5 years, but recently installation of em-http-request-1.1.1 requires
Ruby2.0.

$ env HOME=/root sudo gem install -V em-http-request -v 1.1.1 --no-rdoc
–no-ri
GET http://rubygems.org/specs.4.8.gz
200 OK
GET http://rubygems.org/latest_specs.4.8.gz
200 OK
GET http://rubygems.org/prerelease_specs.4.8.gz
200 OK
Installing gem public_suffix-2.0.5
ERROR: Error installing em-http-request:
public_suffix requires Ruby version >= 2.0.

Seems em-http-request has dependency on public_suffix and trying to get
prerelease version 2.0.5 of it.

My question, how can I avoid upgrading Ruby to 2.0 while installing
em-http-request. Is there a way? Please help.

Thanks,
Ravi

You could install the gem with the --force option, but I would strongly
suggest that you find out the reason, why you now have the version
mismatch:

It is very rare, that someone would add such a version restriction,
without also incrementing the version number. The only reason I could
imagine, is, that the author of the gem found AFTER releasing it, that
there was some problem of running the Gem with Ruby 1.9, and therefore
added the restriction. This would mean that you might have some problem
in your present usage of the gem which you just haven’t noticed yet. At
least you should try to contact the developer and ask why he added the
restriction. Maybe the release notes / readme-files also give some hint.

but recently installation of em-http-request-1.1.1
requires Ruby2.0.

My question, how can I avoid upgrading Ruby to 2.0 while
installing em-http-request. Is there a way?

In principle you can - it depends on the code that is
used.

If you really can not change the ruby version for whatever
reason, I would compare locally what has changed between
these two gems.

If you can make sure that it works on your older ruby,
then you can simply re-build the gem too and get rid
of that dependency (I mean the limitation on the particular
version). My gems all come with the .gemspec so perhaps
em-http-request and the other gems also come with a
.gemspec file.

You can modify the .gemspec files of all the gems
by the way and rebuild them on your own. This is
quite easy to do. The more difficult part would be
to find out what exactly really mandates ruby 2.x.

If it is syntax changes then you may have to go find
all the places on your own where incompatible syntax
is used.