Skip to content

Commit

Permalink
Auto merge of rubygems#6191 - elia:patch-1, r=colby-swandale
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bundlerbot committed Nov 30, 2017
2 parents 953acf7 + 107772e commit 5e49f42
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/bundler/templates/newgem/newgem.gemspec.tt
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
Expand Down

0 comments on commit 5e49f42

Please sign in to comment.