diff options
author | The Bundler Bot <bot@bundler.io> | 2018-04-19 23:22:51 +0000 |
---|---|---|
committer | Colby Swandale <me@colby.fyi> | 2018-04-20 10:28:36 +1000 |
commit | 96d9982ba510ca404b5bfbbf211a977d4d7d286d (patch) | |
tree | 62130bf59d295f247f9acdd86762c152dfd67702 | |
parent | 21fe7d372e01f76aa73751487755ce2fa67d8635 (diff) | |
download | bundler-96d9982ba510ca404b5bfbbf211a977d4d7d286d.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.
(cherry picked from commit 183c986dc89c25e332617fa3609efbed43f5df63)
-rw-r--r-- | lib/bundler/injector.rb | 3 |
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 |