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

Explicit 'json' dependency causes build failure with 2.4-head #32

Closed
mieko opened this issue Aug 13, 2016 · 1 comment
Closed

Explicit 'json' dependency causes build failure with 2.4-head #32

mieko opened this issue Aug 13, 2016 · 1 comment

Comments

@mieko
Copy link
Contributor

mieko commented Aug 13, 2016

Hey Linode team, et. al.,

I wouldn't normally report an issue with a pre-release version of Ruby, but the JSON gem problem affects every version of Ruby since 1.9.x, it just manifests in weirder, more subtle ways. I've been hacking around it since the 2.0 time period. My production stack is 2.3 stable (vs. an unreleased 2.4), and the 'json' dependency works there, but still creates some quirky situations.

The version of 'json' that has shipped with Ruby since 1.9 is a vendored copy of flori/json, and has since diverged enough with compatibility changes that it looks like a fork. The gem on Rubygems is the (still-maintained) work in flori/json.

The end result of an explicit dependency on "json" is:

  • Assuming Ruby 1.9+, "require 'json'" can mean odd, subtly different things, esp. when the author expected the behavior (or Object even!) from a stock Ruby install.
  • Because the builtin 'json' is compiled with Ruby, systems that otherwise wouldn't need build tools (C compiler, ruby-dev, etc) to use the linode gem now do.
  • There will be times, like now, where JSON functionality would've worked out of the box, but is broken with a slightly lagging 'json' gem. MRI's JSON stays in lock-step with MRI.

I don't know what the linode gem's Ruby version policy is, which could be the constraining factor (1.8 still?), but I believe @mperham summed up the solution that has the best chance of working at the most places:

So many gems declare a dependency on json, oj, multi_json, or yajl-ruby. There’s so many ossified layers of cruft around JSON processing that only one course of action makes sense: remove it all. JSON has been in the stdlib since 1.9, you don’t need to declare any dependencies at all. Just require 'json' and let Ruby deal with it.

Rails did it, so can you!

The good thing is: linode appears to work just fine with the dependency removed, and all tests pass. This would've been a one-line PR instead of a novel, but the issues are subtle (more so than "let's break out-of-the-box behavior with 1.8.7!") and I wanted to get some feedback about it.

Thanks

@displague
Copy link
Collaborator

Thanks for the info, feel free to provide a PR. Either way, I'll take a deeper look sometimes this weekend.

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

No branches or pull requests

2 participants