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

Add missing fileutils require in rubygems installer #4036

Merged
merged 1 commit into from Oct 30, 2020

Conversation

deivid-rodriguez
Copy link
Member

What was the end-user or developer problem that led to this PR?

When bundling a git gem including executables, the second time bundle install
is run (when the gem has been cached), we would get a crash like:

NameError: uninitialized constant Gem::Installer::FileUtils
Did you mean?  FileTest
  /home/deivid/.rbenv/versions/2.7.2/lib/ruby/site_ruby/2.7.0/rubygems/installer.rb:536:in `generate_bin_script'
  /home/deivid/.rbenv/versions/2.7.2/lib/ruby/site_ruby/2.7.0/rubygems/installer.rb:506:in `block in generate_bin'
  /home/deivid/.rbenv/versions/2.7.2/lib/ruby/site_ruby/2.7.0/rubygems/installer.rb:482:in `each'
  /home/deivid/.rbenv/versions/2.7.2/lib/ruby/site_ruby/2.7.0/rubygems/installer.rb:482:in `generate_bin'
  /home/deivid/.rbenv/versions/2.7.2/lib/ruby/site_ruby/2.7.0/bundler/source/path/installer.rb:46:in `generate_bin'
  /home/deivid/.rbenv/versions/2.7.2/lib/ruby/site_ruby/2.7.0/bundler/source/path/installer.rb:36:in `post_install'
  /home/deivid/.rbenv/versions/2.7.2/lib/ruby/site_ruby/2.7.0/bundler/source/path.rb:242:in `generate_bin'
  /home/deivid/.rbenv/versions/2.7.2/lib/ruby/site_ruby/2.7.0/bundler/source/git.rb:184:in `install'
  /home/deivid/.rbenv/versions/2.7.2/lib/ruby/site_ruby/2.7.0/bundler/installer/gem_installer.rb:67:in `install'
  /home/deivid/.rbenv/versions/2.7.2/lib/ruby/site_ruby/2.7.0/bundler/installer/gem_installer.rb:18:in `install_from_spec'
  /home/deivid/.rbenv/versions/2.7.2/lib/ruby/site_ruby/2.7.0/bundler/installer/parallel_installer.rb:163:in `do_install'
  /home/deivid/.rbenv/versions/2.7.2/lib/ruby/site_ruby/2.7.0/bundler/installer/parallel_installer.rb:148:in `install_serially'
  /home/deivid/.rbenv/versions/2.7.2/lib/ruby/site_ruby/2.7.0/bundler/installer/parallel_installer.rb:99:in `call'
  /home/deivid/.rbenv/versions/2.7.2/lib/ruby/site_ruby/2.7.0/bundler/installer/parallel_installer.rb:78:in `call'
  /home/deivid/.rbenv/versions/2.7.2/lib/ruby/site_ruby/2.7.0/bundler/installer.rb:285:in `install_in_parallel'
  /home/deivid/.rbenv/versions/2.7.2/lib/ruby/site_ruby/2.7.0/bundler/installer.rb:209:in `install'
  /home/deivid/.rbenv/versions/2.7.2/lib/ruby/site_ruby/2.7.0/bundler/installer.rb:91:in `block in run'
  /home/deivid/.rbenv/versions/2.7.2/lib/ruby/site_ruby/2.7.0/bundler/process_lock.rb:12:in `block in lock'
  /home/deivid/.rbenv/versions/2.7.2/lib/ruby/site_ruby/2.7.0/bundler/process_lock.rb:9:in `open'
  /home/deivid/.rbenv/versions/2.7.2/lib/ruby/site_ruby/2.7.0/bundler/process_lock.rb:9:in `lock'
  /home/deivid/.rbenv/versions/2.7.2/lib/ruby/site_ruby/2.7.0/bundler/installer.rb:72:in `run'
  /home/deivid/.rbenv/versions/2.7.2/lib/ruby/site_ruby/2.7.0/bundler/installer.rb:24:in `install'
  /home/deivid/.rbenv/versions/2.7.2/lib/ruby/site_ruby/2.7.0/bundler/cli/install.rb:64:in `run'
  /home/deivid/.rbenv/versions/2.7.2/lib/ruby/site_ruby/2.7.0/bundler/cli.rb:262:in `block in install'
  /home/deivid/.rbenv/versions/2.7.2/lib/ruby/site_ruby/2.7.0/bundler/settings.rb:116:in `temporary'
  /home/deivid/.rbenv/versions/2.7.2/lib/ruby/site_ruby/2.7.0/bundler/cli.rb:261:in `install'
  /home/deivid/.rbenv/versions/2.7.2/lib/ruby/site_ruby/2.7.0/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
  /home/deivid/.rbenv/versions/2.7.2/lib/ruby/site_ruby/2.7.0/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
  /home/deivid/.rbenv/versions/2.7.2/lib/ruby/site_ruby/2.7.0/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
  /home/deivid/.rbenv/versions/2.7.2/lib/ruby/site_ruby/2.7.0/bundler/cli.rb:30:in `dispatch'
  /home/deivid/.rbenv/versions/2.7.2/lib/ruby/site_ruby/2.7.0/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
  /home/deivid/.rbenv/versions/2.7.2/lib/ruby/site_ruby/2.7.0/bundler/cli.rb:24:in `start'
  /home/deivid/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.0.rc.2/exe/bundle:49:in `block in <top (required)>'
  /home/deivid/.rbenv/versions/2.7.2/lib/ruby/site_ruby/2.7.0/bundler/friendly_errors.rb:117:in `with_friendly_errors'
  /home/deivid/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.0.rc.2/exe/bundle:37:in `<top (required)>'
  /home/deivid/.rbenv/versions/2.7.2/bin/bundle:23:in `load'
  /home/deivid/.rbenv/versions/2.7.2/bin/bundle:23:in `<main>'
  /home/deivid/.rbenv/versions/2.7.2/bin/ruby_executable_hooks:24:in `eval'
  /home/deivid/.rbenv/versions/2.7.2/bin/ruby_executable_hooks:24:in `<main>'

What is your fix for the problem, implemented in this PR?

Bundler inherits from rubygems installer and uses this method directly. It can happen that fileutils is not yet required at that point.

To repro the issue I needed to make sure that the executables inside dummy specs have the executable bit set. Otherwise a different code path that does require fileutils is run. This seems like a good thing anyways since it better resembles the real world.

The fix is to add the missing require.

Make sure he following tasks are checked

Bundler inherits from rubygems installer and uses this method directly.
It can happen that `fileutils` is not yet required at that point.

To repro the issue I needed to make sure that the executables inside
dummy specs have the executable bit set. Otherwise a different code path
that _does_ require `fileutils` is run. This seems like a good thing
anyways since it better resembles the real world.
@deivid-rodriguez deivid-rodriguez merged commit 48a4fe3 into master Oct 30, 2020
@deivid-rodriguez deivid-rodriguez deleted the fileutils_require branch October 30, 2020 10:14
deivid-rodriguez added a commit that referenced this pull request Dec 7, 2020
Add missing `fileutils` require in rubygems installer

(cherry picked from commit 48a4fe3)
deivid-rodriguez added a commit that referenced this pull request Dec 7, 2020
Add missing `fileutils` require in rubygems installer

(cherry picked from commit 48a4fe3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants