Fail back to 'json' gem if 'multi_json' is not available #1034

Closed
wants to merge 2 commits into
from

Projects

None yet

7 participants

@Kami
Kami commented Jul 11, 2012

Newer version of fog which requires multi_json gem don't work on if a user uses an older version of RubyGem, because multi_json requires a newer version (>= 1.3.6). Good example of this is Ubuntu 10.04 where the latest RubyGem version available in the official APT repo is 1.3.5.

My solution is probably not the best and the final one, but I just want to start the discussion so we can figure out a best solution for this together.

@bradgignac
Member

@geemus Have you gotten any other reports of this? This seems like it would be super problematic.

@geemus
Member
geemus commented Jul 11, 2012

@bradgignac - no, don't think I've heard about this particular one before.

@geemus
Member
geemus commented Jul 11, 2012

@Kami - I think a slightly older version of multi_json might not require the newer rubygems (as a workaround for the time being). That said, seems like a better generic solution is worth doing. I've never much liked multi_json as a part of the setup, but it was requested by multiple parties. Maybe something like it (but with less crazy requirements) is worth doing.

@Kami
Kami commented Jul 11, 2012

@geemus I already checked that and sadly all of the multi_json versions besides the really first one (0.0.2) require RubyGem >= 1.3.6.

@Kami
Kami commented Jul 12, 2012

@geemus ^^ any other ideas?

@geemus
Member
geemus commented Jul 12, 2012

@Kami - can you update rubygems directly? ie gem update --system should update the rubygems, even if it doesn't appear on apt. Otherwise we can probably do some kind of conditional thing as you did, but it complicates the code a good deal.

@Kami
Kami commented Jul 12, 2012

@geemus We use system (apt) version of rubygems so sadly upgrading using gem update --system is not an option.

@bradgignac
Member

Should the fog gemspec be updated to indicate it won't work with versions lower than 1.3.6?

@Kami
Kami commented Jul 12, 2012

@bradgignac I don't thing that's the right solution / doesn't change anything since the dependency already declares that.

@Kami
Kami commented Jul 23, 2012

@bradgignac, @geemus Any other suggestions?

@geemus
Member
geemus commented Jul 24, 2012

@Kami - I was never that keen on multi_json in the first place :(, but it was requested a lot. I think something like your fix should be what we do, but I would consolidate a bit. Namely I'd like to see it a bit more like this:

begin
  require 'multi_json'
  define multi_json_stuff
    ...
  end
rescue LoadError
  require 'json'
  define json_stuff
    ...
  end
end

Will that work for you? I would prefer to leave multi_json in the dependencies if possible, but does that fail right away for you? Since older Rubies do not include json in stdlib it would have to be installed/required, so I don't want to end up with something that only works if you have the additional knowledge to install one of either multi_json or json. Make sense?

@Kami
Kami commented Jul 24, 2012

@geemus Yeah, sounds good. I will update the patch with the approach you suggested later today. Thanks.

@geemus
Member
geemus commented Jul 24, 2012

@Kami - thanks, and sorry for the delay. None of the approaches seemed awesome but I did want to address it, so it seems I maybe dragged my feet a bit. Hopefully we can get it sorted out now pretty quickly though.

@nirvdrum
Collaborator
nirvdrum commented Mar 4, 2013

The 'json' lib is now shipped with JRuby and MRI (probably rbx, too, but I don't have an install to check). Maybe removing multi_json is the way to go.

@geemus
Member
geemus commented Mar 4, 2013

@nirvdrum - perhaps. I think we may be stuck with it for now though (for the sake of earlier MRI versions).

@nirvdrum
Collaborator
nirvdrum commented Mar 4, 2013

Ahh, good point.

@geemus
Member
geemus commented Mar 4, 2013

@nirvdrum - yeah, old MRIs are a thorn in our collective side... Seems like there are enough random reasons why some people can't or won't upgrade that we can't really start cutting support though (at least last time I checked). Hopefully this will change in time.

@nirvdrum
Collaborator
nirvdrum commented Mar 4, 2013

I actually like that fog is willing to support its user base. I was being a bit short-sighted is all. At the time I was thinking that "json" won the war and is a sensible default, but I don't know how well "json" supports older rubies.

@geemus
Member
geemus commented Mar 4, 2013

@nirvdrum - yeah, it is unfortunately pretty complicated. Partly it also has to do with performance (for some users) as a number of the non-json libraries are quite a bit faster.

@krames
Member
krames commented Apr 1, 2013

If at all possible, I would like to resolve this issue so I can get rackspace-fog removed from gemcutter.

@geemus @Kami Are the comments in this thread still valid?

If they are, I would like to update the gemspec to require json and then update Fog::JSON to attempt to load and use multi_json first before falling back to JSON. Or are we past a point where the json gem would be an expectable solution?

@Kami Do you have a timeline for moving off Ubuntu 10.04?

@geemus
Member
geemus commented Apr 1, 2013

@krames - To the best of my knowledge multi_json still wouldn't work with old rubygems and json isn't necessarily just available on older MRI. Additionally a lot of people may want to use something other than json as json is not the most performant of options here. json in the gemspec is probably ok, ditto the fallback.

@geemus
Member
geemus commented Apr 1, 2013

@krames - could you explain how this relates to removing rackspace-fog?

@krames
Member
krames commented Apr 1, 2013

@geemus Sorry!i forgot to mention that. A gem called rackspace-fog is a fork of fog that was created that replaces multijson with the json parser.

@Kami
Kami commented Apr 1, 2013

@krames This problem is not unique to us (Rackspace). Everyone who uses Ubuntu 10.04 which comes with an older version of RubyGem will encounter this problem.

@geemus
Member
geemus commented Apr 1, 2013

@Kami - got it, no worries. Just didn't realize that was the outcome of this stuff.

@krames
Member
krames commented Apr 3, 2013

I have created pull request #1730 to address this issue using the latest master.

Can everyone give me your opinions?

@Kami
Kami commented Apr 4, 2013

@krames Thanks.

I'm closing this one in favor of #1730.

@Kami Kami closed this Apr 4, 2013
@sferik
sferik commented May 5, 2013

I wish someone had pinged me about this. I’d have looked into releasing a version of multi_json with a looser required_rubygems_version. Is this still an issue for Ubuntu 10.04?

@geemus
Member
geemus commented May 5, 2013

@sferik - sorry about that. At the time we basically just sought to address the problem in the quickest/easiest way, but we should have reviewed and remediated after the fact instead of just letting it slide. If we could put together a multi_json that works with other rubygems (and therefore this old ubuntu) that would be great. Thanks!

@jphpsf
jphpsf commented May 5, 2013

@Kami If you need to get a more recent version of rubygems for Ubuntu, I highly recommend to check out Brightbox's Ruby NG PPA. PPAs are 3rd party repositories that can be used by apt-get. I've been using Ruby NG for quite sometime now and it was much easier to use than RVM imho in order to get a recent Ruby stack.

See more details on blog post or PPA on Launchpad.

In a nutshell, all you need to do is this:

sudo apt-add-repository ppa:brightbox/ruby-ng
sudo apt-get update
sudo apt-get install ruby rubygems ruby-switch ruby1.9.1

Would that be helpful to resolve your problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment