I have a question about RubyGems’s “~>”. Sorry for asking this here.
I’ve searched in their “manual”, but it’s like searching a needle in a
haystack.
My question is simple:
My gem works only on Ruby 1.8 (that is, it doesn’t work on Ruby 1.9 (and
isn’t supposed to)).
In my gem specification I have:
s.required_ruby_version = ‘~> 1.8’
Is this correct? Or do I have to write ‘~> 1.8.0’ ?
Unfortunately, Ruby 1.9’s ‘gem’ installs my gem. I want it to refuse to
do this. I suspect that’s because ‘~> 1.8’ includes all versions of Ruby
till 2.0 (not including).
So haw can I tell RubyGems that my gem is for 1.8 only?
I have a question about RubyGems’s “~>”. Sorry for asking this here.
I’ve searched in their “manual”, but it’s like searching a needle in a
haystack.
Hijacking this question a little, but how can I tell from my program
what
gems
and what versions of those gems it is using?
If I knew what my programs gem dependencies were, I think it would
really
help
me out on some very nasty issues. Last week for instance, it took me a
couple
of hours of trial and error to get my heroku .gems manifest to match the
gem
versions I was using in development.
If I knew what my programs gem dependencies were, I think it would really
help
me out on some very nasty issues. Last week for instance, it took me a
couple
of hours of trial and error to get my heroku .gems manifest to match the gem
versions I was using in development.
YOU don’t know what gems YOUR code is using? Why not?
One thing that might help is to try out the isolate gem. You specify
what gems your project needs and they’re privately installed and only
those private gems get used. I use it on all my rails projects (and gem
projects) at work.
YOU don’t know what gems YOUR code is using? Why not?
Is this meant to be easy to know? Sure I know when I explicitly use
dust, or
sinatra or
Haml or whatever, but I can never be certain of the network of
dependencies
that those other
gems use.
One thing that might help is to try out the isolate gem. You specify what
gems your project needs and they’re privately installed and only those
private gems get used. I use it on all my rails projects (and gem projects)
at work.
To be clear, I see this issue when checking out code across multiple
systems
which have
different gems and gem versions installed. More specifically this is a
thorny problem with
non-explicit gem use, like when I choose to use a gem which in turn has
other dependencies
and incompatibility between different versions of the gems.
Had a bit of trial and error last week when I had to update my .gems
manifest on Heroku to
use a later version of datamapper and its dependencies. If I could have
seen
what gems &
gem versions my development system was using it could have made for a
much
easier experience.
This is exactly the type of thing that isolate solves. It is perfectly
reasonable to have isolate installed as the only global gem and each project
uses isolate to declare their gem dependencies and they’re all installed
private to each project.
I will look into isolate, though the problem I face isn’t due to
production/professional environments.
I often evaluate different gems or run through example code as part of
course work or general curiosity.
Sometimes I settle on a solution that I take further on, and its usually
at
that stage that I need to figure
out exact gem dependencies. I often end up being shanghaied into helping
out
someone else’s ruby
problem as well. The messiest issues are always gem related.
I was just curious if there was a mechanism to inspect the loaded gems
from
an application (and their
versions). Even unusual techniques, like perhaps objectspace inspection,
or
reopening gem specific
methods.
YOU don’t know what gems YOUR code is using? Why not?
Is this meant to be easy to know? Sure I know when I explicitly use dust, or
sinatra or
Haml or whatever, but I can never be certain of the network of dependencies
that those other
gems use.
Ah. well… rubygems handles the transitive closure of the dependencies.
You should only specify the top level (real) dependencies for your
project.
One thing that might help is to try out the isolate gem. You specify what
gems your project needs and they’re privately installed and only those
private gems get used. I use it on all my rails projects (and gem projects)
at work.
To be clear, I see this issue when checking out code across multiple systems
which have
different gems and gem versions installed. More specifically this is a
thorny problem with
non-explicit gem use, like when I choose to use a gem which in turn has
other dependencies
and incompatibility between different versions of the gems.
This is exactly the type of thing that isolate solves. It is perfectly
reasonable to have isolate installed as the only global gem and each
project uses isolate to declare their gem dependencies and they’re all
installed private to each project.