Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

bundle exec sometimes fails due to bug in Ruby 1.8 on Windows #832

jarmo opened this Issue Nov 10, 2010 · 17 comments


None yet
8 participants

jarmo commented Nov 10, 2010

This works:
bundle exec ping localhost

This doesn't work:
bundle exec ping.exe localhost
bundler: command not found: ping.exe
Install missing gem binaries with bundle install

This works:
bundle exec c:\windows\system32\ping.exe localhost

This doesn't work:
bundle exec c:\windows\system32\ping localhost
bundler: command not found: c:\windows\system32\ping
Install missing gem binaries with bundle install


radar commented Nov 10, 2010

Could you please explain why you would be using bundle exec to run a non ruby command?


jarmo commented Nov 10, 2010

I wouldn't. These were just a simple examples made by me to show what fails and what doesn't. Also note that using Kernel.system() works with every combination above.

The actual problem (why i that issue with Bundler itself) is that trying to use Autotest with RSpec2 fails since RSpec 2 wants to bundle exec ruby[1] where the path to Ruby is given by Autotest [2] and it is a full path to ruby without an ".exe" - e.g "c:\ruby\bin\ruby".

Does it make more sense now?

[1] https://github.com/rspec/rspec-core/blob/master/lib/autotest/rspec2.rb#L44

[2] https://github.com/grosser/autotest/blob/master/lib/autotest.rb#L522-530


radar commented Nov 10, 2010

Thank you for clarifying, please use real examples in the future as they may alter the outcome. I'm in transit right now so can't be too helpful.

What makes you think it is a bundler problem and not an autotest-on-windows one?


jarmo commented Nov 10, 2010

Real life examples tend to be more complex and might make it harder to understand what's the exact problem reported when there's too much verbosity and unneeded additional information. I'm usually trying to localize the problem to be as simple as possible when reporting it. I agree though that this concrete bug report might not have been suffered too much by providing real example provided in my earlier comment.

But back to the problem itself - why i think it is a problem with Bundler and not anything else?

Because Autotest get's ruby's binary path from rbconfig and that path is okay for other process execution methods like Kernel.system() and IO.popen() as mentioned above. Only thing that has problem with that path seems to be Bundler.

There might be other libraries which would like to use ruby-s binary under Windows too in addition to Autotest and will fail currently when used with Bundler, but will work individually.


indirect commented Nov 11, 2010

Jarmo, bundle exec does not use Kernel.system(). It uses Kernel.exec(), because that is the only way to exec. As you can see in the implementation of Bundler::CLI.exec, Bundler simply calls Kernel.exec().

The issues you are describing appear to be a limitation of Kernel.exec() on Windows. If you think that's not true, please include some examples of commands that work with Kernel.exec() but fail with bundle exec. Thanks.


jarmo commented Nov 11, 2010

At first it seemed to me that even Kernel.exec works with all the commands above and it does - only if the command is given as single argument to the Kernel.exec. Since in Bundler ARGV is splatted, then Kernel.exec won't work under some circumstances (for some reason). I don't know if it's a bug or a feature in Windows or in Ruby?

But any reason why it has to be splatted and could not use ARGV.join(" ") instead?

That change would solve the problem under Windows. I don't know if it can use cause any problems on other os-es.

soend commented Nov 18, 2010

Having exactly same problem, jarmo, did u find any solution for this?


jarmo commented Nov 18, 2010

Try to replace Kernel.exec(*ARGV) with Kernel.exec(ARGV.join(" ")) in bundler/cli.rb.

Why this bug got closed without making it working for Windows in the first place?


indirect commented Nov 18, 2010

As you can see in Programming Ruby, Kernel#exec has to be splatted because if it is not, the arguments are subject to shell expansion. Shell expansion will have already happened once when you typed the arguments to bundle exec, so shell expansion a second time would break bundle exec.

I don't have a Windows machine, but it seems like this would be an identical problem on Windows: shell escaping twice will break things. I am definitely open to suggestions, but I do not consider exec on Windows broken.

soend commented Nov 18, 2010

Thanks jarmo, got it working.


jarmo commented Nov 18, 2010

indirect, you are correct...

But in Windows there is no shell expansion - at least not with * or ? (you can read more about it from [1]). I guess the only solution then not to break nix compatibility would be to add some "if statement" which would do ARGV.join(" ") if Windows is used. I don't have any ideas though, why on Windows Kernel#exec doesn't work like Kernel#system or IO#popen does. Do you? Nevertheless i'm going to make a post about it to Ruby mailing list - maybe someone has some clever answer :)

So i guess something like this might work:
RUBY_PLATFORM =~ /mswin|msys|mingw32/ ? Kernel.exec(ARGV.join(" ")) : Kernel.exec(*ARGV)

[1] http://blogs.msdn.com/b/dancre/archive/2005/05/14/417547.aspx


I tracked you and this article all the way from the original autotest issue you reported elsewhere. How do you propose I fix the problem of autotest and Rspec2 failing on windows due to the ruby path issue.

I am a newbie to ruby and rails. Thanks so much.


P.S: Yes there are windows ruby & rails users out there!

ahoward commented Nov 28, 2010

systemu gives completely portable process execution, pid, status, stderr, and stdout. might be able to work that in as a simple solution. fyi.


indirect commented Nov 28, 2010

Ara, thanks for the offer, but our policy is that Bundler not have any gem dependencies. The chance that dependency madness will ensue is just too high. :\

We'll try to get exec fixed on Windows by the next point release. We'll also be be integrating a bunch of other Windows fixes.


jarmo commented Nov 28, 2010

As promised i've made a post to the Ruby mailing list where Luis Lavena commented that it is a bug in Ruby 1.8.x. See the post itself: http://groups.google.com/group/comp.lang.ruby/browse_thread/thread/c4b04e6aeb69e70d

As it turned out then Rake for example is dealing with these (or similar) situations already. I'd still go with the ARGV.join(" ") solution for Windows users since there isn't any shell expansions happening in Windows shell as noted above.

What about reopening this bug?

lstoldt commented Dec 3, 2010

I can confirm I get this when using Ruby 1.8.7 and but not when I'm using 1.9.2p0


ixti commented Jul 8, 2013

Ruby 1.8 is EOL.

@ixti ixti closed this Jul 8, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment