Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Bundler does not load Net::HTTP library for Rails app in 1.14.6 #5540

Closed
remomueller opened this issue Mar 28, 2017 · 2 comments
Closed

Bundler does not load Net::HTTP library for Rails app in 1.14.6 #5540

remomueller opened this issue Mar 28, 2017 · 2 comments

Comments

@remomueller
Copy link

remomueller commented Mar 28, 2017

Bundler version 1.14.6 doesn't appear to load Net::HTTP when loading up a Rails app (5.0.1 or 5.0.2) on Ruby (2.4.0 or 2.4.1).

When you downgrade to bundler version 1.14.3 this works without needing to include require 'net/http' for every model. Here's a quick example:

rails c

Loading development environment (Rails 5.0.2)
2.4.1 :001 > Bundler::VERSION
 => "1.14.6" 
2.4.1 :002 > url = URI.parse('https://www.google.com')
 => #<URI::HTTPS https://www.google.com> 
2.4.1 :003 > http = Net::HTTP.new(url.host, url.port)
NameError: uninitialized constant Net::HTTP
  from (irb):3
  from /usr/local/rvm/gems/ruby-2.4.1/gems/railties-5.0.2/lib/rails/commands/console.rb:65:in `start'
  from /usr/local/rvm/gems/ruby-2.4.1/gems/railties-5.0.2/lib/rails/commands/console_helper.rb:9:in `start'
  from /usr/local/rvm/gems/ruby-2.4.1/gems/railties-5.0.2/lib/rails/commands/commands_tasks.rb:78:in `console'
  from /usr/local/rvm/gems/ruby-2.4.1/gems/railties-5.0.2/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
  from /usr/local/rvm/gems/ruby-2.4.1/gems/railties-5.0.2/lib/rails/commands.rb:18:in `<top (required)>'
  from bin/rails:4:in `require'
  from bin/rails:4:in `<main>'
2.4.1 :004 > exit

gem uninstall bundler

gem install bundler --no-document -v=1.14.3

rails c

Loading development environment (Rails 5.0.2)
2.4.1 :001 > Bundler::VERSION
 => "1.14.3" 
2.4.1 :002 > url = URI.parse('https://www.google.com')
 => #<URI::HTTPS https://www.google.com> 
2.4.1 :003 > http = Net::HTTP.new(url.host, url.port)
 => #<Net::HTTP www.google.com:443 open=false> 
2.4.1 :004 > exit

I also replied to a post with a similar problem over on Stack Overflow.

Is this intended behavior going forward, ie, should you explicitly need to require the net/http library if you are going to reference it, or is this a regression?

Thanks!

@segiddins
Copy link
Member

This is intentional -- Bundler never intended to require net/http, and it wasn't guaranteed that it would (i.e. by using standalone mode). Please require the libraries that your application is using, and our apologies for the trouble!

@remomueller
Copy link
Author

OK good to know, thanks for the explanation!

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

No branches or pull requests

2 participants