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

stringio is required eagerly by RubyGems #2772

Closed
eregon opened this issue May 21, 2019 · 4 comments

Comments

@eregon
Copy link
Contributor

commented May 21, 2019

Currently, RubyGems requires stringio eagerly:

require 'stringio'

The only usage in that file though seems in

io = StringIO.new

where it could be required on demand.

The effect of this is that StringIO is defined in MRI, without require, which makes some gems accidentally rely on RubyGems loading it:

$ ruby -e 'p StringIO'                                                
StringIO

How about requiring stringio lazily in RubyGems, so users of stringio must require it explicitly like other stdlibs, and notice easily the missing require if --disable-gems is used?

This issue is related to:

  • Other

I will abide by the code of conduct.

@eregon

This comment has been minimized.

Copy link
Contributor Author

commented May 21, 2019

FWIW, there are quite a few files loaded eagerly by RubyGems on startup, making startup slower:

$ ruby --disable-gems -ve 'puts $"'         
ruby 2.6.2p47 (2019-03-13 revision 67232) [x86_64-linux]
enumerator.so
thread.rb
rational.so
complex.so
/home/eregon/.rubies/ruby-2.6.2/lib/ruby/2.6.0/x86_64-linux/enc/encdb.so
/home/eregon/.rubies/ruby-2.6.2/lib/ruby/2.6.0/x86_64-linux/enc/trans/transdb.so
$ ruby -ve 'puts $"' | grep -v rubygems | grep -v did_you_mean
ruby 2.6.2p47 (2019-03-13 revision 67232) [x86_64-linux]
enumerator.so
thread.rb
rational.so
complex.so
/home/eregon/.rubies/ruby-2.6.2/lib/ruby/2.6.0/x86_64-linux/enc/encdb.so
/home/eregon/.rubies/ruby-2.6.2/lib/ruby/2.6.0/x86_64-linux/enc/trans/transdb.so
Required by RubyGems:
/home/eregon/.rubies/ruby-2.6.2/lib/ruby/2.6.0/x86_64-linux/rbconfig.rb
/home/eregon/.rubies/ruby-2.6.2/lib/ruby/2.6.0/delegate.rb
/home/eregon/.rubies/ruby-2.6.2/lib/ruby/2.6.0/uri/rfc2396_parser.rb
/home/eregon/.rubies/ruby-2.6.2/lib/ruby/2.6.0/uri/rfc3986_parser.rb
/home/eregon/.rubies/ruby-2.6.2/lib/ruby/2.6.0/uri/common.rb
/home/eregon/.rubies/ruby-2.6.2/lib/ruby/2.6.0/uri/generic.rb
/home/eregon/.rubies/ruby-2.6.2/lib/ruby/2.6.0/uri/file.rb
/home/eregon/.rubies/ruby-2.6.2/lib/ruby/2.6.0/uri/ftp.rb
/home/eregon/.rubies/ruby-2.6.2/lib/ruby/2.6.0/uri/http.rb
/home/eregon/.rubies/ruby-2.6.2/lib/ruby/2.6.0/uri/https.rb
/home/eregon/.rubies/ruby-2.6.2/lib/ruby/2.6.0/uri/ldap.rb
/home/eregon/.rubies/ruby-2.6.2/lib/ruby/2.6.0/uri/ldaps.rb
/home/eregon/.rubies/ruby-2.6.2/lib/ruby/2.6.0/uri/mailto.rb
/home/eregon/.rubies/ruby-2.6.2/lib/ruby/2.6.0/uri.rb
/home/eregon/.rubies/ruby-2.6.2/lib/ruby/2.6.0/x86_64-linux/stringio.so
/home/eregon/.rubies/ruby-2.6.2/lib/ruby/2.6.0/monitor.rb
@deivid-rodriguez

This comment has been minimized.

Copy link
Contributor

commented May 21, 2019

@eregon Yeah, I'm totally fine with lazily requiring stringio if we can 👍

@deivid-rodriguez

This comment has been minimized.

Copy link
Contributor

commented May 22, 2019

Also, since stringio is now gemified, this also means we won't impose any requirement on end users of the gem.

@bronzdoc bronzdoc referenced this issue May 29, 2019

Merged

Lazy require stringio #2781

0 of 4 tasks complete

bundlerbot bot pushed a commit that referenced this issue Jun 3, 2019

Merge #2781
2781: Lazy require stringio r=bronzdoc a=bronzdoc

# Description:
close #2772
______________

# Tasks:

- [ ] Describe the problem / feature
- [ ] Write tests
- [ ] Write code to solve the problem
- [ ] Get code review from coworkers / friends

I will abide by the [code of conduct](https://github.com/rubygems/rubygems/blob/master/CODE_OF_CONDUCT.md).


Co-authored-by: bronzdoc <lsagastume1990@gmail.com>

@bundlerbot bundlerbot bot closed this in #2781 Jun 3, 2019

@eregon

This comment has been minimized.

Copy link
Contributor Author

commented Jun 3, 2019

@deivid-rodriguez @bronzdoc Thanks for the discussion and fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants
You can’t perform that action at this time.