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

Is json gem needed for Ruby 1.9? #20

Closed
ma11hew28 opened this issue Apr 27, 2011 · 6 comments
Closed

Is json gem needed for Ruby 1.9? #20

ma11hew28 opened this issue Apr 27, 2011 · 6 comments

Comments

@ma11hew28
Copy link

When I did gem install flickraw, it installed the gem json-1.5.1. For Ruby 1.9, require 'json' is supported out of the box, so is this necessary?

If not, please use something like gem "json", :platforms => [:ruby_18, :jruby, :mswin, :mingw_18] in the Gemfile.

I like to keep my gem list as clean as possible. :)

Ref: http://gembundler.com/man/gemfile.5.html

Thanks!

Matt

@hanklords
Copy link
Owner

Hello Matt,

Json dependency is not required for ruby 1.9 since it is in the stdlib. However there is no way to define a conditional dependency in the gemspec. I am considering removing it anyway, everybody should use 1.9 :)

@hanklords
Copy link
Owner

ca1af0b removes json dependency.

@felipeelias
Copy link

I'm still using ruby 1.8 and I ran into this issue today.

I'm quite sure bundler solve this issue with specific ruby dependencies as @mattdipasquale posted. You can check a example here

If you don't have plans to move to bundler, at least post a note in the docs for ruby 1.8 users, please :)

@hanklords
Copy link
Owner

I don't see how bundler solve this problem. If you need flickraw in your app you put something like gem "flickraw" in your Gemfile and bundler has no way, whatever I do with flickraw packaging, to know that it depends on json for ruby 1.8 only. It is just a limitation of rubygems.
Maybe I am missing something ?

I agree with you on the documentation. I will update this.

@felipeelias
Copy link

My bad, bundler only handles that in development.

The following code actually works:

if Gem::Version.new(RUBY_VERSION.dup) <= Gem::Version.new("1.8.7")
  s.add_dependency "json", ...
end

I've seen this code before, but instead of RUBY_VERSION it was Gem::VERSION. I'm not quite sure whether this is a good practice or not.

@hanklords
Copy link
Owner

This doesn't work : it is executed once on the machine building the gem (when you do gem build flickraw.gemspec).

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

3 participants