Skip to content

Commit

Permalink
Add missing fileutils require in rubygems installer
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
deivid-rodriguez committed Oct 26, 2020
1 parent ad9f9d1 commit 1e1947d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
6 changes: 5 additions & 1 deletion bundler/spec/install/gemfile/git_spec.rb
Expand Up @@ -30,11 +30,15 @@
expect(Dir["#{default_bundle_path}/cache/bundler/git/foo-1.0-*"]).to have_attributes :size => 1
end

it "caches the git repo globally" do
it "caches the git repo globally and properly uses the cached repo on the next invocation" do
simulate_new_machine
bundle "config set global_gem_cache true"
bundle :install
expect(Dir["#{home}/.bundle/cache/git/foo-1.0-*"]).to have_attributes :size => 1

bundle "install --verbose"
expect(err).to be_empty
expect(out).to include("Using foo 1.0 from #{lib_path("foo")}")
end

it "caches the evaluated gemspec" do
Expand Down
1 change: 1 addition & 0 deletions bundler/spec/support/builders.rb
Expand Up @@ -523,6 +523,7 @@ def @spec.validate(*); end
file = Pathname.new(path).join(file)
FileUtils.mkdir_p(file.dirname)
File.open(file, "w") {|f| f.puts source }
File.chmod("+x", file) if @spec.executables.map {|exe| "#{@spec.bindir}/#{exe}" }.include?(file)
end
path
end
Expand Down
1 change: 1 addition & 0 deletions lib/rubygems/installer.rb
Expand Up @@ -530,6 +530,7 @@ def generate_plugins # :nodoc:
def generate_bin_script(filename, bindir)
bin_script_path = File.join bindir, formatted_program_filename(filename)

require 'fileutils'
FileUtils.rm_f bin_script_path # prior install may have been --no-wrappers

File.open bin_script_path, 'wb', 0755 do |file|
Expand Down

0 comments on commit 1e1947d

Please sign in to comment.