Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Bundler >= 2.1.1 ERROR: While executing gem ... (Gem::CommandLineError) Too many gem names #7512

Closed
shadydealer opened this issue Dec 20, 2019 · 2 comments · Fixed by #7514
Closed

Comments

@shadydealer
Copy link

shadydealer commented Dec 20, 2019

We recently ran into a problem when we updated to bundler 2.1.1 and ran the following command:

jenkins@vpszap6s:~/jobs/is-babylon_scene Build and Release/workspace$ bundle _2.1.1_ exec rake build

output:

rake aborted!
ERROR:  While executing gem ... (Gem::CommandLineError)
    Too many gem names (/var/lib/jenkins/jobs/is-babylon_scene, Build, and, Release/workspace/is-babylon_scene.gemspec); please specify only one
/usr/local/rvm/gems/ruby-2.6.5/gems/bundler-2.1.1/lib/bundler/gem_helper.rb:190:in `sh'
/usr/local/rvm/gems/ruby-2.6.5/gems/bundler-2.1.1/lib/bundler/gem_helper.rb:76:in `build_gem'
/usr/local/rvm/gems/ruby-2.6.5/gems/bundler-2.1.1/lib/bundler/gem_helper.rb:40:in `block in install'
/usr/local/rvm/gems/ruby-2.6.5/gems/rake-13.0.1/exe/rake:27:in `<top (required)>'
/usr/local/rvm/gems/ruby-2.6.5/bin/ruby_executable_hooks:24:in `eval'
/usr/local/rvm/gems/ruby-2.6.5/bin/ruby_executable_hooks:24:in `<main>'
Tasks: TOP => build
(See full trace by running task with --trace)

Turns out it's because we're running it from a path which contains white spaces. The exact same error can be reproduced when running rake build with bundle 2.1.2 but it seems to be working on older versions, such as 2.0.2. Can you please fix this? Thanks in advance!

@deivid-rodriguez
Copy link
Member

deivid-rodriguez commented Dec 20, 2019

Hi @shadydealer. Could you manually apply this change and tell me if it fixes things for you?

diff --git a/lib/bundler/gem_helper.rb b/lib/bundler/gem_helper.rb
index 7d4e382be8..a09d03a448 100644
--- a/lib/bundler/gem_helper.rb
+++ b/lib/bundler/gem_helper.rb
@@ -73,7 +73,7 @@ module Bundler
 
     def build_gem
       file_name = nil
-      sh("#{gem_command} build -V #{spec_path}".shellsplit) do
+      sh("#{gem_command} build -V #{spec_path.shellescape}".shellsplit) do
         file_name = File.basename(built_gem_path)
         SharedHelpers.filesystem_access(File.join(base, "pkg")) {|p| FileUtils.mkdir_p(p) }
         FileUtils.mv(built_gem_path, "pkg")

I was able to reproduce a similar error, and fix it, with this patch, but I want to double check, since the error was not the same.

@shadydealer
Copy link
Author

Hi @deivid-rodriguez. Yes this does indeed fix the error. Thanks!

@ghost ghost closed this as completed in 26888b6 Dec 22, 2019
deivid-rodriguez pushed a commit that referenced this issue Jan 1, 2020
7514: Fix `rake build` when path has spaces on it r=colby-swandale a=deivid-rodriguez

### What was the end-user problem that led to this PR?

The problem was that `rake build` can no longer be run from a path that has spaces on it.

### What was your diagnosis of the problem?

My diagnosis was that we need to escape the path for the shell somewhere.

### What is your fix for the problem, implemented in this PR?

My fix is to add `.shellescape` at the right place.

### Why did you choose this fix out of the possible options?

I chose this fix because it fixes the problem.

Fixes #7512.

Co-authored-by: David Rodríguez <[email protected]>
(cherry picked from commit 26888b6)
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants