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

Ruby 2.7.0 compatibility. #582

Closed
vincentwoo opened this issue Dec 28, 2019 · 12 comments
Closed

Ruby 2.7.0 compatibility. #582

vincentwoo opened this issue Dec 28, 2019 · 12 comments

Comments

@vincentwoo
Copy link

It seems that after upgrade I am unable to cast an HTTP-rb response to a string:

[4] pry(main)> resp.to_s
/app/vendor/bundle/ruby/2.7.0/gems/pry-0.12.2/lib/pry/exceptions.rb:28: warning: $SAFE will become a normal global variable in Ruby 3.0
FrozenError: can't modify frozen String: ""
from /app/vendor/bundle/ruby/2.7.0/gems/http-4.2.0/lib/http/response/body.rb:52:in `force_encoding'
[5] pry(main)> resp.body.to_s
/app/vendor/bundle/ruby/2.7.0/gems/pry-0.12.2/lib/pry/exceptions.rb:28: warning: $SAFE will become a normal global variable in Ruby 3.0
HTTP::StateError: body is being streamed
from /app/vendor/bundle/ruby/2.7.0/gems/http-4.2.0/lib/http/response/body.rb:45:in `to_s'
[6] pry(main)> resp.class
HTTP::Response < Object
[7] pry(main)> resp.to_s
/app/vendor/bundle/ruby/2.7.0/gems/pry-0.12.2/lib/pry/exceptions.rb:28: warning: $SAFE will become a normal global variable in Ruby 3.0
HTTP::StateError: body is being streamed
from /app/vendor/bundle/ruby/2.7.0/gems/http-4.2.0/lib/http/response/body.rb:45:in `to_s'
@vincentwoo
Copy link
Author

Perhaps clearer:

Vincents-MacBook-Pro:coderpad.io vwoo$ gem info http

*** LOCAL GEMS ***

http (4.2.0)
    Authors: Tony Arcieri, Erik Michaels-Ober, Alexey V. Zapparov,
    Zachary Anker
    Homepage: https://github.com/httprb/http
    License: MIT
    Installed at: /Users/vwoo/.gem/ruby/2.7.0

    HTTP should be easy
Vincents-MacBook-Pro:coderpad.io vwoo$ ruby --version
ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-darwin19]
Vincents-MacBook-Pro:coderpad.io vwoo$ irb
irb(main):001:0> require 'http'
=> true
irb(main):002:0>  HTTP.get('https://google.com').to_s
Traceback (most recent call last):
        7: from /Users/vwoo/.rubies/ruby-2.7.0/bin/irb:23:in `<main>'
        6: from /Users/vwoo/.rubies/ruby-2.7.0/bin/irb:23:in `load'
        5: from /Users/vwoo/.rubies/ruby-2.7.0/lib/ruby/gems/2.7.0/gems/irb-1.2.1/exe/irb:11:in `<top (required)>'
        4: from (irb):2
        3: from /Users/vwoo/.rubies/ruby-2.7.0/lib/ruby/2.7.0/forwardable.rb:235:in `to_s'
        2: from /Users/vwoo/.gem/ruby/2.7.0/gems/http-4.2.0/lib/http/response/body.rb:52:in `to_s'
        1: from /Users/vwoo/.gem/ruby/2.7.0/gems/http-4.2.0/lib/http/response/body.rb:52:in `force_encoding'
FrozenError (can't modify frozen String: "")
irb(main):003:0* /app/vendor/bundle/ruby/2.7.0/gems/pry-0.12.2/lib/pry/exceptions.rb:28: warning: $SAFE will become
a normal global variable in Ruby 3.0
irb(main):004:0* FrozenError: can't modify frozen String: ""
irb(main):005:0* from /app/vendor/bundle/ruby/2.7.0/gems/http-4.2.0/lib/http/response/body.rb:52:in `force_encoding'

@vincentwoo
Copy link
Author

And perhaps even more clearly:

Vincents-MacBook-Pro:coderpad.io vwoo$ ruby --version
ruby 2.6.4p104 (2019-08-28 revision 67798) [x86_64-darwin18]
Vincents-MacBook-Pro:coderpad.io vwoo$ gem info http

*** LOCAL GEMS ***

http (4.2.0)
    Authors: Tony Arcieri, Erik Michaels-Ober, Alexey V. Zapparov,
    Zachary Anker
    Homepage: https://github.com/httprb/http
    License: MIT
    Installed at: /Users/vwoo/.gem/ruby/2.6.4

    HTTP should be easy
Vincents-MacBook-Pro:coderpad.io vwoo$ ruby -e "require 'http'; puts HTTP.get('https://google.com').to_s.length"
220
Vincents-MacBook-Pro:coderpad.io vwoo$ chruby ruby-2.7.0
Vincents-MacBook-Pro:coderpad.io vwoo$ gem info http

*** LOCAL GEMS ***

http (4.2.0)
    Authors: Tony Arcieri, Erik Michaels-Ober, Alexey V. Zapparov,
    Zachary Anker
    Homepage: https://github.com/httprb/http
    License: MIT
    Installed at: /Users/vwoo/.gem/ruby/2.7.0

    HTTP should be easy
Vincents-MacBook-Pro:coderpad.io vwoo$ ruby -e "require 'http'; puts HTTP.get('https://google.com').to_s.length"
Traceback (most recent call last):
	3: from -e:1:in `<main>'
	2: from /Users/vwoo/.rubies/ruby-2.7.0/lib/ruby/2.7.0/forwardable.rb:235:in `to_s'
	1: from /Users/vwoo/.gem/ruby/2.7.0/gems/http-4.2.0/lib/http/response/body.rb:52:in `to_s'
/Users/vwoo/.gem/ruby/2.7.0/gems/http-4.2.0/lib/http/response/body.rb:52:in `force_encoding': can't modify frozen String: "" (FrozenError)

@ixti
Copy link
Member

ixti commented Dec 28, 2019

Yes, apparently it is. There's fix applied to master I will backport it to 4.2.X branch during this weekend.

@vincentwoo
Copy link
Author

Any chance we could get a quick 4.2.1 release?

@ixti
Copy link
Member

ixti commented Dec 31, 2019

http form data also needs update - I'll tackle that as soon as possible.

@psisson
Copy link

psisson commented Jan 8, 2020

Are you going to fix your code? What is the delay?

@ixti
Copy link
Member

ixti commented Jan 8, 2020

@psisson

Are you going to fix your code? What is the delay?

I seriously doubt you're the one I have to report to on why I had no time to work on bringing compatibility with latest Ruby version.

@ixti ixti changed the title Is http-rb broken on Ruby 2.7.0? Ruby 2.7.0 compatibility. Jan 8, 2020
@psisson
Copy link

psisson commented Jan 8, 2020

I seriously doubt you're the one I have to report to on why I had no time to work on bringing compatibility with latest Ruby version.

No, you do not report to me, but you should feel some responsibility to promptly fix your code when thousands of users use this gem in production code.

@ook
Copy link
Contributor

ook commented Jan 8, 2020

@psisson AFAIK, http.rb didn't advertise compatibility with ruby 2.7, which is 13days old… Of course, your patches are welcome.

@ixti
Copy link
Member

ixti commented Jan 8, 2020

@psisson I feel responsibility to keep this gem stable on what we support, see README - it is pretty obvious which versions of ruby this gem was tested and guaranteed to be working.

Also not judging anybody, but I believe that those who upgrade production to use 16 days old Ruby version should visit a doctor to check of possible cerebral aneurysm that inhibits sane perception of reality.

@tarcieri
Copy link
Member

tarcieri commented Jan 8, 2020

Let’s keep it cordial everyone.

Are you going to fix your code? What is the delay?

This is an open source project run by volunteers, and like every OSS project those volunteers have limited time and resources to give to supporting the project.

Please be respectful of this when commenting on issues. If you would like to help accelerate Ruby 2.7 support, I would suggest helping out in doing the relevant work.

@ixti
Copy link
Member

ixti commented Jan 9, 2020

Many thanks to @janko for fixing ruby-2.7 compatibility in both this gem and http-form_data. Fixes are available in master and released as 4.3.0 version on rubygems.

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

5 participants