piotrmurach / github

Ruby interface to GitHub API
https://piotrmurach.github.io/github
MIT License
1.15k stars 316 forks source link

Hashie Dependency #333

Closed btoone closed 6 years ago

btoone commented 6 years ago

While using a command line gem (epr) I got an error about this project's gem of github_api-0.18.1/lib/github_api/mash.rb:5:in <class:Mash>': undefined local variable or method disable_warnings' for Github::Mash:Class

The disable_warnings feature was added in Hashie version 3.5.2 but here the dependency in the Gemspec for Hashie is >=3.4. This caused the error for me because I only had Hashie 3.4.3 installed.

I think increasing the dependency to >=3.5 would prevent this but I'm not that familiar with managing gem dependencies.

See #298 for discussion on adding disable_warnings. Also here is the link to the commit that adds disable_warnings in the Hashie project for reference https://github.com/intridea/hashie/commit/b2f94a486650587573fea808cf0b1dbb06bc57e5

piotrmurach commented 6 years ago

Thanks for your contribution!

Managing dependencies is a bit a black magic or really hoping that everybody is using semantic versioning correctly 😄 Introducing disable_warnings at patch level is not ideal, even if we specify >=3.5 people can have v3.5.0 or v3.5.1 installed which will still break. However, if we get to specify ~> 3.5.2 then if the 3.6.0 gets released people will be stuck on this version until I release new gem. Any thoughts?

btoone commented 6 years ago

Hmm... Yeah I can see the problems there. Unfortunately I don't have any ideas. Let's toss this one out to the community here. Anyone have ideas on better ways to address this?

piotrmurach commented 6 years ago

How about being a bit pessimistic in version control in gemspec:

spec.add_runtime_dependency 'hashie', ['>= 3.5.2', '< 4.0']

or

spec.add_runtime_dependency 'hashie', '~> 3.5', '>= 3.5.2'

Both should achieve the desired effect but I think the second one is slightly better as it excludes any prerelease versions.

piotrmurach commented 6 years ago

Released v0.18.2 that fixes this issue.