summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThe Bundler Bot <bot@bundler.io>2018-04-19 23:22:51 +0000
committerThe Bundler Bot <bot@bundler.io>2018-04-19 23:22:51 +0000
commit183c986dc89c25e332617fa3609efbed43f5df63 (patch)
tree625cae52b88f4090004e1ce0f33629f6ce3b0b21
parente5c06862a620b8e0bc778164f0e426f927c10cba (diff)
parente03eaf23c8da2dcce01457158a30a9b61358d7d7 (diff)
downloadbundler-183c986dc89c25e332617fa3609efbed43f5df63.tar.gz
Auto merge of #6476 - tobias-grasse:master, r=colby-swandale
Document parameters and return value of Injector#inject Summary: Use File.open instead of Kernel.open to avoid private method call when using Bundler::Injector in Ruby script. ### What was the end-user problem that led to this PR? My app should allow users to install extensions at runtime. When using `Bundler::Injector`'s `inject` in a Ruby script, the internal method `append_to` fails with the error below. Calling system('bundle inject GEM VERSION') is not feasible in my use case, since I want to inject the gem in a secondary Gemfile. ### What was your diagnosis of the problem? The error that occurs when trying to inject a dependency through a call to `Bundler::Injector.inject`: `bundler-1.16.1/lib/bundler/injector.rb:85:in 'append_to': private method `open' called for "Gemfile.local":String (NoMethodError)` ### What is your fix for the problem, implemented in this PR? My fix replaces Kernel.open with File.open to open the Gemfile. ### Why did you choose this fix out of the possible options? I chose this fix because it does not break current `bundle inject GEM VERSION` CLI behavior and does not introduce additional dependencies.
-rw-r--r--lib/bundler/injector.rb3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/bundler/injector.rb b/lib/bundler/injector.rb
index 6f9669ae4f..9c67a80777 100644
--- a/lib/bundler/injector.rb
+++ b/lib/bundler/injector.rb
@@ -12,6 +12,9 @@ module Bundler
@options = options
end
+ # @param [Pathname] gemfile_path The Gemfile in which to inject the new dependency.
+ # @param [Pathname] lockfile_path The lockfile in which to inject the new dependency.
+ # @return [Array]
def inject(gemfile_path, lockfile_path)
if Bundler.frozen_bundle?
# ensure the lock and Gemfile are synced