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

Lazy-load io/console to avoid activating the gem unecessarily #539

Merged
merged 1 commit into from
Feb 12, 2017

Conversation

segiddins
Copy link
Contributor

No description provided.

@segiddins
Copy link
Contributor Author

Ping on getting this reviewed? Thanks!

@piotrmurach
Copy link

Hey, have you found it to be performance issue? I'm curious to see whether hiding file dependency in the bowels of codebase is good enough tradeoff?

@rafaelfranca
Copy link
Member

The main reason to lazy loading it is that it is being extracted to a gem in Ruby 2.4+ and it may not be present in a ruby installation. It also is only necessary if the ruby installation doesn't have readline.

This change does make sense. Thanks.

@rafaelfranca rafaelfranca merged commit 1c14743 into rails:master Feb 12, 2017
@segiddins
Copy link
Contributor Author

Its not a performance issue, but rather an issue for bundler & other gems -- if io-console is eagerly loaded, then the user cannot control what version is used

@segiddins segiddins deleted the seg-lazy-load-io-console branch February 12, 2017 22:54
@piotrmurach
Copy link

I'm asking cuz I'm in a similar boat relying on 'io-console' and in particular in changing echo mode. I guess I'm looking for a robust solution. For example, what will happen if you're running on Ruby 2.4 and io-console gem is not installed whether through bundler or rubygems? Will the application explode with LoadError when that particular branch is called?

@rafaelfranca
Copy link
Member

Yeah, that is what would happen today. We can improve it though with a fallback.

Iristyle added a commit to Iristyle/puppet that referenced this pull request May 10, 2017
 - On Fedora 25, Bundler will outright crash as it has a hard
   dependency on io/console by way of the Thor CLI library.

   Bundler 1.14-6 vendors Thor 0.19.1

   https://github.com/bundler/bundler/blob/v1.14.6/lib/bundler/vendor/thor/lib/thor/version.rb
   https://github.com/erikhuda/thor/blob/v0.19.1/lib/thor/shell/basic.rb#L2

   The hard dependency has been removed in an as of yet unshipped
   version of Thor via rails/thor#539
   meaning that at some point it will not be necessary to have
   io/console installed for Bundler.

   For now, it remains a hard dependency,
   without which calling Bundler will fail with an error like:

 /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- io/console (LoadError)
  from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'
  from /usr/local/share/gems/gems/bundler-1.14.6/lib/bundler/vendor/thor/lib/thor/shell/basic.rb:2:in `<top (required)>'
  from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'
  from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'
  from /usr/local/share/gems/gems/bundler-1.14.6/lib/bundler/vendor/thor/lib/thor/shell/color.rb:1:in `<top (required)>'
  from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'
  from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'
  from /usr/local/share/gems/gems/bundler-1.14.6/lib/bundler/vendor/thor/lib/thor/shell.rb:17:in `shell'
  from /usr/local/share/gems/gems/bundler-1.14.6/lib/bundler/ui/shell.rb:15:in `initialize'
  from /usr/local/share/gems/gems/bundler-1.14.6/lib/bundler/cli.rb:13:in `new'
  from /usr/local/share/gems/gems/bundler-1.14.6/lib/bundler/cli.rb:13:in `rescue in start'
  from /usr/local/share/gems/gems/bundler-1.14.6/lib/bundler/cli.rb:17:in `start'
  from /usr/local/share/gems/gems/bundler-1.14.6/exe/bundle:32:in `block in <top (required)>'
  from /usr/local/share/gems/gems/bundler-1.14.6/lib/bundler/friendly_errors.rb:121:in `with_friendly_errors'
  from /usr/local/share/gems/gems/bundler-1.14.6/exe/bundle:24:in `<top (required)>'
  from /usr/local/bin/bundle:23:in `load'
  from /usr/local/bin/bundle:23:in `<main>'
Iristyle added a commit to Iristyle/puppet that referenced this pull request May 10, 2017
 - On Fedora 25, Bundler will outright crash as it has a hard
   dependency on io/console by way of the Thor CLI library.

   Bundler 1.14-6 vendors Thor 0.19.1

   https://github.com/bundler/bundler/blob/v1.14.6/lib/bundler/vendor/thor/lib/thor/version.rb
   https://github.com/erikhuda/thor/blob/v0.19.1/lib/thor/shell/basic.rb#L2

   The hard dependency has been removed in an as of yet unshipped
   version of Thor via rails/thor#539
   meaning that at some point it will not be necessary to have
   io/console installed for Bundler.

   For now, it remains a hard dependency,
   without which calling Bundler will fail with an error like:

 /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- io/console (LoadError)
  from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'
  from /usr/local/share/gems/gems/bundler-1.14.6/lib/bundler/vendor/thor/lib/thor/shell/basic.rb:2:in `<top (required)>'
  from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'
  from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'
  from /usr/local/share/gems/gems/bundler-1.14.6/lib/bundler/vendor/thor/lib/thor/shell/color.rb:1:in `<top (required)>'
  from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'
  from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'
  from /usr/local/share/gems/gems/bundler-1.14.6/lib/bundler/vendor/thor/lib/thor/shell.rb:17:in `shell'
  from /usr/local/share/gems/gems/bundler-1.14.6/lib/bundler/ui/shell.rb:15:in `initialize'
  from /usr/local/share/gems/gems/bundler-1.14.6/lib/bundler/cli.rb:13:in `new'
  from /usr/local/share/gems/gems/bundler-1.14.6/lib/bundler/cli.rb:13:in `rescue in start'
  from /usr/local/share/gems/gems/bundler-1.14.6/lib/bundler/cli.rb:17:in `start'
  from /usr/local/share/gems/gems/bundler-1.14.6/exe/bundle:32:in `block in <top (required)>'
  from /usr/local/share/gems/gems/bundler-1.14.6/lib/bundler/friendly_errors.rb:121:in `with_friendly_errors'
  from /usr/local/share/gems/gems/bundler-1.14.6/exe/bundle:24:in `<top (required)>'
  from /usr/local/bin/bundle:23:in `load'
  from /usr/local/bin/bundle:23:in `<main>'
Iristyle added a commit to Iristyle/puppet that referenced this pull request May 10, 2017
 - On Fedora 25, Bundler will outright crash as it has a hard
   dependency on io/console by way of the Thor CLI library.

   Bundler 1.14-6 vendors Thor 0.19.1

   https://github.com/bundler/bundler/blob/v1.14.6/lib/bundler/vendor/thor/lib/thor/version.rb
   https://github.com/erikhuda/thor/blob/v0.19.1/lib/thor/shell/basic.rb#L2

   The hard dependency has been removed in an as of yet unshipped
   version of Thor via rails/thor#539
   meaning that at some point it will not be necessary to have
   io/console installed for Bundler.

   For now, it remains a hard dependency,
   without which calling Bundler will fail with an error like:

 /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- io/console (LoadError)
  from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'
  from /usr/local/share/gems/gems/bundler-1.14.6/lib/bundler/vendor/thor/lib/thor/shell/basic.rb:2:in `<top (required)>'
  from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'
  from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'
  from /usr/local/share/gems/gems/bundler-1.14.6/lib/bundler/vendor/thor/lib/thor/shell/color.rb:1:in `<top (required)>'
  from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'
  from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'
  from /usr/local/share/gems/gems/bundler-1.14.6/lib/bundler/vendor/thor/lib/thor/shell.rb:17:in `shell'
  from /usr/local/share/gems/gems/bundler-1.14.6/lib/bundler/ui/shell.rb:15:in `initialize'
  from /usr/local/share/gems/gems/bundler-1.14.6/lib/bundler/cli.rb:13:in `new'
  from /usr/local/share/gems/gems/bundler-1.14.6/lib/bundler/cli.rb:13:in `rescue in start'
  from /usr/local/share/gems/gems/bundler-1.14.6/lib/bundler/cli.rb:17:in `start'
  from /usr/local/share/gems/gems/bundler-1.14.6/exe/bundle:32:in `block in <top (required)>'
  from /usr/local/share/gems/gems/bundler-1.14.6/lib/bundler/friendly_errors.rb:121:in `with_friendly_errors'
  from /usr/local/share/gems/gems/bundler-1.14.6/exe/bundle:24:in `<top (required)>'
  from /usr/local/bin/bundle:23:in `load'
  from /usr/local/bin/bundle:23:in `<main>'
Iristyle added a commit to Iristyle/puppet that referenced this pull request May 10, 2017
 - On Fedora 25, Bundler will outright crash as it has a hard
   dependency on io/console by way of the Thor CLI library.

   Bundler 1.14-6 vendors Thor 0.19.1

   https://github.com/bundler/bundler/blob/v1.14.6/lib/bundler/vendor/thor/lib/thor/version.rb
   https://github.com/erikhuda/thor/blob/v0.19.1/lib/thor/shell/basic.rb#L2

   The hard dependency has been removed in an as of yet unshipped
   version of Thor via rails/thor#539
   meaning that at some point it will not be necessary to have
   io/console installed for Bundler.

   For now, it remains a hard dependency,
   without which calling Bundler will fail with an error like:

 /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- io/console (LoadError)
  from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'
  from /usr/local/share/gems/gems/bundler-1.14.6/lib/bundler/vendor/thor/lib/thor/shell/basic.rb:2:in `<top (required)>'
  from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'
  from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'
  from /usr/local/share/gems/gems/bundler-1.14.6/lib/bundler/vendor/thor/lib/thor/shell/color.rb:1:in `<top (required)>'
  from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'
  from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'
  from /usr/local/share/gems/gems/bundler-1.14.6/lib/bundler/vendor/thor/lib/thor/shell.rb:17:in `shell'
  from /usr/local/share/gems/gems/bundler-1.14.6/lib/bundler/ui/shell.rb:15:in `initialize'
  from /usr/local/share/gems/gems/bundler-1.14.6/lib/bundler/cli.rb:13:in `new'
  from /usr/local/share/gems/gems/bundler-1.14.6/lib/bundler/cli.rb:13:in `rescue in start'
  from /usr/local/share/gems/gems/bundler-1.14.6/lib/bundler/cli.rb:17:in `start'
  from /usr/local/share/gems/gems/bundler-1.14.6/exe/bundle:32:in `block in <top (required)>'
  from /usr/local/share/gems/gems/bundler-1.14.6/lib/bundler/friendly_errors.rb:121:in `with_friendly_errors'
  from /usr/local/share/gems/gems/bundler-1.14.6/exe/bundle:24:in `<top (required)>'
  from /usr/local/bin/bundle:23:in `load'
  from /usr/local/bin/bundle:23:in `<main>'
eputnam pushed a commit to eputnam/puppet that referenced this pull request Jul 12, 2017
 - On Fedora 25, Bundler will outright crash as it has a hard
   dependency on io/console by way of the Thor CLI library.

   Bundler 1.14-6 vendors Thor 0.19.1

   https://github.com/bundler/bundler/blob/v1.14.6/lib/bundler/vendor/thor/lib/thor/version.rb
   https://github.com/erikhuda/thor/blob/v0.19.1/lib/thor/shell/basic.rb#L2

   The hard dependency has been removed in an as of yet unshipped
   version of Thor via rails/thor#539
   meaning that at some point it will not be necessary to have
   io/console installed for Bundler.

   For now, it remains a hard dependency,
   without which calling Bundler will fail with an error like:

 /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- io/console (LoadError)
  from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'
  from /usr/local/share/gems/gems/bundler-1.14.6/lib/bundler/vendor/thor/lib/thor/shell/basic.rb:2:in `<top (required)>'
  from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'
  from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'
  from /usr/local/share/gems/gems/bundler-1.14.6/lib/bundler/vendor/thor/lib/thor/shell/color.rb:1:in `<top (required)>'
  from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'
  from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'
  from /usr/local/share/gems/gems/bundler-1.14.6/lib/bundler/vendor/thor/lib/thor/shell.rb:17:in `shell'
  from /usr/local/share/gems/gems/bundler-1.14.6/lib/bundler/ui/shell.rb:15:in `initialize'
  from /usr/local/share/gems/gems/bundler-1.14.6/lib/bundler/cli.rb:13:in `new'
  from /usr/local/share/gems/gems/bundler-1.14.6/lib/bundler/cli.rb:13:in `rescue in start'
  from /usr/local/share/gems/gems/bundler-1.14.6/lib/bundler/cli.rb:17:in `start'
  from /usr/local/share/gems/gems/bundler-1.14.6/exe/bundle:32:in `block in <top (required)>'
  from /usr/local/share/gems/gems/bundler-1.14.6/lib/bundler/friendly_errors.rb:121:in `with_friendly_errors'
  from /usr/local/share/gems/gems/bundler-1.14.6/exe/bundle:24:in `<top (required)>'
  from /usr/local/bin/bundle:23:in `load'
  from /usr/local/bin/bundle:23:in `<main>'
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

Successfully merging this pull request may close these issues.

3 participants