← Back to Upcase

Confused about Gemspec dependencies

(Dan Weaver) #1

Today I was struck by how little I actually understand exactly how gems work, where they come from and where they’re stored.

I’m using client_side_validations gem in my Rails 3.2.14 app and it’s all working fine. According to bundle show I seem to be using the latest version, 3.2.6, however the .gemspec on Github for this version has a dependency of 'rails', '>= 4.0.0', '< 4.3.0'

And if I add the Github URL to my Gemfile like:

gem 'client_side_validations', github: 'DavyJonesLocker/client_side_validations'

I get kicked with dependency issues when running bundle install, so can I assume I’m not running the 3.2.6 version from Github? I’m confused.

When I check rubygems.org it shows virtually no dependencies for 3.2.6, except for Rails ~>3.2.0

Where can I find out more about this? I’ve read plenty but so much of it skips over how the whole gem system actually works. I’m all for the benefits of ‘magic’ but I also like to know how things work in the background too.

(Tom Ridge) #2

@weavermedia heya!

So few bits and pixels here:

  1. https://github.com/DavyJonesLocker/client_side_validations/blob/3-2-stable/client_side_validations.gemspec is the current stable 3.2 gemspec. Which like you said specifies the dependencies for that particular version, specifically s.add_development_dependency 'rails', '~> 3.2.0'.Not rails 4. The github version (at I’m assuming master) is more up to date, and thus has a dependency of rails 4 and above (but below 4.3).
  2. How this basically works is that your gemspec identifies the dependencies for your gem, and that when you submit new versions, you can modify the dependencies you require. For instance, you can choose to no longer support older versions of Rails for new versions of your gem going forward. If you need more specifics let me know, I’d love to do more of a deep dive on this

(Dan Weaver) #3

Thanks @Tom_Ridge - the file you linked to makes it a little clearer. The dependencies are more like the ones listed on the RubyGems page.

What I’m still confused about is when I install and use this gem bundler reports the version as 3.2.6 and when I go to Github and download the source for that version it contains a .gemspec that’s quite different to the 3-2-stable version and by all accounts shouldn’t work for me.

I need to do a lot more reading and experimentation on this to learn it properly.

(Tom Ridge) #4

@weavermedia sorry if this seems like a rude question, just want to rule it out, are you checking out the 3.2 stable branch when you download it from Github? Because that gem spec is specifically on that branch.

(Dan Weaver) #5

Hey @Tom_Ridge, it’s not a rude question at all. While I seem to have gathered enough skills to build a fairly complex app I still have gaping holes in my knowledge (one of the downsides of ‘learn what you need to build the feature’).

I’m not so confused about checking out different versions for modification. I think my problem was that I made the mistaken assumption that installing the latest version of a gem meant I was using the latest version of the repo ‘master’ from Github. I understand now this isn’t always the case.

Thanks for your help