diff options
author | The Bundler Bot <bot@bundler.io> | 2017-11-30 22:27:48 +0000 |
---|---|---|
committer | The Bundler Bot <bot@bundler.io> | 2017-11-30 22:27:48 +0000 |
commit | 5e49f422b69df8fc5a0c0c06cb1adfc167212b5d (patch) | |
tree | 705c6389606cd62671ba2301fa11fa225935397d | |
parent | 953acf7eb7c27f8fb569713c5276e12561687d6d (diff) | |
parent | 107772e562b51d3e355925a55714d566fe484c88 (diff) | |
download | bundler-5e49f422b69df8fc5a0c0c06cb1adfc167212b5d.tar.gz |
Auto merge of #6191 - elia:patch-1, r=colby-swandale
Ensure git is executed inside the gemspec dir
### What was the end-user problem that led to this PR?
Executables from bundled gems weren't available.
```
Gem::Exception: can't find executable <EXEC-FILENAME> for gem <GEM-NAME>
/Users/elia/.rvm/rubies/ruby-2.3.4/lib/ruby/site_ruby/2.3.0/bundler/rubygems_integration.rb:458:in `block in replace_bin_path'
/Users/elia/.rvm/rubies/ruby-2.3.4/lib/ruby/site_ruby/2.3.0/bundler/rubygems_integration.rb:478:in `block in replace_bin_path'
…
```
### What was your diagnosis of the problem?
When a Gemfile was pointing to a local gem using git to list its files the git command
was executed from within the wrong dir.
### What is your fix for the problem, implemented in this PR?
Initially I added `-C #{__dir__}` to the `git ls-files -z` command.
### Why did you choose this fix out of the possible options?
Realized `-C` wasn't safe and opted for stuff already available in the corelib, i.e. `Dir.chrid` instead of, say, escaping with `shellwords`.
---
I know the line is long-ish, happy to fix it in the way you want
-rw-r--r-- | lib/bundler/templates/newgem/newgem.gemspec.tt | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/bundler/templates/newgem/newgem.gemspec.tt b/lib/bundler/templates/newgem/newgem.gemspec.tt index 1236bb1bd7..97da2b14d8 100644 --- a/lib/bundler/templates/newgem/newgem.gemspec.tt +++ b/lib/bundler/templates/newgem/newgem.gemspec.tt @@ -28,8 +28,8 @@ Gem::Specification.new do |spec| "public gem pushes." end - spec.files = `git ls-files -z`.split("\x0").reject do |f| - f.match(%r{^(test|spec|features)/}) + spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do + `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } end spec.bindir = "exe" spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } |